From 9a8b0503838dd6c46c59f7cdcac61671f630cbeb Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Fri, 5 Jan 2024 18:35:31 -0800 Subject: [PATCH 01/25] Work around dead_code warning in test warning: field `0` is never read --> tests/test.rs:678:22 | 678 | pub struct Tuple(u8); | ----- ^^ | | | field in this struct | = note: `#[warn(dead_code)]` on by default help: consider changing the field to be of unit type to suppress this warning while preserving the field numbering, or remove the field | 678 | pub struct Tuple(()); | ~~ --- tests/test.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test.rs b/tests/test.rs index b78c9ff..1f62d59 100644 --- a/tests/test.rs +++ b/tests/test.rs @@ -675,7 +675,7 @@ pub mod issue53 { use async_trait::async_trait; pub struct Unit; - pub struct Tuple(u8); + pub struct Tuple(pub u8); pub struct Struct { pub x: u8, } From 7b1fec7b1fb24024219cda146ad52e0589ef89a5 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Wed, 10 Jan 2024 19:17:17 -0800 Subject: [PATCH 02/25] Update ui test suite to nightly-2024-01-11 --- tests/ui/lifetime-span.stderr | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/tests/ui/lifetime-span.stderr b/tests/ui/lifetime-span.stderr index fa16ac7..661ad5e 100644 --- a/tests/ui/lifetime-span.stderr +++ b/tests/ui/lifetime-span.stderr @@ -22,3 +22,30 @@ note: trait defined here, with 0 lifetime parameters | 22 | pub trait Trait2 { | ^^^^^^ + +error[E0195]: lifetime parameters or bounds on method `method` do not match the trait declaration + --> tests/ui/lifetime-span.rs:13:14 + | +8 | async fn method(&'r self); + | ---------------- lifetimes in impl do not match this method in trait +... +13 | async fn method(&self) {} + | ^^^^^^^^^^^^^ lifetimes do not match method in trait + +error[E0195]: lifetime parameters or bounds on method `method` do not match the trait declaration + --> tests/ui/lifetime-span.rs:18:14 + | +8 | async fn method(&'r self); + | ---------------- lifetimes in impl do not match this method in trait +... +18 | async fn method(&self) {} + | ^^^^^^^^^^^^^ lifetimes do not match method in trait + +error[E0195]: lifetime parameters or bounds on method `method` do not match the trait declaration + --> tests/ui/lifetime-span.rs:33:14 + | +23 | async fn method<'r>(&'r self); + | ---- lifetimes in impl do not match this method in trait +... +33 | async fn method(&'r self) {} + | ^^^^^^^^^^^^^^^^ lifetimes do not match method in trait From db5bfa5c9fd3f1aa27ac2e049d55b7633de38a84 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Wed, 31 Jan 2024 18:37:14 -0800 Subject: [PATCH 03/25] Update ui test suite to nightly-2024-02-01 --- tests/ui/send-not-implemented.stderr | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/ui/send-not-implemented.stderr b/tests/ui/send-not-implemented.stderr index 7152b98..5171b7c 100644 --- a/tests/ui/send-not-implemented.stderr +++ b/tests/ui/send-not-implemented.stderr @@ -9,7 +9,7 @@ error: future cannot be sent between threads safely 12 | | } | |_____^ future created by async block is not `Send` | - = help: within `{async block@$DIR/tests/ui/send-not-implemented.rs:8:26: 12:6}`, the trait `Send` is not implemented for `MutexGuard<'_, ()>` + = help: within `{async block@$DIR/tests/ui/send-not-implemented.rs:8:26: 12:6}`, the trait `Send` is not implemented for `MutexGuard<'_, ()>`, which is required by `{async block@$DIR/tests/ui/send-not-implemented.rs:8:26: 12:6}: Send` note: future is not `Send` as this value is used across an await --> tests/ui/send-not-implemented.rs:11:13 | @@ -31,7 +31,7 @@ error: future cannot be sent between threads safely 19 | | } | |_____^ future created by async block is not `Send` | - = help: within `{async block@$DIR/tests/ui/send-not-implemented.rs:14:38: 19:6}`, the trait `Send` is not implemented for `MutexGuard<'_, ()>` + = help: within `{async block@$DIR/tests/ui/send-not-implemented.rs:14:38: 19:6}`, the trait `Send` is not implemented for `MutexGuard<'_, ()>`, which is required by `{async block@$DIR/tests/ui/send-not-implemented.rs:14:38: 19:6}: Send` note: future is not `Send` as this value is used across an await --> tests/ui/send-not-implemented.rs:17:13 | From 52836cf43e9546491e6077c54eaebf39ed87adc4 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Wed, 7 Feb 2024 21:25:09 -0800 Subject: [PATCH 04/25] Avoid dead_code warnings in test warning: trait `UnsafeTraitPubCrate` is never used --> tests/test.rs:160:25 | 160 | pub(crate) unsafe trait UnsafeTraitPubCrate {} | ^^^^^^^^^^^^^^^^^^^ | = note: `#[warn(dead_code)]` on by default warning: trait `UnsafeTraitPrivate` is never used --> tests/test.rs:163:14 | 163 | unsafe trait UnsafeTraitPrivate {} | ^^^^^^^^^^^^^^^^^^ warning: trait `CanDestruct` is never used --> tests/test.rs:167:11 | 167 | trait CanDestruct { | ^^^^^^^^^^^ warning: trait `Trait` is never used --> tests/test.rs:184:11 | 184 | trait Trait { | ^^^^^ warning: trait `Trait` is never used --> tests/test.rs:206:15 | 206 | pub trait Trait { | ^^^^^ warning: trait `Trait` is never used --> tests/test.rs:231:15 | 231 | pub trait Trait { | ^^^^^ warning: trait `Issue1` is never used --> tests/test.rs:243:11 | 243 | trait Issue1 { | ^^^^^^ warning: trait `Issue11` is never used --> tests/test.rs:287:11 | 287 | trait Issue11 { | ^^^^^^^ warning: struct `Struct` is never constructed --> tests/test.rs:291:12 | 291 | struct Struct; | ^^^^^^ warning: trait `Trait` is never used --> tests/test.rs:304:11 | 304 | trait Trait {} | ^^^^^ warning: trait `Issue15` is never used --> tests/test.rs:307:11 | 307 | trait Issue15 { | ^^^^^^^ warning: trait `Issue17` is never used --> tests/test.rs:317:11 | 317 | trait Issue17 { | ^^^^^^^ warning: struct `Struct` is never constructed --> tests/test.rs:321:12 | 321 | struct Struct { | ^^^^^^ warning: struct `Str` is never constructed --> tests/test.rs:412:12 | 412 | struct Str<'a>(&'a str); | ^^^ warning: trait `Trait1` is never used --> tests/test.rs:415:11 | 415 | trait Trait1<'a> { | ^^^^^^ warning: trait `Trait2` is never used --> tests/test.rs:430:11 | 430 | trait Trait2 { | ^^^^^^ warning: trait `Trait3` is never used --> tests/test.rs:440:11 | 440 | trait Trait3<'a, 'b> { | ^^^^^^ warning: trait `Trait` is never used --> tests/test.rs:870:11 | 870 | trait Trait { | ^^^^^ warning: trait `T1` is never used --> tests/test.rs:1006:11 | 1006 | trait T1 { | ^^ warning: struct `Foo` is never constructed --> tests/test.rs:1021:12 | 1021 | struct Foo; | ^^^ warning: trait `Trait` is never used --> tests/test.rs:1085:11 | 1085 | trait Trait { | ^^^^^ warning: trait `Trait` is never used --> tests/test.rs:1100:11 | 1100 | trait Trait { | ^^^^^ warning: trait `TestTrait` is never used --> tests/test.rs:1140:11 | 1140 | trait TestTrait { | ^^^^^^^^^ warning: trait `Trait` is never used --> tests/test.rs:1287:11 | 1287 | trait Trait { | ^^^^^ warning: struct `Struct` is never constructed --> tests/test.rs:1293:12 | 1293 | struct Struct; | ^^^^^^ warning: trait `Foo` is never used --> tests/test.rs:1402:11 | 1402 | trait Foo { | ^^^ --- tests/test.rs | 56 +++++++++++++++++++++++++++++++++------------------ 1 file changed, 36 insertions(+), 20 deletions(-) diff --git a/tests/test.rs b/tests/test.rs index 1f62d59..c910071 100644 --- a/tests/test.rs +++ b/tests/test.rs @@ -157,9 +157,11 @@ pub unsafe trait UnsafeTrait {} unsafe impl UnsafeTrait for () {} #[async_trait] +#[allow(dead_code)] pub(crate) unsafe trait UnsafeTraitPubCrate {} #[async_trait] +#[allow(dead_code)] unsafe trait UnsafeTraitPrivate {} pub async fn test_can_destruct() { @@ -177,6 +179,8 @@ pub async fn test_can_destruct() { let _d: u8 = d; } } + + let _ = ::f; } pub async fn test_self_in_macro() { @@ -199,6 +203,10 @@ pub async fn test_self_in_macro() { println!("{}", self); } } + + let _ = ::a; + let _ = ::b; + let _ = ::c; } pub async fn test_inference() { @@ -208,6 +216,10 @@ pub async fn test_inference() { Box::new(std::iter::empty()) } } + + impl Trait for () {} + + let _ = <() as Trait>::f; } pub async fn test_internal_items() { @@ -233,6 +245,10 @@ pub async fn test_unimplemented() { unimplemented!() } } + + impl Trait for () {} + + let _ = <() as Trait>::f; } // https://github.com/dtolnay/async-trait/issues/1 @@ -240,7 +256,7 @@ pub mod issue1 { use async_trait::async_trait; #[async_trait] - trait Issue1 { + pub trait Issue1 { async fn f(&self); } @@ -284,11 +300,11 @@ pub mod issue11 { use std::sync::Arc; #[async_trait] - trait Issue11 { + pub trait Issue11 { async fn example(self: Arc); } - struct Struct; + pub struct Struct; #[async_trait] impl Issue11 for Struct { @@ -301,10 +317,10 @@ pub mod issue15 { use async_trait::async_trait; use std::marker::PhantomData; - trait Trait {} + pub trait Trait {} #[async_trait] - trait Issue15 { + pub trait Issue15 { async fn myfn(&self, _: PhantomData) {} } } @@ -314,11 +330,11 @@ pub mod issue17 { use async_trait::async_trait; #[async_trait] - trait Issue17 { + pub trait Issue17 { async fn f(&self); } - struct Struct { + pub struct Struct { string: String, } @@ -409,10 +425,10 @@ pub mod issue25 { pub mod issue28 { use async_trait::async_trait; - struct Str<'a>(&'a str); + pub struct Str<'a>(&'a str); #[async_trait] - trait Trait1<'a> { + pub trait Trait1<'a> { async fn f(x: Str<'a>) -> &'a str; async fn g(x: Str<'a>) -> &'a str { x.0 @@ -427,7 +443,7 @@ pub mod issue28 { } #[async_trait] - trait Trait2 { + pub trait Trait2 { async fn f(); } @@ -437,7 +453,7 @@ pub mod issue28 { } #[async_trait] - trait Trait3<'a, 'b> { + pub trait Trait3<'a, 'b> { async fn f(_: &'a &'b ()); // chain 'a and 'b async fn g(_: &'b ()); // chain 'b only async fn h(); // do not chain @@ -867,7 +883,7 @@ pub mod issue89 { use async_trait::async_trait; #[async_trait] - trait Trait { + pub trait Trait { async fn f(&self); } @@ -1003,7 +1019,7 @@ pub mod issue104 { use async_trait::async_trait; #[async_trait] - trait T1 { + pub trait T1 { async fn id(&self) -> i32; } @@ -1018,7 +1034,7 @@ pub mod issue104 { }; } - struct Foo; + pub struct Foo; impl_t1!(Foo, 1); } @@ -1082,7 +1098,7 @@ pub mod issue120 { use async_trait::async_trait; #[async_trait] - trait Trait { + pub trait Trait { async fn f(&self); } @@ -1097,7 +1113,7 @@ pub mod issue123 { use async_trait::async_trait; #[async_trait] - trait Trait { + pub trait Trait { async fn f(&self) -> &str where T: 'async_trait, @@ -1137,7 +1153,7 @@ pub mod issue134 { use async_trait::async_trait; #[async_trait] - trait TestTrait { + pub trait TestTrait { async fn run(self) where Self: Sized, @@ -1284,13 +1300,13 @@ pub mod issue152 { use async_trait::async_trait; #[async_trait] - trait Trait { + pub trait Trait { type Assoc; async fn f(&self) -> Self::Assoc; } - struct Struct; + pub struct Struct; #[async_trait] impl Trait for Struct { @@ -1399,7 +1415,7 @@ pub mod issue183 { use async_trait::async_trait; #[async_trait] - trait Foo { + pub trait Foo { async fn foo(_n: i32) {} } } From 77b6cbf3542b6e1911473734bd7de5ef77cc3d03 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Wed, 7 Feb 2024 21:40:11 -0800 Subject: [PATCH 05/25] Enable const generics test cases on stable toolchain --- tests/test.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/test.rs b/tests/test.rs index c910071..1ad40a9 100644 --- a/tests/test.rs +++ b/tests/test.rs @@ -731,7 +731,6 @@ pub mod issue53 { } // https://github.com/dtolnay/async-trait/issues/57 -#[cfg(async_trait_nightly_testing)] pub mod issue57 { use crate::executor; use async_trait::async_trait; @@ -1148,7 +1147,6 @@ pub mod issue129 { } // https://github.com/dtolnay/async-trait/issues/134 -#[cfg(async_trait_nightly_testing)] pub mod issue134 { use async_trait::async_trait; From 8ac3241c5cebcde5a1d05c3df338f01543a76fc7 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Fri, 9 Feb 2024 19:04:01 -0800 Subject: [PATCH 06/25] Ignore incompatible_msrv clippy false positives in test https://github.com/rust-lang/rust-clippy/issues/12257 warning: current MSRV (Minimum Supported Rust Version) is `1.56.0` but this item is stable since `1.64.0` --> tests/test.rs:49:24 | 49 | self.selfref().await; | ^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#incompatible_msrv = note: `-W clippy::incompatible-msrv` implied by `-W clippy::all` = help: to override `-W clippy::all` add `#[allow(clippy::incompatible_msrv)]` warning: current MSRV (Minimum Supported Rust Version) is `1.56.0` but this item is stable since `1.64.0` --> tests/test.rs:50:35 | 50 | Self::elided_lifetime("").await; | ^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#incompatible_msrv warning: current MSRV (Minimum Supported Rust Version) is `1.56.0` but this item is stable since `1.64.0` --> tests/test.rs:51:37 | 51 | ::elided_lifetime("").await; | ^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#incompatible_msrv warning: current MSRV (Minimum Supported Rust Version) is `1.56.0` but this item is stable since `1.64.0` --> tests/test.rs:55:24 | 55 | self.selfmut().await; | ^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#incompatible_msrv warning: current MSRV (Minimum Supported Rust Version) is `1.56.0` but this item is stable since `1.64.0` --> tests/test.rs:82:24 | 82 | self.selfref().await; | ^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#incompatible_msrv warning: current MSRV (Minimum Supported Rust Version) is `1.56.0` but this item is stable since `1.64.0` --> tests/test.rs:83:35 | 83 | Self::elided_lifetime("").await; | ^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#incompatible_msrv warning: current MSRV (Minimum Supported Rust Version) is `1.56.0` but this item is stable since `1.64.0` --> tests/test.rs:84:37 | 84 | ::elided_lifetime("").await; | ^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#incompatible_msrv warning: current MSRV (Minimum Supported Rust Version) is `1.56.0` but this item is stable since `1.64.0` --> tests/test.rs:88:24 | 88 | self.selfmut().await; | ^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#incompatible_msrv warning: current MSRV (Minimum Supported Rust Version) is `1.56.0` but this item is stable since `1.64.0` --> tests/test.rs:94:17 | 94 | s.selfref().await; | ^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#incompatible_msrv warning: current MSRV (Minimum Supported Rust Version) is `1.56.0` but this item is stable since `1.64.0` --> tests/test.rs:95:17 | 95 | s.selfmut().await; | ^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#incompatible_msrv warning: current MSRV (Minimum Supported Rust Version) is `1.56.0` but this item is stable since `1.64.0` --> tests/test.rs:96:19 | 96 | s.selfvalue().await; | ^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#incompatible_msrv warning: current MSRV (Minimum Supported Rust Version) is `1.56.0` but this item is stable since `1.64.0` --> tests/test.rs:98:24 | 98 | Struct::required().await; | ^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#incompatible_msrv warning: current MSRV (Minimum Supported Rust Version) is `1.56.0` but this item is stable since `1.64.0` --> tests/test.rs:99:33 | 99 | Struct::elided_lifetime("").await; | ^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#incompatible_msrv warning: current MSRV (Minimum Supported Rust Version) is `1.56.0` but this item is stable since `1.64.0` --> tests/test.rs:100:35 | 100 | Struct::explicit_lifetime("").await; | ^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#incompatible_msrv warning: current MSRV (Minimum Supported Rust Version) is `1.56.0` but this item is stable since `1.64.0` --> tests/test.rs:101:46 | 101 | Struct::generic_type_param(Box::new("")).await; | ^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#incompatible_msrv warning: current MSRV (Minimum Supported Rust Version) is `1.56.0` but this item is stable since `1.64.0` --> tests/test.rs:104:15 | 104 | s.calls().await; | ^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#incompatible_msrv warning: current MSRV (Minimum Supported Rust Version) is `1.56.0` but this item is stable since `1.64.0` --> tests/test.rs:105:19 | 105 | s.calls_mut().await; | ^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#incompatible_msrv warning: current MSRV (Minimum Supported Rust Version) is `1.56.0` but this item is stable since `1.64.0` --> tests/test.rs:120:16 | 120 | object.f().await; | ^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#incompatible_msrv warning: current MSRV (Minimum Supported Rust Version) is `1.56.0` but this item is stable since `1.64.0` --> tests/test.rs:135:16 | 135 | object.f().await; | ^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#incompatible_msrv warning: current MSRV (Minimum Supported Rust Version) is `1.56.0` but this item is stable since `1.64.0` --> tests/test.rs:150:16 | 150 | object.f().await; | ^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#incompatible_msrv warning: current MSRV (Minimum Supported Rust Version) is `1.56.0` but this item is stable since `1.64.0` --> tests/test.rs:281:38 | 281 | let nested_future = self.await; | ^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#incompatible_msrv warning: current MSRV (Minimum Supported Rust Version) is `1.56.0` but this item is stable since `1.64.0` --> tests/test.rs:282:27 | 282 | nested_future.await | ^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#incompatible_msrv warning: current MSRV (Minimum Supported Rust Version) is `1.56.0` but this item is stable since `1.64.0` --> tests/test.rs:475:41 | 475 | let str1 = Self::hello(one).await; | ^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#incompatible_msrv warning: current MSRV (Minimum Supported Rust Version) is `1.56.0` but this item is stable since `1.64.0` --> tests/test.rs:476:41 | 476 | let str2 = Self::hello(two).await; | ^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#incompatible_msrv warning: current MSRV (Minimum Supported Rust Version) is `1.56.0` but this item is stable since `1.64.0` --> tests/test.rs:552:24 | 552 | self.bar().await; | ^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#incompatible_msrv warning: current MSRV (Minimum Supported Rust Version) is `1.56.0` but this item is stable since `1.64.0` --> tests/test.rs:549:9 | 549 | #[instrument] | ^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#incompatible_msrv warning: current MSRV (Minimum Supported Rust Version) is `1.56.0` but this item is stable since `1.64.0` --> tests/test.rs:561:9 | 561 | #[instrument(skip(self))] | ^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#incompatible_msrv warning: current MSRV (Minimum Supported Rust Version) is `1.56.0` but this item is stable since `1.64.0` --> tests/test.rs:667:31 | 667 | self.f(x).await | ^^^^^ ... 673 | implement_commands_workaround!(K: Send); | --------------------------------------- in this macro invocation | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#incompatible_msrv = note: this warning originates in the macro `implement_commands_workaround` (in Nightly builds, run with -Z macro-backtrace for more info) warning: current MSRV (Minimum Supported Rust Version) is `1.56.0` but this item is stable since `1.64.0` --> tests/test.rs:680:31 | 680 | self.f(x).await | ^^^^^ ... 686 | implement_commands!(K: Send); | ---------------------------- in this macro invocation | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#incompatible_msrv = note: this warning originates in the macro `implement_commands` (in Nightly builds, run with -Z macro-backtrace for more info) warning: current MSRV (Minimum Supported Rust Version) is `1.56.0` but this item is stable since `1.64.0` --> tests/test.rs:1068:34 | 1068 | (**self).spawn(work).await | ^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#incompatible_msrv warning: current MSRV (Minimum Supported Rust Version) is `1.56.0` but this item is stable since `1.64.0` --> tests/test.rs:1370:13 | 1370 | / futures::select! { 1371 | | () = async { 1372 | | println!("{}", self.0); 1373 | | }.fuse() => {} 1374 | | } | |_____________^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#incompatible_msrv = note: this warning originates in the macro `futures::select` (in Nightly builds, run with -Z macro-backtrace for more info) --- tests/test.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test.rs b/tests/test.rs index 1ad40a9..aae8e96 100644 --- a/tests/test.rs +++ b/tests/test.rs @@ -4,6 +4,7 @@ )] #![deny(rust_2021_compatibility)] #![allow( + clippy::incompatible_msrv, // https://github.com/rust-lang/rust-clippy/issues/12257 clippy::let_underscore_untyped, clippy::let_unit_value, clippy::missing_panics_doc, From d8c07fca1a6239883251c640922135849ef833bf Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Fri, 8 Mar 2024 18:18:33 -0800 Subject: [PATCH 07/25] Update ui test suite to nightly-2024-03-09 --- tests/ui/lifetime-span.stderr | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/tests/ui/lifetime-span.stderr b/tests/ui/lifetime-span.stderr index 661ad5e..021c9fc 100644 --- a/tests/ui/lifetime-span.stderr +++ b/tests/ui/lifetime-span.stderr @@ -9,20 +9,6 @@ help: indicate the anonymous lifetime 12 | impl Trait<'_> for A { | ++++ -error[E0107]: trait takes 0 lifetime arguments but 1 lifetime argument was supplied - --> tests/ui/lifetime-span.rs:32:10 - | -32 | impl<'r> Trait2<'r> for B { - | ^^^^^^---- help: remove these generics - | | - | expected 0 lifetime arguments - | -note: trait defined here, with 0 lifetime parameters - --> tests/ui/lifetime-span.rs:22:11 - | -22 | pub trait Trait2 { - | ^^^^^^ - error[E0195]: lifetime parameters or bounds on method `method` do not match the trait declaration --> tests/ui/lifetime-span.rs:13:14 | @@ -41,6 +27,20 @@ error[E0195]: lifetime parameters or bounds on method `method` do not match the 18 | async fn method(&self) {} | ^^^^^^^^^^^^^ lifetimes do not match method in trait +error[E0107]: trait takes 0 lifetime arguments but 1 lifetime argument was supplied + --> tests/ui/lifetime-span.rs:32:10 + | +32 | impl<'r> Trait2<'r> for B { + | ^^^^^^---- help: remove these generics + | | + | expected 0 lifetime arguments + | +note: trait defined here, with 0 lifetime parameters + --> tests/ui/lifetime-span.rs:22:11 + | +22 | pub trait Trait2 { + | ^^^^^^ + error[E0195]: lifetime parameters or bounds on method `method` do not match the trait declaration --> tests/ui/lifetime-span.rs:33:14 | From 62969d525fbd76abec15edf00289ced049b7fa0a Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Mon, 11 Mar 2024 20:01:03 -0700 Subject: [PATCH 08/25] Ignore new dead_code warnings in test Since nightly-2024-03-12. warning: struct `S` is never constructed --> tests/test.rs:366:12 | 366 | struct S {} | ^ | = note: `#[warn(dead_code)]` on by default warning: struct `Struct` is never constructed --> tests/test.rs:1492:12 | 1492 | struct Struct; | ^^^^^^ --- tests/test.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/test.rs b/tests/test.rs index aae8e96..cbd8e03 100644 --- a/tests/test.rs +++ b/tests/test.rs @@ -363,6 +363,7 @@ pub mod issue23 { } } + #[allow(dead_code)] struct S {} #[async_trait] @@ -1489,6 +1490,7 @@ pub mod issue226 { async fn cfg_param_tuple(&self, (left, right): (u8, u8)); } + #[allow(dead_code)] struct Struct; #[async_trait] From 2002954964e7976bcc14c1d981397062ca84f4fd Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Sat, 16 Mar 2024 16:02:47 -0700 Subject: [PATCH 09/25] Reproduce unused_qualifications lint in tests error: unnecessary qualification --> tests/test.rs:29:5 | 29 | async fn selfvalue(self) | ^^^^^ | note: the lint level is defined here --> tests/test.rs:5:34 | 5 | #![deny(rust_2021_compatibility, unused_qualifications)] | ^^^^^^^^^^^^^^^^^^^^^ help: remove the unnecessary path segments | 29 | async fn selfvalue(self) | error: unnecessary qualification --> tests/test.rs:35:5 | 35 | async fn selfref(&self) {} | ^^^^^ | help: remove the unnecessary path segments | 35 | async fn selfref(&self) {} | error: unnecessary qualification --> tests/test.rs:37:5 | 37 | async fn selfmut(&mut self) {} | ^^^^^ | help: remove the unnecessary path segments | 37 | async fn selfmut(&mut self) {} | error: unnecessary qualification --> tests/test.rs:39:5 | 39 | async fn required() -> Self::Assoc; | ^^^^^ | help: remove the unnecessary path segments | 39 | async fn required() -> Self::Assoc; | error: unnecessary qualification --> tests/test.rs:41:5 | 41 | async fn elided_lifetime(_x: &str) {} | ^^^^^ | help: remove the unnecessary path segments | 41 | async fn elided_lifetime(_x: &str) {} | error: unnecessary qualification --> tests/test.rs:43:5 | 43 | async fn explicit_lifetime<'a>(_x: &'a str) {} | ^^^^^ | help: remove the unnecessary path segments | 43 | async fn explicit_lifetime<'a>(_x: &'a str) {} | error: unnecessary qualification --> tests/test.rs:45:5 | 45 | async fn generic_type_param(x: Box) -> T { | ^^^^^ | help: remove the unnecessary path segments | 45 | async fn generic_type_param(x: Box) -> T { | error: unnecessary qualification --> tests/test.rs:45:58 | 45 | async fn generic_type_param(x: Box) -> T { | __________________________________________________________^ 46 | | *x 47 | | } | |_____^ | help: remove the unnecessary path segments | 45 | async fn generic_type_param(x: Box) -> T { | error: unnecessary qualification --> tests/test.rs:49:5 | 49 | async fn calls(&self) { | ^^^^^ | help: remove the unnecessary path segments | 49 | async fn calls(&self) { | error: unnecessary qualification --> tests/test.rs:55:5 | 55 | async fn calls_mut(&mut self) { | ^^^^^ | help: remove the unnecessary path segments | 55 | async fn calls_mut(&mut self) { | error: unnecessary qualification --> tests/test.rs:66:5 | 66 | async fn selfvalue(self) {} | ^^^^^ | help: remove the unnecessary path segments | 66 | async fn selfvalue(self) {} | error: unnecessary qualification --> tests/test.rs:68:5 | 68 | async fn selfref(&self) {} | ^^^^^ | help: remove the unnecessary path segments | 68 | async fn selfref(&self) {} | error: unnecessary qualification --> tests/test.rs:70:5 | 70 | async fn selfmut(&mut self) {} | ^^^^^ | help: remove the unnecessary path segments | 70 | async fn selfmut(&mut self) {} | error: unnecessary qualification --> tests/test.rs:72:5 | 72 | async fn required() -> Self::Assoc {} | ^^^^^ | help: remove the unnecessary path segments | 72 | async fn required() -> Self::Assoc {} | error: unnecessary qualification --> tests/test.rs:72:40 | 72 | async fn required() -> Self::Assoc {} | ^^ | help: remove the unnecessary path segments | 72 | async fn required() -> Self::Assoc {} | error: unnecessary qualification --> tests/test.rs:74:5 | 74 | async fn elided_lifetime(_x: &str) {} | ^^^^^ | help: remove the unnecessary path segments | 74 | async fn elided_lifetime(_x: &str) {} | error: unnecessary qualification --> tests/test.rs:76:5 | 76 | async fn explicit_lifetime<'a>(_x: &'a str) {} | ^^^^^ | help: remove the unnecessary path segments | 76 | async fn explicit_lifetime<'a>(_x: &'a str) {} | error: unnecessary qualification --> tests/test.rs:78:5 | 78 | async fn generic_type_param(x: Box) -> T { | ^^^^^ | help: remove the unnecessary path segments | 78 | async fn generic_type_param(x: Box) -> T { | error: unnecessary qualification --> tests/test.rs:78:58 | 78 | async fn generic_type_param(x: Box) -> T { | __________________________________________________________^ 79 | | *x 80 | | } | |_____^ | help: remove the unnecessary path segments | 78 | async fn generic_type_param(x: Box) -> T { | error: unnecessary qualification --> tests/test.rs:82:5 | 82 | async fn calls(&self) { | ^^^^^ | help: remove the unnecessary path segments | 82 | async fn calls(&self) { | error: unnecessary qualification --> tests/test.rs:88:5 | 88 | async fn calls_mut(&mut self) { | ^^^^^ | help: remove the unnecessary path segments | 88 | async fn calls_mut(&mut self) { | error: unnecessary qualification --> tests/test.rs:112:9 | 112 | async fn f(&self); | ^^^^^ | help: remove the unnecessary path segments | 112 | async fn f(&self); | error: unnecessary qualification --> tests/test.rs:117:9 | 117 | async fn f(&self) {} | ^^^^^ | help: remove the unnecessary path segments | 117 | async fn f(&self) {} | error: unnecessary qualification --> tests/test.rs:127:9 | 127 | async fn f(&self) {} | ^^^^^ | help: remove the unnecessary path segments | 127 | async fn f(&self) {} | error: unnecessary qualification --> tests/test.rs:132:9 | 132 | async fn f(&self) {} | ^^^^^ | help: remove the unnecessary path segments | 132 | async fn f(&self) {} | error: unnecessary qualification --> tests/test.rs:171:9 | 171 | async fn f(&self, foos: (u8, u8, u8, u8)); | ^^^^^ | help: remove the unnecessary path segments | 171 | async fn f(&self, foos: (u8, u8, u8, u8)); | error: unnecessary qualification --> tests/test.rs:176:9 | 176 | async fn f(&self, (a, ref mut b, ref c, d): (u8, u8, u8, u8)) { | ^^^^^ | help: remove the unnecessary path segments | 176 | async fn f(&self, (a, ref mut b, ref c, d): (u8, u8, u8, u8)) { | error: unnecessary qualification --> tests/test.rs:190:9 | 190 | async fn a(self); | ^^^^^ | help: remove the unnecessary path segments | 190 | async fn a(self); | error: unnecessary qualification --> tests/test.rs:191:9 | 191 | async fn b(&mut self); | ^^^^^ | help: remove the unnecessary path segments | 191 | async fn b(&mut self); | error: unnecessary qualification --> tests/test.rs:192:9 | 192 | async fn c(&self); | ^^^^^ | help: remove the unnecessary path segments | 192 | async fn c(&self); | error: unnecessary qualification --> tests/test.rs:197:9 | 197 | async fn a(self) { | ^^^^^ | help: remove the unnecessary path segments | 197 | async fn a(self) { | error: unnecessary qualification --> tests/test.rs:200:9 | 200 | async fn b(&mut self) { | ^^^^^ | help: remove the unnecessary path segments | 200 | async fn b(&mut self) { | error: unnecessary qualification --> tests/test.rs:203:9 | 203 | async fn c(&self) { | ^^^^^ | help: remove the unnecessary path segments | 203 | async fn c(&self) { | error: unnecessary qualification --> tests/test.rs:216:9 | 216 | async fn f() -> Box> { | ^^^^^ | help: remove the unnecessary path segments | 216 | async fn f() -> Box> { | error: unnecessary qualification --> tests/test.rs:216:54 | 216 | async fn f() -> Box> { | ______________________________________________________^ 217 | | Box::new(std::iter::empty()) 218 | | } | |_________^ | help: remove the unnecessary path segments | 216 | async fn f() -> Box> { | error: unnecessary qualification --> tests/test.rs:230:9 | 230 | async fn f(self) { | ^^^^^ | help: remove the unnecessary path segments | 230 | async fn f(self) { | error: unnecessary qualification --> tests/test.rs:245:9 | 245 | async fn f() { | ^^^^^ | help: remove the unnecessary path segments | 245 | async fn f() { | error: unnecessary qualification --> tests/test.rs:261:9 | 261 | async fn f(&self); | ^^^^^ | help: remove the unnecessary path segments | 261 | async fn f(&self); | error: unnecessary qualification --> tests/test.rs:266:9 | 266 | async fn f(&self) {} | ^^^^^ | help: remove the unnecessary path segments | 266 | async fn f(&self) {} | error: unnecessary qualification --> tests/test.rs:277:9 | 277 | async fn flatten(self) -> ::Output | ^^^^^ | help: remove the unnecessary path segments | 277 | async fn flatten(self) -> ::Output | error: unnecessary qualification --> tests/test.rs:281:9 | 281 | / { 282 | | let nested_future = self.await; 283 | | nested_future.await 284 | | } | |_________^ | help: remove the unnecessary path segments | 281 | { | error: unnecessary qualification --> tests/test.rs:294:9 | 294 | async fn f(_x: Self) {} | ^^^^^ | help: remove the unnecessary path segments | 294 | async fn f(_x: Self) {} | error: unnecessary qualification --> tests/test.rs:305:9 | 305 | async fn example(self: Arc); | ^^^^^ | help: remove the unnecessary path segments | 305 | async fn example(self: Arc); | error: unnecessary qualification --> tests/test.rs:312:9 | 312 | async fn example(self: Arc) {} | ^^^^^ | help: remove the unnecessary path segments | 312 | async fn example(self: Arc) {} | error: unnecessary qualification --> tests/test.rs:325:9 | 325 | async fn myfn(&self, _: PhantomData) {} | ^^^^^ | help: remove the unnecessary path segments | 325 | async fn myfn(&self, _: PhantomData) {} | error: unnecessary qualification --> tests/test.rs:335:9 | 335 | async fn f(&self); | ^^^^^ | help: remove the unnecessary path segments | 335 | async fn f(&self); | error: unnecessary qualification --> tests/test.rs:344:9 | 344 | async fn f(&self) { | ^^^^^ | help: remove the unnecessary path segments | 344 | async fn f(&self) { | error: unnecessary qualification --> tests/test.rs:356:9 | 356 | async fn f(self); | ^^^^^ | help: remove the unnecessary path segments | 356 | async fn f(self); | error: unnecessary qualification --> tests/test.rs:358:9 | 358 | async fn g(mut self) | ^^^^^ | help: remove the unnecessary path segments | 358 | async fn g(mut self) | error: unnecessary qualification --> tests/test.rs:371:9 | 371 | async fn f(mut self) { | ^^^^^ | help: remove the unnecessary path segments | 371 | async fn f(mut self) { | error: unnecessary qualification --> tests/test.rs:434:9 | 434 | async fn f(x: Str<'a>) -> &'a str; | ^^^^^ | help: remove the unnecessary path segments | 434 | async fn f(x: Str<'a>) -> &'a str; | error: unnecessary qualification --> tests/test.rs:435:9 | 435 | async fn g(x: Str<'a>) -> &'a str { | ^^^^^ | help: remove the unnecessary path segments | 435 | async fn g(x: Str<'a>) -> &'a str { | error: unnecessary qualification --> tests/test.rs:435:43 | 435 | async fn g(x: Str<'a>) -> &'a str { | ___________________________________________^ 436 | | x.0 437 | | } | |_________^ | help: remove the unnecessary path segments | 435 | async fn g(x: Str<'a>) -> &'a str { | error: unnecessary qualification --> tests/test.rs:442:9 | 442 | async fn f(x: Str<'a>) -> &'a str { | ^^^^^ | help: remove the unnecessary path segments | 442 | async fn f(x: Str<'a>) -> &'a str { | error: unnecessary qualification --> tests/test.rs:442:43 | 442 | async fn f(x: Str<'a>) -> &'a str { | ___________________________________________^ 443 | | x.0 444 | | } | |_________^ | help: remove the unnecessary path segments | 442 | async fn f(x: Str<'a>) -> &'a str { | error: unnecessary qualification --> tests/test.rs:449:9 | 449 | async fn f(); | ^^^^^ | help: remove the unnecessary path segments | 449 | async fn f(); | error: unnecessary qualification --> tests/test.rs:454:9 | 454 | async fn f() {} | ^^^^^ | help: remove the unnecessary path segments | 454 | async fn f() {} | error: unnecessary qualification --> tests/test.rs:459:9 | 459 | async fn f(_: &'a &'b ()); // chain 'a and 'b | ^^^^^ | help: remove the unnecessary path segments | 459 | async fn f(_: &'a &'b ()); // chain 'a and 'b | error: unnecessary qualification --> tests/test.rs:460:9 | 460 | async fn g(_: &'b ()); // chain 'b only | ^^^^^ | help: remove the unnecessary path segments | 460 | async fn g(_: &'b ()); // chain 'b only | error: unnecessary qualification --> tests/test.rs:461:9 | 461 | async fn h(); // do not chain | ^^^^^ | help: remove the unnecessary path segments | 461 | async fn h(); // do not chain | error: unnecessary qualification --> tests/test.rs:475:9 | 475 | async fn hello(thing: Struct<'a>) -> String; | ^^^^^ | help: remove the unnecessary path segments | 475 | async fn hello(thing: Struct<'a>) -> String; | error: unnecessary qualification --> tests/test.rs:476:9 | 476 | async fn hello_twice(one: Struct<'a>, two: Struct<'a>) -> String { | ^^^^^ | help: remove the unnecessary path segments | 476 | async fn hello_twice(one: Struct<'a>, two: Struct<'a>) -> String { | error: unnecessary qualification --> tests/test.rs:476:74 | 476 | async fn hello_twice(one: Struct<'a>, two: Struct<'a>) -> String { | __________________________________________________________________________^ 477 | | let str1 = Self::hello(one).await; 478 | | let str2 = Self::hello(two).await; 479 | | str1 + &str2 480 | | } | |_________^ | help: remove the unnecessary path segments | 476 | async fn hello_twice(one: Struct<'a>, two: Struct<'a>) -> String { | error: unnecessary qualification --> tests/test.rs:490:9 | 490 | async fn from_parts() -> Self; | ^^^^^ | help: remove the unnecessary path segments | 490 | async fn from_parts() -> Self; | error: unnecessary qualification --> tests/test.rs:497:9 | 497 | async fn from_parts() -> TokenContext { | ^^^^^ | help: remove the unnecessary path segments | 497 | async fn from_parts() -> TokenContext { | error: unnecessary qualification --> tests/test.rs:497:47 | 497 | async fn from_parts() -> TokenContext { | _______________________________________________^ 498 | | TokenContext 499 | | } | |_________^ | help: remove the unnecessary path segments | 497 | async fn from_parts() -> TokenContext { | error: unnecessary qualification --> tests/test.rs:513:9 | 513 | async fn get_one() -> u8 { | ^^^^^ | help: remove the unnecessary path segments | 513 | async fn get_one() -> u8 { | error: unnecessary qualification --> tests/test.rs:513:34 | 513 | async fn get_one() -> u8 { | __________________________________^ 514 | | 1 515 | | } | |_________^ | help: remove the unnecessary path segments | 513 | async fn get_one() -> u8 { | error: unnecessary qualification --> tests/test.rs:538:9 | 538 | async fn foo(&mut self, v: usize); | ^^^^^ | help: remove the unnecessary path segments | 538 | async fn foo(&mut self, v: usize); | error: unnecessary qualification --> tests/test.rs:543:9 | 543 | async fn bar(&self); | ^^^^^ | help: remove the unnecessary path segments | 543 | async fn bar(&self); | error: unnecessary qualification --> tests/test.rs:552:9 | 552 | async fn foo(&mut self, v: usize) { | ^^^^^ | help: remove the unnecessary path segments | 552 | async fn foo(&mut self, v: usize) { | error: unnecessary qualification --> tests/test.rs:564:9 | 564 | async fn bar(&self) { | ^^^^^ | help: remove the unnecessary path segments | 564 | async fn bar(&self) { | error: unnecessary qualification --> tests/test.rs:703:9 | 703 | async fn method(); | ^^^^^ | help: remove the unnecessary path segments | 703 | async fn method(); | error: unnecessary qualification --> tests/test.rs:708:9 | 708 | async fn method() { | ^^^^^ | help: remove the unnecessary path segments | 708 | async fn method() { | error: unnecessary qualification --> tests/test.rs:715:9 | 715 | async fn method() { | ^^^^^ | help: remove the unnecessary path segments | 715 | async fn method() { | error: unnecessary qualification --> tests/test.rs:722:9 | 722 | async fn method() { | ^^^^^ | help: remove the unnecessary path segments | 722 | async fn method() { | error: unnecessary qualification --> tests/test.rs:729:9 | 729 | async fn method() { | ^^^^^ | help: remove the unnecessary path segments | 729 | async fn method() { | error: unnecessary qualification --> tests/test.rs:742:9 | 742 | async fn const_generic(_: [T; C]) {} | ^^^^^ | help: remove the unnecessary path segments | 742 | async fn const_generic(_: [T; C]) {} | error: unnecessary qualification --> tests/test.rs:749:9 | 749 | async fn const_generic(_: [T; C]) {} | ^^^^^ | help: remove the unnecessary path segments | 749 | async fn const_generic(_: [T; C]) {} | error: unnecessary qualification --> tests/test.rs:763:9 | 763 | async fn method(&self) { | ^^^^^ | help: remove the unnecessary path segments | 763 | async fn method(&self) { | error: unnecessary qualification --> tests/test.rs:782:9 | 782 | async fn associated(&self) { | ^^^^^ | help: remove the unnecessary path segments | 782 | async fn associated(&self) { | error: unnecessary qualification --> tests/test.rs:794:9 | 794 | async fn handle(&self); | ^^^^^ | help: remove the unnecessary path segments | 794 | async fn handle(&self); | error: unnecessary qualification --> tests/test.rs:803:9 | 803 | async fn handle(&self) { | ^^^^^ | help: remove the unnecessary path segments | 803 | async fn handle(&self) { | error: unnecessary qualification --> tests/test.rs:818:9 | 818 | async fn f(&self) {} | ^^^^^ | help: remove the unnecessary path segments | 818 | async fn f(&self) {} | error: unnecessary qualification --> tests/test.rs:819:9 | 819 | async fn g(self: &Self) {} | ^^^^^ | help: remove the unnecessary path segments | 819 | async fn g(self: &Self) {} | error: unnecessary qualification --> tests/test.rs:832:9 | 832 | async fn camelCase(); | ^^^^^ | help: remove the unnecessary path segments | 832 | async fn camelCase(); | error: unnecessary qualification --> tests/test.rs:839:9 | 839 | async fn camelCase() {} | ^^^^^ | help: remove the unnecessary path segments | 839 | async fn camelCase() {} | error: unnecessary qualification --> tests/test.rs:849:9 | 849 | async fn f(&self); | ^^^^^ | help: remove the unnecessary path segments | 849 | async fn f(&self); | error: unnecessary qualification --> tests/test.rs:862:9 | 862 | async fn f(&self) { | ^^^^^ | help: remove the unnecessary path segments | 862 | async fn f(&self) { | error: unnecessary qualification --> tests/test.rs:872:9 | 872 | async fn f(&self) { | ^^^^^ | help: remove the unnecessary path segments | 872 | async fn f(&self) { | error: unnecessary qualification --> tests/test.rs:888:9 | 888 | async fn f(&self); | ^^^^^ | help: remove the unnecessary path segments | 888 | async fn f(&self); | error: unnecessary qualification --> tests/test.rs:893:9 | 893 | async fn f(&self) {} | ^^^^^ | help: remove the unnecessary path segments | 893 | async fn f(&self) {} | error: unnecessary qualification --> tests/test.rs:898:9 | 898 | async fn f(&self) {} | ^^^^^ | help: remove the unnecessary path segments | 898 | async fn f(&self) {} | error: unnecessary qualification --> tests/test.rs:903:9 | 903 | async fn f(&self) {} | ^^^^^ | help: remove the unnecessary path segments | 903 | async fn f(&self) {} | error: unnecessary qualification --> tests/test.rs:935:9 | 935 | async fn associated2(&self) { | ^^^^^ | help: remove the unnecessary path segments | 935 | async fn associated2(&self) { | error: unnecessary qualification --> tests/test.rs:958:9 | 958 | async fn associated2(&self) { | ^^^^^ | help: remove the unnecessary path segments | 958 | async fn associated2(&self) { | error: unnecessary qualification --> tests/test.rs:983:9 | 983 | async fn associated2(&self) { | ^^^^^ | help: remove the unnecessary path segments | 983 | async fn associated2(&self) { | error: unnecessary qualification --> tests/test.rs:1005:9 | 1005 | async fn func2() { | ^^^^^ | help: remove the unnecessary path segments | 1005 | async fn func2() { | error: unnecessary qualification --> tests/test.rs:1024:9 | 1024 | async fn id(&self) -> i32; | ^^^^^ | help: remove the unnecessary path segments | 1024 | async fn id(&self) -> i32; | error: unnecessary qualification --> tests/test.rs:1052:9 | 1052 | async fn spawn(&self, work: F) -> T | ^^^^^ | help: remove the unnecessary path segments | 1052 | async fn spawn(&self, work: F) -> T | error: unnecessary qualification --> tests/test.rs:1065:9 | 1065 | async fn spawn(&self, work: F) -> T | ^^^^^ | help: remove the unnecessary path segments | 1065 | async fn spawn(&self, work: F) -> T | error: unnecessary qualification --> tests/test.rs:1069:9 | 1069 | / { 1070 | | (**self).spawn(work).await 1071 | | } | |_________^ | help: remove the unnecessary path segments | 1069 | { | error: unnecessary qualification --> tests/test.rs:1082:9 | 1082 | async fn load(&self, key: &str); | ^^^^^ | help: remove the unnecessary path segments | 1082 | async fn load(&self, key: &str); | error: unnecessary qualification --> tests/test.rs:1091:9 | 1091 | async fn load(&self, _key: &str) {} | ^^^^^ | help: remove the unnecessary path segments | 1091 | async fn load(&self, _key: &str) {} | error: unnecessary qualification --> tests/test.rs:1103:9 | 1103 | async fn f(&self); | ^^^^^ | help: remove the unnecessary path segments | 1103 | async fn f(&self); | error: unnecessary qualification --> tests/test.rs:1108:9 | 1108 | async fn f(&self) {} | ^^^^^ | help: remove the unnecessary path segments | 1108 | async fn f(&self) {} | error: unnecessary qualification --> tests/test.rs:1118:9 | 1118 | async fn f(&self) -> &str | ^^^^^ | help: remove the unnecessary path segments | 1118 | async fn f(&self) -> &str | error: unnecessary qualification --> tests/test.rs:1121:9 | 1121 | / { 1122 | | "default" 1123 | | } | |_________^ | help: remove the unnecessary path segments | 1121 | { | error: unnecessary qualification --> tests/test.rs:1136:9 | 1136 | async fn a(_b: u8, c: u8) -> u8 { | ^^^^^ | help: remove the unnecessary path segments | 1136 | async fn a(_b: u8, c: u8) -> u8 { | error: unnecessary qualification --> tests/test.rs:1136:41 | 1136 | async fn a(_b: u8, c: u8) -> u8 { | _________________________________________^ 1137 | | c 1138 | | } | |_________^ | help: remove the unnecessary path segments | 1136 | async fn a(_b: u8, c: u8) -> u8 { | error: unnecessary qualification --> tests/test.rs:1145:9 | 1145 | async fn a(_b: u8, c: u8) -> u8 { | ^^^^^ | help: remove the unnecessary path segments | 1145 | async fn a(_b: u8, c: u8) -> u8 { | error: unnecessary qualification --> tests/test.rs:1145:41 | 1145 | async fn a(_b: u8, c: u8) -> u8 { | _________________________________________^ 1146 | | c 1147 | | } | |_________^ | help: remove the unnecessary path segments | 1145 | async fn a(_b: u8, c: u8) -> u8 { | error: unnecessary qualification --> tests/test.rs:1157:9 | 1157 | async fn run(self) | ^^^^^ | help: remove the unnecessary path segments | 1157 | async fn run(self) | error: unnecessary qualification --> tests/test.rs:1168:9 | 1168 | async fn run(self) | ^^^^^ | help: remove the unnecessary path segments | 1168 | async fn run(self) | error: unnecessary qualification --> tests/test.rs:1192:9 | 1192 | async fn async_trait(_: Flagger<'_>, flag: &AtomicBool); | ^^^^^ | help: remove the unnecessary path segments | 1192 | async fn async_trait(_: Flagger<'_>, flag: &AtomicBool); | error: unnecessary qualification --> tests/test.rs:1199:9 | 1199 | async fn async_trait(_: Flagger<'_>, flag: &AtomicBool) { | ^^^^^ | help: remove the unnecessary path segments | 1199 | async fn async_trait(_: Flagger<'_>, flag: &AtomicBool) { | error: unnecessary qualification --> tests/test.rs:1210:9 | 1210 | async fn async_trait(self, flag: &AtomicBool); | ^^^^^ | help: remove the unnecessary path segments | 1210 | async fn async_trait(self, flag: &AtomicBool); | error: unnecessary qualification --> tests/test.rs:1215:9 | 1215 | async fn async_trait(self, flag: &AtomicBool) { | ^^^^^ | help: remove the unnecessary path segments | 1215 | async fn async_trait(self, flag: &AtomicBool) { | error: unnecessary qualification --> tests/test.rs:1248:9 | 1248 | async fn connect(&self) -> Result; | ^^^^^ | help: remove the unnecessary path segments | 1248 | async fn connect(&self) -> Result; | error: unnecessary qualification --> tests/test.rs:1262:9 | 1262 | async fn x(); | ^^^^^ | help: remove the unnecessary path segments | 1262 | async fn x(); | error: unnecessary qualification --> tests/test.rs:1263:9 | 1263 | async fn y() -> (); | ^^^^^ | help: remove the unnecessary path segments | 1263 | async fn y() -> (); | error: unnecessary qualification --> tests/test.rs:1264:9 | 1264 | async fn z(); | ^^^^^ | help: remove the unnecessary path segments | 1264 | async fn z(); | error: unnecessary qualification --> tests/test.rs:1269:9 | 1269 | async fn x() {} | ^^^^^ | help: remove the unnecessary path segments | 1269 | async fn x() {} | error: unnecessary qualification --> tests/test.rs:1270:9 | 1270 | async fn y() -> () {} | ^^^^^ | help: remove the unnecessary path segments | 1270 | async fn y() -> () {} | error: unnecessary qualification --> tests/test.rs:1270:28 | 1270 | async fn y() -> () {} | ^^ | help: remove the unnecessary path segments | 1270 | async fn y() -> () {} | error: unnecessary qualification --> tests/test.rs:1271:9 | 1271 | async fn z() { | ^^^^^ | help: remove the unnecessary path segments | 1271 | async fn z() { | error: unnecessary qualification --> tests/test.rs:1291:9 | 1291 | async fn fail() -> &'static dyn Ret { | ^^^^^ | help: remove the unnecessary path segments | 1291 | async fn fail() -> &'static dyn Ret { | error: unnecessary qualification --> tests/test.rs:1291:45 | 1291 | async fn fail() -> &'static dyn Ret { | _____________________________________________^ 1292 | | return &Thing; 1293 | | } | |_________^ | help: remove the unnecessary path segments | 1291 | async fn fail() -> &'static dyn Ret { | error: unnecessary qualification --> tests/test.rs:1327:9 | 1327 | async fn f(&self); | ^^^^^ | help: remove the unnecessary path segments | 1327 | async fn f(&self); | error: unnecessary qualification --> tests/test.rs:1334:9 | 1334 | async fn f(&self) { | ^^^^^ | help: remove the unnecessary path segments | 1334 | async fn f(&self) { | error: unnecessary qualification --> tests/test.rs:1349:9 | 1349 | async fn f(&self) { | ^^^^^ | help: remove the unnecessary path segments | 1349 | async fn f(&self) { | error: unnecessary qualification --> tests/test.rs:1350:13 | 1350 | self::f(); | ^^^^^^^ | help: remove the unnecessary path segments | 1350 - self::f(); 1350 + f(); | error: unnecessary qualification --> tests/test.rs:1364:9 | 1364 | async fn f(self: Arc); | ^^^^^ | help: remove the unnecessary path segments | 1364 | async fn f(self: Arc); | error: unnecessary qualification --> tests/test.rs:1371:9 | 1371 | async fn f(self: Arc) { | ^^^^^ | help: remove the unnecessary path segments | 1371 | async fn f(self: Arc) { | error: unnecessary qualification --> tests/test.rs:1388:9 | 1388 | async fn f(&self) {} | ^^^^^ | help: remove the unnecessary path segments | 1388 | async fn f(&self) {} | error: unnecessary qualification --> tests/test.rs:1400:9 | 1400 | async fn foo(&self, _callback: impl FnMut(&str) + Send) {} | ^^^^^ | help: remove the unnecessary path segments | 1400 | async fn foo(&self, _callback: impl FnMut(&str) + Send) {} | error: unnecessary qualification --> tests/test.rs:1407:9 | 1407 | async fn foo(&self, _callback: impl FnMut(&str) + Send) {} | ^^^^^ | help: remove the unnecessary path segments | 1407 | async fn foo(&self, _callback: impl FnMut(&str) + Send) {} | error: unnecessary qualification --> tests/test.rs:1419:9 | 1419 | async fn foo(_n: i32) {} | ^^^^^ | help: remove the unnecessary path segments | 1419 | async fn foo(_n: i32) {} | error: unnecessary qualification --> tests/test.rs:1438:9 | 1438 | async fn f(counter: &Cell, arg: IncrementOnDrop<'_>); | ^^^^^ | help: remove the unnecessary path segments | 1438 | async fn f(counter: &Cell, arg: IncrementOnDrop<'_>); | error: unnecessary qualification --> tests/test.rs:1445:9 | 1445 | async fn f(counter: &Cell, _: IncrementOnDrop<'_>) { | ^^^^^ | help: remove the unnecessary path segments | 1445 | async fn f(counter: &Cell, _: IncrementOnDrop<'_>) { | error: unnecessary qualification --> tests/test.rs:1466:9 | 1466 | async fn f(arg: &impl Trait); | ^^^^^ | help: remove the unnecessary path segments | 1466 | async fn f(arg: &impl Trait); | error: unnecessary qualification --> tests/test.rs:1467:9 | 1467 | async fn g(arg: *const impl Trait); | ^^^^^ | help: remove the unnecessary path segments | 1467 | async fn g(arg: *const impl Trait); | error: unnecessary qualification --> tests/test.rs:1478:9 | 1478 | async fn f(self: Arc) {} | ^^^^^ | help: remove the unnecessary path segments | 1478 | async fn f(self: Arc) {} | error: unnecessary qualification --> tests/test.rs:1488:9 | 1488 | async fn cfg_param(&self, param: u8); | ^^^^^ | help: remove the unnecessary path segments | 1488 | async fn cfg_param(&self, param: u8); | error: unnecessary qualification --> tests/test.rs:1489:9 | 1489 | async fn cfg_param_wildcard(&self, _: u8); | ^^^^^ | help: remove the unnecessary path segments | 1489 | async fn cfg_param_wildcard(&self, _: u8); | error: unnecessary qualification --> tests/test.rs:1490:9 | 1490 | async fn cfg_param_tuple(&self, (left, right): (u8, u8)); | ^^^^^ | help: remove the unnecessary path segments | 1490 | async fn cfg_param_tuple(&self, (left, right): (u8, u8)); | error: unnecessary qualification --> tests/test.rs:1498:9 | 1498 | async fn cfg_param(&self, #[cfg(any())] param: u8, #[cfg(all())] _unused: u8) {} | ^^^^^ | help: remove the unnecessary path segments | 1498 | async fn cfg_param(&self, #[cfg(any())] param: u8, #[cfg(all())] _unused: u8) {} | error: unnecessary qualification --> tests/test.rs:1500:9 | 1500 | async fn cfg_param_wildcard(&self, #[cfg(any())] _: u8, #[cfg(all())] _: u8) {} | ^^^^^ | help: remove the unnecessary path segments | 1500 | async fn cfg_param_wildcard(&self, #[cfg(any())] _: u8, #[cfg(all())] _: u8) {} | error: unnecessary qualification --> tests/test.rs:1502:9 | 1502 | async fn cfg_param_tuple( | ^^^^^ | help: remove the unnecessary path segments | 1502 | async fn cfg_param_tuple( | error: unnecessary qualification --> tests/test.rs:1517:9 | 1517 | async fn take_ref(&self, thing: &T); | ^^^^^ | help: remove the unnecessary path segments | 1517 | async fn take_ref(&self, thing: &T); | error: unnecessary qualification --> tests/test.rs:1524:9 | 1524 | async fn take_ref(&self, _: &T) {} | ^^^^^ | help: remove the unnecessary path segments | 1524 | async fn take_ref(&self, _: &T) {} | error: unnecessary qualification --> tests/test.rs:1531:9 | 1531 | async fn take_ref(&self, (a, b): &(T, T)) { | ^^^^^ | help: remove the unnecessary path segments | 1531 | async fn take_ref(&self, (a, b): &(T, T)) { | error: unnecessary qualification --> tests/test.rs:1541:9 | 1541 | async fn take_ref(&self, (_a, _b, _c): &(T, T, T)) {} | ^^^^^ | help: remove the unnecessary path segments | 1541 | async fn take_ref(&self, (_a, _b, _c): &(T, T, T)) {} | error: unnecessary qualification --> tests/test.rs:1559:9 | 1559 | async fn f(arg: Tuple); | ^^^^^ | help: remove the unnecessary path segments | 1559 | async fn f(arg: Tuple); | error: unnecessary qualification --> tests/test.rs:1566:9 | 1566 | async fn f(Tuple(_, _int): Tuple) {} | ^^^^^ | help: remove the unnecessary path segments | 1566 | async fn f(Tuple(_, _int): Tuple) {} | error: unnecessary qualification --> tests/test.rs:1573:9 | 1573 | async fn f(Tuple { 1: _int, .. }: Tuple) {} | ^^^^^ | help: remove the unnecessary path segments | 1573 | async fn f(Tuple { 1: _int, .. }: Tuple) {} | error: unnecessary qualification --> tests/test.rs:1599:9 | 1599 | async fn f() -> Ready<()> { | ^^^^^ | help: remove the unnecessary path segments | 1599 | async fn f() -> Ready<()> { | error: unnecessary qualification --> tests/test.rs:1599:35 | 1599 | async fn f() -> Ready<()> { | ___________________________________^ 1600 | | future::ready(()) 1601 | | } | |_________^ | help: remove the unnecessary path segments | 1599 | async fn f() -> Ready<()> { | error: unnecessary qualification --> tests/test.rs:1613:9 | 1613 | async fn f(); | ^^^^^ | help: remove the unnecessary path segments | 1613 | async fn f(); | error: unnecessary qualification --> tests/test.rs:1620:9 | 1620 | async fn f() {} | ^^^^^ | help: remove the unnecessary path segments | 1620 | async fn f() {} | --- tests/test.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test.rs b/tests/test.rs index cbd8e03..f2d8b54 100644 --- a/tests/test.rs +++ b/tests/test.rs @@ -2,7 +2,7 @@ async_trait_nightly_testing, feature(impl_trait_in_assoc_type, min_specialization) )] -#![deny(rust_2021_compatibility)] +#![deny(rust_2021_compatibility, unused_qualifications)] #![allow( clippy::incompatible_msrv, // https://github.com/rust-lang/rust-clippy/issues/12257 clippy::let_underscore_untyped, From 4cf4ff679f8ec3de6840e8870800c34d124d78f0 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Sat, 16 Mar 2024 16:04:14 -0700 Subject: [PATCH 10/25] Ignore unused_qualifications rustc lint in generated code --- src/expand.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/expand.rs b/src/expand.rs index 2a8b3c2..cbef6f2 100644 --- a/src/expand.rs +++ b/src/expand.rs @@ -125,6 +125,7 @@ pub fn expand(input: &mut Item, is_local: bool) { fn lint_suppress_with_body() -> Attribute { parse_quote! { #[allow( + unused_qualifications, clippy::async_yields_async, clippy::diverging_sub_expression, clippy::let_unit_value, @@ -140,6 +141,7 @@ fn lint_suppress_with_body() -> Attribute { fn lint_suppress_without_body() -> Attribute { parse_quote! { #[allow( + unused_qualifications, clippy::type_complexity, clippy::type_repetition_in_bounds )] From 75879e856897b6249be445b6b0235426976e2c04 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Sat, 16 Mar 2024 16:06:00 -0700 Subject: [PATCH 11/25] Ignore intentional unused_qualifications in a regression test --- tests/test.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test.rs b/tests/test.rs index f2d8b54..4b01bad 100644 --- a/tests/test.rs +++ b/tests/test.rs @@ -1384,6 +1384,7 @@ pub mod issue169 { use async_trait::async_trait; #[async_trait] + #[allow(unused_qualifications)] pub trait Trait: ::core::marker::Sync { async fn f(&self) {} } From 1a01bb450ea356cb7730b8f9aa4988705115028b Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Sat, 16 Mar 2024 16:40:36 -0700 Subject: [PATCH 12/25] Skip needlessly generating inferred bounds during ?Send --- src/expand.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/expand.rs b/src/expand.rs index cbef6f2..867ae59 100644 --- a/src/expand.rs +++ b/src/expand.rs @@ -239,7 +239,9 @@ fn transform_sig( .push(parse_quote_spanned!(default_span=> 'async_trait)); if has_self { - let bounds: &[InferredBound] = if let Some(receiver) = sig.receiver() { + let bounds: &[InferredBound] = if is_local { + &[] + } else if let Some(receiver) = sig.receiver() { match receiver.ty.as_ref() { // self: &Self Type::Reference(ty) if ty.mutability.is_none() => &[InferredBound::Sync], @@ -275,7 +277,7 @@ fn transform_sig( Context::Trait { supertraits, .. } => !has_default || has_bound(supertraits, bound), Context::Impl { .. } => true, }; - if assume_bound || is_local { + if assume_bound { None } else { Some(bound.spanned_path(default_span)) From c98a408176cae0294c5f5ba2a9e4c7375aa9cfcb Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Sat, 16 Mar 2024 16:31:26 -0700 Subject: [PATCH 13/25] Minimize use of async token's span in expanded code --- src/bound.rs | 10 ++++++---- src/expand.rs | 29 ++++++++++------------------- tests/test.rs | 1 + 3 files changed, 17 insertions(+), 23 deletions(-) diff --git a/src/bound.rs b/src/bound.rs index 50182f6..1210517 100644 --- a/src/bound.rs +++ b/src/bound.rs @@ -1,5 +1,5 @@ use proc_macro2::{Ident, Span, TokenStream}; -use quote::quote_spanned; +use quote::{quote, ToTokens}; use syn::punctuated::Punctuated; use syn::{Token, TypeParamBound}; @@ -34,10 +34,12 @@ impl InferredBound { InferredBound::Sync => "Sync", } } +} - pub fn spanned_path(&self, span: Span) -> TokenStream { - let ident = Ident::new(self.as_str(), span); - quote_spanned!(span=> ::core::marker::#ident) +impl ToTokens for InferredBound { + fn to_tokens(&self, tokens: &mut TokenStream) { + let ident = Ident::new(self.as_str(), Span::call_site()); + quote!(::core::marker::#ident).to_tokens(tokens); } } diff --git a/src/expand.rs b/src/expand.rs index 867ae59..bb37597 100644 --- a/src/expand.rs +++ b/src/expand.rs @@ -125,7 +125,6 @@ pub fn expand(input: &mut Item, is_local: bool) { fn lint_suppress_with_body() -> Attribute { parse_quote! { #[allow( - unused_qualifications, clippy::async_yields_async, clippy::diverging_sub_expression, clippy::let_unit_value, @@ -141,7 +140,6 @@ fn lint_suppress_with_body() -> Attribute { fn lint_suppress_without_body() -> Attribute { parse_quote! { #[allow( - unused_qualifications, clippy::type_complexity, clippy::type_repetition_in_bounds )] @@ -168,11 +166,10 @@ fn transform_sig( has_default: bool, is_local: bool, ) { - let default_span = sig.asyncness.take().unwrap().span; - sig.fn_token.span = default_span; + sig.fn_token.span = sig.asyncness.take().unwrap().span; let (ret_arrow, ret) = match &sig.output { - ReturnType::Default => (Token![->](default_span), quote_spanned!(default_span=> ())), + ReturnType::Default => (Token![->](Span::call_site()), quote!(())), ReturnType::Type(arrow, ret) => (*arrow, quote!(#ret)), }; @@ -234,9 +231,7 @@ fn transform_sig( .push(parse_quote_spanned!(elided.span()=> #elided: 'async_trait)); } - sig.generics - .params - .push(parse_quote_spanned!(default_span=> 'async_trait)); + sig.generics.params.push(parse_quote!('async_trait)); if has_self { let bounds: &[InferredBound] = if is_local { @@ -272,21 +267,17 @@ fn transform_sig( &[InferredBound::Send] }; - let bounds = bounds.iter().filter_map(|bound| { + let bounds = bounds.iter().filter(|bound| { let assume_bound = match context { Context::Trait { supertraits, .. } => !has_default || has_bound(supertraits, bound), Context::Impl { .. } => true, }; - if assume_bound { - None - } else { - Some(bound.spanned_path(default_span)) - } + !assume_bound }); where_clause_or_default(&mut sig.generics.where_clause) .predicates - .push(parse_quote_spanned! {default_span=> + .push(parse_quote! { Self: #(#bounds +)* 'async_trait }); } @@ -318,11 +309,11 @@ fn transform_sig( } let bounds = if is_local { - quote_spanned!(default_span=> 'async_trait) + quote!('async_trait) } else { - quote_spanned!(default_span=> ::core::marker::Send + 'async_trait) + quote!(::core::marker::Send + 'async_trait) }; - sig.output = parse_quote_spanned! {default_span=> + sig.output = parse_quote! { #ret_arrow ::core::pin::Pin + #bounds >> @@ -420,7 +411,7 @@ fn transform_block(context: Context, sig: &mut Signature, block: &mut Block) { quote!(#(#decls)* { #(#stmts)* }) } } else { - quote_spanned! {block.brace_token.span=> + quote! { if let ::core::option::Option::Some(__ret) = ::core::option::Option::None::<#ret> { return __ret; } diff --git a/tests/test.rs b/tests/test.rs index 4b01bad..0d5aacd 100644 --- a/tests/test.rs +++ b/tests/test.rs @@ -1345,6 +1345,7 @@ pub mod issue158 { fn f() {} #[async_trait] + #[allow(unused_qualifications)] pub trait Trait { async fn f(&self) { self::f(); From b6314bc6bda7303f0fee2648af4de18f8984ef53 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Sat, 16 Mar 2024 16:50:20 -0700 Subject: [PATCH 14/25] Refactor inferred bound filtering --- src/expand.rs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/expand.rs b/src/expand.rs index bb37597..237d92f 100644 --- a/src/expand.rs +++ b/src/expand.rs @@ -267,12 +267,9 @@ fn transform_sig( &[InferredBound::Send] }; - let bounds = bounds.iter().filter(|bound| { - let assume_bound = match context { - Context::Trait { supertraits, .. } => !has_default || has_bound(supertraits, bound), - Context::Impl { .. } => true, - }; - !assume_bound + let bounds = bounds.iter().filter(|bound| match context { + Context::Trait { supertraits, .. } => has_default && !has_bound(supertraits, bound), + Context::Impl { .. } => false, }); where_clause_or_default(&mut sig.generics.where_clause) From c73061d1b2264c37b09e1a84242c4471d8a54e32 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Sat, 16 Mar 2024 16:56:00 -0700 Subject: [PATCH 15/25] Release 0.1.78 --- Cargo.toml | 2 +- src/lib.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index a1a0339..17748c3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "async-trait" -version = "0.1.77" +version = "0.1.78" authors = ["David Tolnay "] categories = ["asynchronous", "no-std"] description = "Type erasure for async trait methods" diff --git a/src/lib.rs b/src/lib.rs index 7a48574..f537626 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -316,7 +316,7 @@ //! let object = &value as &dyn ObjectSafe; //! ``` -#![doc(html_root_url = "https://docs.rs/async-trait/0.1.77")] +#![doc(html_root_url = "https://docs.rs/async-trait/0.1.78")] #![allow( clippy::default_trait_access, clippy::doc_markdown, From cd8286bfacec2e3d4b6d0f72ae6af2098fb91f93 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Thu, 21 Mar 2024 20:45:27 -0700 Subject: [PATCH 16/25] Update ui test suite to nightly-2024-03-22 --- tests/ui/lifetime-span.stderr | 9 --------- 1 file changed, 9 deletions(-) diff --git a/tests/ui/lifetime-span.stderr b/tests/ui/lifetime-span.stderr index 021c9fc..aa7d57e 100644 --- a/tests/ui/lifetime-span.stderr +++ b/tests/ui/lifetime-span.stderr @@ -9,15 +9,6 @@ help: indicate the anonymous lifetime 12 | impl Trait<'_> for A { | ++++ -error[E0195]: lifetime parameters or bounds on method `method` do not match the trait declaration - --> tests/ui/lifetime-span.rs:13:14 - | -8 | async fn method(&'r self); - | ---------------- lifetimes in impl do not match this method in trait -... -13 | async fn method(&self) {} - | ^^^^^^^^^^^^^ lifetimes do not match method in trait - error[E0195]: lifetime parameters or bounds on method `method` do not match the trait declaration --> tests/ui/lifetime-span.rs:18:14 | From 82cb95c484f1777371417a9827a1e7df5f399ce0 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Sat, 23 Mar 2024 19:39:11 -0700 Subject: [PATCH 17/25] Resolve unused field of ReplaceSelf syntax tree visitor warning: field `0` is never read --> src/receiver.rs:81:24 | 81 | pub struct ReplaceSelf(pub Span); | ----------- ^^^^^^^^ | | | field in this struct | = note: `#[warn(dead_code)]` on by default help: consider changing the field to be of unit type to suppress this warning while preserving the field numbering, or remove the field | 81 | pub struct ReplaceSelf(()); | ~~ --- src/expand.rs | 9 ++++----- src/receiver.rs | 4 ++-- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/expand.rs b/src/expand.rs index 237d92f..9b9cf09 100644 --- a/src/expand.rs +++ b/src/expand.rs @@ -335,7 +335,7 @@ fn transform_sig( // ___ret // }) fn transform_block(context: Context, sig: &mut Signature, block: &mut Block) { - let mut self_span = None; + let mut replace_self = false; let decls = sig .inputs .iter() @@ -346,8 +346,8 @@ fn transform_block(context: Context, sig: &mut Signature, block: &mut Block) { mutability, .. }) => { + replace_self = true; let ident = Ident::new("__self", self_token.span); - self_span = Some(self_token.span); quote!(let #mutability #ident = #self_token;) } FnArg::Typed(arg) => { @@ -389,9 +389,8 @@ fn transform_block(context: Context, sig: &mut Signature, block: &mut Block) { }) .collect::>(); - if let Some(span) = self_span { - let mut replace_self = ReplaceSelf(span); - replace_self.visit_block_mut(block); + if replace_self { + ReplaceSelf.visit_block_mut(block); } let stmts = &block.stmts; diff --git a/src/receiver.rs b/src/receiver.rs index f5791bf..e032dc1 100644 --- a/src/receiver.rs +++ b/src/receiver.rs @@ -1,4 +1,4 @@ -use proc_macro2::{Group, Span, TokenStream, TokenTree}; +use proc_macro2::{Group, TokenStream, TokenTree}; use syn::visit_mut::{self, VisitMut}; use syn::{ Block, ExprPath, Ident, Item, Macro, Pat, PatIdent, Path, Receiver, Signature, Token, TypePath, @@ -78,7 +78,7 @@ impl VisitMut for HasSelf { } } -pub struct ReplaceSelf(pub Span); +pub struct ReplaceSelf; impl ReplaceSelf { #[cfg_attr(not(self_span_hack), allow(clippy::unused_self))] From 1eb21ed8bd87029bf4dcbea41ff309f2b2220c43 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Sat, 23 Mar 2024 20:06:08 -0700 Subject: [PATCH 18/25] Release 0.1.79 --- Cargo.toml | 2 +- src/lib.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 17748c3..0543f14 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "async-trait" -version = "0.1.78" +version = "0.1.79" authors = ["David Tolnay "] categories = ["asynchronous", "no-std"] description = "Type erasure for async trait methods" diff --git a/src/lib.rs b/src/lib.rs index f537626..1b3a545 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -316,7 +316,7 @@ //! let object = &value as &dyn ObjectSafe; //! ``` -#![doc(html_root_url = "https://docs.rs/async-trait/0.1.78")] +#![doc(html_root_url = "https://docs.rs/async-trait/0.1.79")] #![allow( clippy::default_trait_access, clippy::doc_markdown, From 4f0b72eb8455834b1b52bdadb411aaf40bdf1b81 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Mon, 25 Mar 2024 22:24:49 -0700 Subject: [PATCH 19/25] Explicitly install a Rust toolchain for cargo-outdated job Debugging a recent cargo-outdated bug, it would have been nice not to wonder whether a rustc version change in GitHub's runner image was a contributing factor. --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index eef1ba6..8fc6f6c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -96,5 +96,6 @@ jobs: timeout-minutes: 45 steps: - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable - uses: dtolnay/install@cargo-outdated - run: cargo outdated --workspace --exit-code 1 From c8d958dfde2c36a5c483c9255729d30361cbd0bf Mon Sep 17 00:00:00 2001 From: Maarten de Vries Date: Thu, 11 Apr 2024 13:40:17 +0200 Subject: [PATCH 20/25] Fix unreachable code warning for functions that return `!` The generated code for function bodies produces an `unreachable_code` warning if the function has a `!` return type. The offending bit is: ```rust if let Some(__ret) == None:: { // unreachable } ``` This PR fixes the warning by simply adding `#[allow(unreachable_code)]` to the return statement. It also adds a test for it. This problem can only be triggered on nightly with the `never_type` feature enabled, but it is easy to fix here. --- src/expand.rs | 1 + tests/test.rs | 21 ++++++++++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/expand.rs b/src/expand.rs index 9b9cf09..8179ee7 100644 --- a/src/expand.rs +++ b/src/expand.rs @@ -409,6 +409,7 @@ fn transform_block(context: Context, sig: &mut Signature, block: &mut Block) { } else { quote! { if let ::core::option::Option::Some(__ret) = ::core::option::Option::None::<#ret> { + #[allow(unreachable_code)] return __ret; } #(#decls)* diff --git a/tests/test.rs b/tests/test.rs index 0d5aacd..e868941 100644 --- a/tests/test.rs +++ b/tests/test.rs @@ -1,6 +1,6 @@ #![cfg_attr( async_trait_nightly_testing, - feature(impl_trait_in_assoc_type, min_specialization) + feature(impl_trait_in_assoc_type, min_specialization, never_type) )] #![deny(rust_2021_compatibility, unused_qualifications)] #![allow( @@ -252,6 +252,25 @@ pub async fn test_unimplemented() { let _ = <() as Trait>::f; } +#[cfg(async_trait_nightly_testing)] +pub async fn test_divering_function() { + #[async_trait] + pub trait Trait { + async fn f() -> !; + } + + #[async_trait] + impl Trait for () { + async fn f() -> ! { + loop { + std::thread::sleep(std::time::Duration::from_millis(1)); + } + } + } + + let _ = <() as Trait>::f; +} + // https://github.com/dtolnay/async-trait/issues/1 pub mod issue1 { use async_trait::async_trait; From b64d041c6543f5ce48ff356cc5aaf712224b70e4 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Thu, 11 Apr 2024 11:45:03 -0700 Subject: [PATCH 21/25] Move never_type test under issue266 --- tests/test.rs | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/tests/test.rs b/tests/test.rs index e868941..a42b225 100644 --- a/tests/test.rs +++ b/tests/test.rs @@ -252,25 +252,6 @@ pub async fn test_unimplemented() { let _ = <() as Trait>::f; } -#[cfg(async_trait_nightly_testing)] -pub async fn test_divering_function() { - #[async_trait] - pub trait Trait { - async fn f() -> !; - } - - #[async_trait] - impl Trait for () { - async fn f() -> ! { - loop { - std::thread::sleep(std::time::Duration::from_millis(1)); - } - } - } - - let _ = <() as Trait>::f; -} - // https://github.com/dtolnay/async-trait/issues/1 pub mod issue1 { use async_trait::async_trait; @@ -1641,3 +1622,23 @@ pub mod issue238 { async fn f() {} } } + +// https://github.com/dtolnay/async-trait/issues/266 +#[cfg(async_trait_nightly_testing)] +pub mod issue266 { + use async_trait::async_trait; + + #[async_trait] + pub trait Trait { + async fn f() -> !; + } + + #[async_trait] + impl Trait for () { + async fn f() -> ! { + loop { + std::thread::sleep(std::time::Duration::from_millis(1)); + } + } + } +} From 22d017e9415fccf237372a3c5003c5cb44bcef6e Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Thu, 11 Apr 2024 11:48:36 -0700 Subject: [PATCH 22/25] Build script no longer looks at $DOCS_RS Since #254. --- build.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.rs b/build.rs index db7c5f0..d7f6b15 100644 --- a/build.rs +++ b/build.rs @@ -3,7 +3,7 @@ use std::process::Command; use std::str; fn main() { - println!("cargo:rerun-if-env-changed=DOCS_RS"); + println!("cargo:rerun-if-changed=build.rs"); let compiler = match rustc_minor_version() { Some(compiler) => compiler, From 83a542268d907f503793e64b5764c30b301a06d1 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Thu, 11 Apr 2024 11:50:36 -0700 Subject: [PATCH 23/25] Drop support for compilers older than 1.45 --- build.rs | 4 ---- src/expand.rs | 4 +--- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/build.rs b/build.rs index d7f6b15..04c6250 100644 --- a/build.rs +++ b/build.rs @@ -10,10 +10,6 @@ fn main() { None => return, }; - if compiler < 45 { - println!("cargo:rustc-cfg=no_span_mixed_site"); - } - if compiler < 47 { println!("cargo:rustc-cfg=self_span_hack"); } diff --git a/src/expand.rs b/src/expand.rs index 8179ee7..793e084 100644 --- a/src/expand.rs +++ b/src/expand.rs @@ -427,9 +427,7 @@ fn transform_block(context: Context, sig: &mut Signature, block: &mut Block) { } fn positional_arg(i: usize, pat: &Pat) -> Ident { - let span: Span = syn::spanned::Spanned::span(pat); - #[cfg(not(no_span_mixed_site))] - let span = span.resolved_at(Span::mixed_site()); + let span = syn::spanned::Spanned::span(pat).resolved_at(Span::mixed_site()); format_ident!("__arg{}", i, span = span) } From 10b5c9951af4cc787905ca26f95509e059931067 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Thu, 11 Apr 2024 11:51:32 -0700 Subject: [PATCH 24/25] Drop support for compilers older than 1.47 --- build.rs | 27 --------------------------- src/receiver.rs | 21 +++++++++------------ 2 files changed, 9 insertions(+), 39 deletions(-) delete mode 100644 build.rs diff --git a/build.rs b/build.rs deleted file mode 100644 index 04c6250..0000000 --- a/build.rs +++ /dev/null @@ -1,27 +0,0 @@ -use std::env; -use std::process::Command; -use std::str; - -fn main() { - println!("cargo:rerun-if-changed=build.rs"); - - let compiler = match rustc_minor_version() { - Some(compiler) => compiler, - None => return, - }; - - if compiler < 47 { - println!("cargo:rustc-cfg=self_span_hack"); - } -} - -fn rustc_minor_version() -> Option { - let rustc = env::var_os("RUSTC")?; - let output = Command::new(rustc).arg("--version").output().ok()?; - let version = str::from_utf8(&output.stdout).ok()?; - let mut pieces = version.split('.'); - if pieces.next() != Some("rustc 1") { - return None; - } - pieces.next()?.parse().ok() -} diff --git a/src/receiver.rs b/src/receiver.rs index e032dc1..e4627f1 100644 --- a/src/receiver.rs +++ b/src/receiver.rs @@ -80,18 +80,15 @@ impl VisitMut for HasSelf { pub struct ReplaceSelf; -impl ReplaceSelf { - #[cfg_attr(not(self_span_hack), allow(clippy::unused_self))] - fn prepend_underscore_to_self(&self, ident: &mut Ident) -> bool { - let modified = ident == "self"; - if modified { - *ident = Ident::new("__self", ident.span()); - #[cfg(self_span_hack)] - ident.set_span(self.0); - } - modified +fn prepend_underscore_to_self(ident: &mut Ident) -> bool { + let modified = ident == "self"; + if modified { + *ident = Ident::new("__self", ident.span()); } + modified +} +impl ReplaceSelf { fn visit_token_stream(&mut self, tokens: &mut TokenStream) -> bool { let mut out = Vec::new(); let mut modified = false; @@ -110,7 +107,7 @@ impl ReplaceSelf { for tt in tokens { match tt { TokenTree::Ident(mut ident) => { - *modified |= visitor.prepend_underscore_to_self(&mut ident); + *modified |= prepend_underscore_to_self(&mut ident); out.push(TokenTree::Ident(ident)); } TokenTree::Group(group) => { @@ -129,7 +126,7 @@ impl ReplaceSelf { impl VisitMut for ReplaceSelf { fn visit_ident_mut(&mut self, i: &mut Ident) { - self.prepend_underscore_to_self(i); + prepend_underscore_to_self(i); } fn visit_path_mut(&mut self, p: &mut Path) { From d528b5a816c891c3b5ab90dc4bcc5cc8d384e177 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Thu, 11 Apr 2024 11:55:15 -0700 Subject: [PATCH 25/25] Release 0.1.80 --- Cargo.toml | 2 +- src/lib.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 0543f14..6a34bdc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "async-trait" -version = "0.1.79" +version = "0.1.80" authors = ["David Tolnay "] categories = ["asynchronous", "no-std"] description = "Type erasure for async trait methods" diff --git a/src/lib.rs b/src/lib.rs index 1b3a545..cc8b628 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -316,7 +316,7 @@ //! let object = &value as &dyn ObjectSafe; //! ``` -#![doc(html_root_url = "https://docs.rs/async-trait/0.1.79")] +#![doc(html_root_url = "https://docs.rs/async-trait/0.1.80")] #![allow( clippy::default_trait_access, clippy::doc_markdown, pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy