1
Fork 0

Bless tests

This commit is contained in:
Michael Goulet 2023-09-26 20:20:25 +00:00
parent ec79720c1e
commit 28d58f6524
26 changed files with 40 additions and 7 deletions

View file

@ -9,12 +9,14 @@ use std::fmt::Debug;
trait MyTrait<'a, 'b, T> where Self: 'a, T: Debug + Sized + 'b { trait MyTrait<'a, 'b, T> where Self: 'a, T: Debug + Sized + 'b {
type MyAssoc; type MyAssoc;
#[allow(async_fn_in_trait)]
async fn foo(&'a self, key: &'b T) -> Self::MyAssoc; async fn foo(&'a self, key: &'b T) -> Self::MyAssoc;
} }
impl<'a, 'b, T: Debug + Sized + 'b, U: 'a> MyTrait<'a, 'b, T> for U { impl<'a, 'b, T: Debug + Sized + 'b, U: 'a> MyTrait<'a, 'b, T> for U {
type MyAssoc = (&'a U, &'b T); type MyAssoc = (&'a U, &'b T);
#[allow(async_fn_in_trait)]
async fn foo(&'a self, key: &'b T) -> (&'a U, &'b T) { async fn foo(&'a self, key: &'b T) -> (&'a U, &'b T) {
(self, key) (self, key)
} }

View file

@ -6,10 +6,12 @@
use std::future::Future; use std::future::Future;
trait AsyncTrait { trait AsyncTrait {
#[allow(async_fn_in_trait)]
async fn default_impl() { async fn default_impl() {
assert!(false); assert!(false);
} }
#[allow(async_fn_in_trait)]
async fn call_default_impl() { async fn call_default_impl() {
Self::default_impl().await Self::default_impl().await
} }

View file

@ -10,6 +10,7 @@ use std::pin::Pin;
use std::task::Poll; use std::task::Poll;
pub trait MyTrait { pub trait MyTrait {
#[allow(async_fn_in_trait)]
async fn foo(&self) -> i32; async fn foo(&self) -> i32;
} }

View file

@ -8,6 +8,7 @@
use std::future::Future; use std::future::Future;
trait MyTrait { trait MyTrait {
#[allow(async_fn_in_trait)]
async fn foo(&self) -> i32; async fn foo(&self) -> i32;
} }

View file

@ -5,7 +5,10 @@
#![allow(incomplete_features)] #![allow(incomplete_features)]
trait MyTrait { trait MyTrait {
#[allow(async_fn_in_trait)]
async fn foo(&self) -> i32; async fn foo(&self) -> i32;
#[allow(async_fn_in_trait)]
async fn bar(&self) -> i32; async fn bar(&self) -> i32;
} }

View file

@ -7,6 +7,7 @@
use std::fmt::Debug; use std::fmt::Debug;
trait MyTrait<'a, 'b, T> { trait MyTrait<'a, 'b, T> {
#[allow(async_fn_in_trait)]
async fn foo(&'a self, key: &'b T) -> (&'a Self, &'b T) where T: Debug + Sized; async fn foo(&'a self, key: &'b T) -> (&'a Self, &'b T) where T: Debug + Sized;
} }

View file

@ -5,6 +5,7 @@
#![allow(incomplete_features)] #![allow(incomplete_features)]
trait MyTrait<'a, 'b, T> { trait MyTrait<'a, 'b, T> {
#[allow(async_fn_in_trait)]
async fn foo(&'a self, key: &'b T) -> (&'a Self, &'b T); async fn foo(&'a self, key: &'b T) -> (&'a Self, &'b T);
} }

View file

@ -5,6 +5,7 @@
#![allow(incomplete_features)] #![allow(incomplete_features)]
pub trait Foo { pub trait Foo {
#[allow(async_fn_in_trait)]
async fn foo(&mut self); async fn foo(&mut self);
} }

View file

@ -5,6 +5,7 @@
#![allow(incomplete_features)] #![allow(incomplete_features)]
pub trait Foo { pub trait Foo {
#[allow(async_fn_in_trait)]
async fn foo(&mut self); async fn foo(&mut self);
} }

View file

@ -7,6 +7,8 @@
trait TcpStack { trait TcpStack {
type Connection<'a>: Sized where Self: 'a; type Connection<'a>: Sized where Self: 'a;
fn connect<'a>(&'a self) -> Self::Connection<'a>; fn connect<'a>(&'a self) -> Self::Connection<'a>;
#[allow(async_fn_in_trait)]
async fn async_connect<'a>(&'a self) -> Self::Connection<'a>; async fn async_connect<'a>(&'a self) -> Self::Connection<'a>;
} }

View file

@ -10,6 +10,8 @@ async fn yield_now() {}
trait AsyncIterator { trait AsyncIterator {
type Item; type Item;
#[allow(async_fn_in_trait)]
async fn next(&mut self) -> Option<Self::Item>; async fn next(&mut self) -> Option<Self::Item>;
} }

View file

@ -6,5 +6,6 @@
#![allow(incomplete_features)] #![allow(incomplete_features)]
trait T { trait T {
#[allow(async_fn_in_trait)]
async fn foo(); async fn foo();
} }

View file

@ -5,6 +5,7 @@
#![allow(incomplete_features)] #![allow(incomplete_features)]
pub trait SpiDevice { pub trait SpiDevice {
#[allow(async_fn_in_trait)]
async fn transaction<F, R>(&mut self); async fn transaction<F, R>(&mut self);
} }

View file

@ -8,6 +8,7 @@ use std::future::Future;
pub trait Pool { pub trait Pool {
type Conn; type Conn;
#[allow(async_fn_in_trait)]
async fn async_callback<'a, F: FnOnce(&'a Self::Conn) -> Fut, Fut: Future<Output = ()>>( async fn async_callback<'a, F: FnOnce(&'a Self::Conn) -> Fut, Fut: Future<Output = ()>>(
&'a self, &'a self,
callback: F, callback: F,

View file

@ -9,6 +9,7 @@ use std::future::Future;
use std::marker::PhantomData; use std::marker::PhantomData;
trait Lockable<K, V> { trait Lockable<K, V> {
#[allow(async_fn_in_trait)]
async fn lock_all_entries(&self) -> impl Future<Output = Guard<'_>>; async fn lock_all_entries(&self) -> impl Future<Output = Guard<'_>>;
} }

View file

@ -11,6 +11,7 @@
pub struct SharedState {} pub struct SharedState {}
pub trait State { pub trait State {
#[allow(async_fn_in_trait)]
async fn execute(self, shared_state: &SharedState); async fn execute(self, shared_state: &SharedState);
} }

View file

@ -1,5 +1,5 @@
error[E0658]: return type notation is experimental error[E0658]: return type notation is experimental
--> $DIR/feature-gate-return_type_notation.rs:14:17 --> $DIR/feature-gate-return_type_notation.rs:15:17
| |
LL | fn foo<T: Trait<m(): Send>>() {} LL | fn foo<T: Trait<m(): Send>>() {}
| ^^^^^^^^^ | ^^^^^^^^^
@ -8,7 +8,7 @@ LL | fn foo<T: Trait<m(): Send>>() {}
= help: add `#![feature(return_type_notation)]` to the crate attributes to enable = help: add `#![feature(return_type_notation)]` to the crate attributes to enable
error: parenthesized generic arguments cannot be used in associated type constraints error: parenthesized generic arguments cannot be used in associated type constraints
--> $DIR/feature-gate-return_type_notation.rs:14:17 --> $DIR/feature-gate-return_type_notation.rs:15:17
| |
LL | fn foo<T: Trait<m(): Send>>() {} LL | fn foo<T: Trait<m(): Send>>() {}
| ^-- | ^--
@ -16,7 +16,7 @@ LL | fn foo<T: Trait<m(): Send>>() {}
| help: remove these parentheses | help: remove these parentheses
error[E0220]: associated type `m` not found for `Trait` error[E0220]: associated type `m` not found for `Trait`
--> $DIR/feature-gate-return_type_notation.rs:14:17 --> $DIR/feature-gate-return_type_notation.rs:15:17
| |
LL | fn foo<T: Trait<m(): Send>>() {} LL | fn foo<T: Trait<m(): Send>>() {}
| ^ associated type `m` not found | ^ associated type `m` not found

View file

@ -1,5 +1,5 @@
warning: return type notation is experimental warning: return type notation is experimental
--> $DIR/feature-gate-return_type_notation.rs:14:17 --> $DIR/feature-gate-return_type_notation.rs:15:17
| |
LL | fn foo<T: Trait<m(): Send>>() {} LL | fn foo<T: Trait<m(): Send>>() {}
| ^^^^^^^^^ | ^^^^^^^^^

View file

@ -7,6 +7,7 @@
#![feature(async_fn_in_trait)] #![feature(async_fn_in_trait)]
trait Trait { trait Trait {
#[allow(async_fn_in_trait)]
async fn m(); async fn m();
} }

View file

@ -9,6 +9,7 @@ trait AsyncLendingIterator {
where where
Self: 'a; Self: 'a;
#[allow(async_fn_in_trait)]
async fn next(&mut self) -> Option<Self::Item<'_>>; async fn next(&mut self) -> Option<Self::Item<'_>>;
} }

View file

@ -7,6 +7,7 @@
use std::fmt::Debug; use std::fmt::Debug;
trait Foo { trait Foo {
#[allow(async_fn_in_trait)]
async fn baz(&self) -> impl Debug { async fn baz(&self) -> impl Debug {
"" ""
} }

View file

@ -7,6 +7,7 @@
use std::fmt::Debug; use std::fmt::Debug;
trait Foo { trait Foo {
#[allow(async_fn_in_trait)]
async fn baz(&self) -> &str { async fn baz(&self) -> &str {
"" ""
} }

View file

@ -5,6 +5,7 @@
#![allow(incomplete_features)] #![allow(incomplete_features)]
pub trait Foo { pub trait Foo {
#[allow(async_fn_in_trait)]
async fn bar<'a: 'a>(&'a mut self); async fn bar<'a: 'a>(&'a mut self);
} }

View file

@ -4,12 +4,15 @@
#![feature(async_fn_in_trait, return_position_impl_trait_in_trait)] #![feature(async_fn_in_trait, return_position_impl_trait_in_trait)]
trait Trait { trait Trait {
#[allow(async_fn_in_trait)]
async fn foo(); async fn foo();
#[allow(async_fn_in_trait)]
async fn bar() -> i32; async fn bar() -> i32;
fn test(&self) -> impl Sized + '_; fn test(&self) -> impl Sized + '_;
#[allow(async_fn_in_trait)]
async fn baz(&self) -> &i32; async fn baz(&self) -> &i32;
} }

View file

@ -4,12 +4,15 @@
#![feature(async_fn_in_trait, return_position_impl_trait_in_trait)] #![feature(async_fn_in_trait, return_position_impl_trait_in_trait)]
trait Trait { trait Trait {
#[allow(async_fn_in_trait)]
async fn foo(); async fn foo();
#[allow(async_fn_in_trait)]
async fn bar() -> i32; async fn bar() -> i32;
fn test(&self) -> impl Sized + '_; fn test(&self) -> impl Sized + '_;
#[allow(async_fn_in_trait)]
async fn baz(&self) -> &i32; async fn baz(&self) -> &i32;
} }

View file

@ -1,15 +1,15 @@
error[E0046]: not all trait items implemented, missing: `foo`, `bar`, `test`, `baz` error[E0046]: not all trait items implemented, missing: `foo`, `bar`, `test`, `baz`
--> $DIR/suggest-missing-item.rs:18:1 --> $DIR/suggest-missing-item.rs:21:1
| |
LL | async fn foo(); LL | async fn foo();
| --------------- `foo` from trait | --------------- `foo` from trait
LL | ...
LL | async fn bar() -> i32; LL | async fn bar() -> i32;
| ---------------------- `bar` from trait | ---------------------- `bar` from trait
LL | LL |
LL | fn test(&self) -> impl Sized + '_; LL | fn test(&self) -> impl Sized + '_;
| ---------------------------------- `test` from trait | ---------------------------------- `test` from trait
LL | ...
LL | async fn baz(&self) -> &i32; LL | async fn baz(&self) -> &i32;
| ---------------------------- `baz` from trait | ---------------------------- `baz` from trait
... ...