diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
commit | 43a97878ce14b72f0981164f87f2e35e14151312 (patch) | |
tree | 620249daf56c0258faa40cbdcf9cfba06de2a846 /third_party/rust/async-trait/tests/ui | |
parent | Initial commit. (diff) | |
download | firefox-upstream.tar.xz firefox-upstream.zip |
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/rust/async-trait/tests/ui')
26 files changed, 508 insertions, 0 deletions
diff --git a/third_party/rust/async-trait/tests/ui/arg-implementation-detail.rs b/third_party/rust/async-trait/tests/ui/arg-implementation-detail.rs new file mode 100644 index 0000000000..b83aa72fcf --- /dev/null +++ b/third_party/rust/async-trait/tests/ui/arg-implementation-detail.rs @@ -0,0 +1,22 @@ +use async_trait::async_trait; + +pub struct Struct; + +#[async_trait] +pub trait Trait { + async fn f((_a, _b): (Struct, Struct)) { + // Expands to something like: + // + // fn f(__arg0: (Struct, Struct)) -> … { + // Box::pin(async move { + // let (_a, _b) = __arg0; + // … + // }) + // } + // + // but user's code must not be allowed to name that temporary argument: + let _ = __arg0; + } +} + +fn main() {} diff --git a/third_party/rust/async-trait/tests/ui/arg-implementation-detail.stderr b/third_party/rust/async-trait/tests/ui/arg-implementation-detail.stderr new file mode 100644 index 0000000000..e742688888 --- /dev/null +++ b/third_party/rust/async-trait/tests/ui/arg-implementation-detail.stderr @@ -0,0 +1,5 @@ +error[E0425]: cannot find value `__arg0` in this scope + --> tests/ui/arg-implementation-detail.rs:18:17 + | +18 | let _ = __arg0; + | ^^^^^^ not found in this scope diff --git a/third_party/rust/async-trait/tests/ui/bare-trait-object.rs b/third_party/rust/async-trait/tests/ui/bare-trait-object.rs new file mode 100644 index 0000000000..afcd6b44c3 --- /dev/null +++ b/third_party/rust/async-trait/tests/ui/bare-trait-object.rs @@ -0,0 +1,15 @@ +#![deny(bare_trait_objects)] + +use async_trait::async_trait; + +#[async_trait] +trait Trait { + async fn f(&self); +} + +#[async_trait] +impl Trait for Send + Sync { + async fn f(&self) {} +} + +fn main() {} diff --git a/third_party/rust/async-trait/tests/ui/bare-trait-object.stderr b/third_party/rust/async-trait/tests/ui/bare-trait-object.stderr new file mode 100644 index 0000000000..50b20484cb --- /dev/null +++ b/third_party/rust/async-trait/tests/ui/bare-trait-object.stderr @@ -0,0 +1,21 @@ +error: trait objects without an explicit `dyn` are deprecated + --> tests/ui/bare-trait-object.rs:11:16 + | +11 | impl Trait for Send + Sync { + | ^^^^^^^^^^^ + | + = warning: this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2021! + = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html> +note: the lint level is defined here + --> tests/ui/bare-trait-object.rs:1:9 + | +1 | #![deny(bare_trait_objects)] + | ^^^^^^^^^^^^^^^^^^ +help: use `dyn` + | +11 | impl Trait for dyn Send + Sync { + | +++ +help: alternatively use a blanket implementation to implement `Trait` for all types that also implement `Send + Sync` + | +11 | impl<T: Send + Sync> Trait for T { + | ++++++++++++++++ ~ diff --git a/third_party/rust/async-trait/tests/ui/consider-restricting.rs b/third_party/rust/async-trait/tests/ui/consider-restricting.rs new file mode 100644 index 0000000000..e23c8b1539 --- /dev/null +++ b/third_party/rust/async-trait/tests/ui/consider-restricting.rs @@ -0,0 +1,26 @@ +// https://github.com/rust-lang/rust/issues/93828 + +use async_trait::async_trait; + +pub trait IntoUrl {} + +#[async_trait] +pub trait ClientExt { + async fn publish<T: IntoUrl>(&self, url: T); +} + +struct Client; + +#[async_trait] +impl ClientExt for Client { + async fn publish<T: IntoUrl>(&self, url: T) {} +} + +struct Client2; + +#[async_trait] +impl ClientExt for Client2 { + async fn publish<T>(&self, url: T) {} +} + +fn main() {} diff --git a/third_party/rust/async-trait/tests/ui/consider-restricting.stderr b/third_party/rust/async-trait/tests/ui/consider-restricting.stderr new file mode 100644 index 0000000000..62ff894ed5 --- /dev/null +++ b/third_party/rust/async-trait/tests/ui/consider-restricting.stderr @@ -0,0 +1,33 @@ +error: future cannot be sent between threads safely + --> tests/ui/consider-restricting.rs:16:49 + | +16 | async fn publish<T: IntoUrl>(&self, url: T) {} + | ^^ future created by async block is not `Send` + | +note: captured value is not `Send` + --> tests/ui/consider-restricting.rs:16:41 + | +16 | async fn publish<T: IntoUrl>(&self, url: T) {} + | ^^^ has type `T` which is not `Send` + = note: required for the cast from `[async block@$DIR/tests/ui/consider-restricting.rs:16:49: 16:51]` to the object type `dyn Future<Output = ()> + Send` +help: consider further restricting this bound + | +16 | async fn publish<T: IntoUrl + std::marker::Send>(&self, url: T) {} + | +++++++++++++++++++ + +error: future cannot be sent between threads safely + --> tests/ui/consider-restricting.rs:23:40 + | +23 | async fn publish<T>(&self, url: T) {} + | ^^ future created by async block is not `Send` + | +note: captured value is not `Send` + --> tests/ui/consider-restricting.rs:23:32 + | +23 | async fn publish<T>(&self, url: T) {} + | ^^^ has type `T` which is not `Send` + = note: required for the cast from `[async block@$DIR/tests/ui/consider-restricting.rs:23:40: 23:42]` to the object type `dyn Future<Output = ()> + Send` +help: consider further restricting this bound + | +23 | async fn publish<T + std::marker::Send>(&self, url: T) {} + | +++++++++++++++++++ diff --git a/third_party/rust/async-trait/tests/ui/delimiter-span.rs b/third_party/rust/async-trait/tests/ui/delimiter-span.rs new file mode 100644 index 0000000000..51a44a24b5 --- /dev/null +++ b/third_party/rust/async-trait/tests/ui/delimiter-span.rs @@ -0,0 +1,24 @@ +#![allow(unused_macro_rules)] + +use async_trait::async_trait; + +macro_rules! picky { + ($(t:tt)*) => {}; +} + +#[async_trait] +trait Trait { + async fn method(); +} + +struct Struct; + +#[async_trait] +impl Trait for Struct { + async fn method() { + picky!({ 123, self }); + picky!({ 123 }); + } +} + +fn main() {} diff --git a/third_party/rust/async-trait/tests/ui/delimiter-span.stderr b/third_party/rust/async-trait/tests/ui/delimiter-span.stderr new file mode 100644 index 0000000000..f03da4c97c --- /dev/null +++ b/third_party/rust/async-trait/tests/ui/delimiter-span.stderr @@ -0,0 +1,21 @@ +error: no rules expected the token `{` + --> tests/ui/delimiter-span.rs:19:16 + | +5 | macro_rules! picky { + | ------------------ when calling this macro +... +19 | picky!({ 123, self }); + | ^ no rules expected this token in macro call + | + = note: while trying to match sequence start + +error: no rules expected the token `{` + --> tests/ui/delimiter-span.rs:20:16 + | +5 | macro_rules! picky { + | ------------------ when calling this macro +... +20 | picky!({ 123 }); + | ^ no rules expected this token in macro call + | + = note: while trying to match sequence start diff --git a/third_party/rust/async-trait/tests/ui/lifetime-span.rs b/third_party/rust/async-trait/tests/ui/lifetime-span.rs new file mode 100644 index 0000000000..01981e6de4 --- /dev/null +++ b/third_party/rust/async-trait/tests/ui/lifetime-span.rs @@ -0,0 +1,36 @@ +use async_trait::async_trait; + +struct A; +struct B; + +#[async_trait] +pub trait Trait<'r> { + async fn method(&'r self); +} + +#[async_trait] +impl Trait for A { + async fn method(&self) {} +} + +#[async_trait] +impl<'r> Trait<'r> for B { + async fn method(&self) {} +} + +#[async_trait] +pub trait Trait2 { + async fn method<'r>(&'r self); +} + +#[async_trait] +impl Trait2 for A { + async fn method(&self) {} +} + +#[async_trait] +impl<'r> Trait2<'r> for B { + async fn method(&'r self) {} +} + +fn main() {} diff --git a/third_party/rust/async-trait/tests/ui/lifetime-span.stderr b/third_party/rust/async-trait/tests/ui/lifetime-span.stderr new file mode 100644 index 0000000000..999da04c30 --- /dev/null +++ b/third_party/rust/async-trait/tests/ui/lifetime-span.stderr @@ -0,0 +1,25 @@ +error[E0726]: implicit elided lifetime not allowed here + --> tests/ui/lifetime-span.rs:12:6 + | +12 | impl Trait for A { + | ^^^^^ expected lifetime parameter + | + = note: assuming a `'static` lifetime... +help: indicate the anonymous lifetime + | +12 | impl Trait<'_> for A { + | ++++ + +error[E0107]: this 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 { + | ^^^^^^ diff --git a/third_party/rust/async-trait/tests/ui/missing-async-in-impl.rs b/third_party/rust/async-trait/tests/ui/missing-async-in-impl.rs new file mode 100644 index 0000000000..3a5f58c3ac --- /dev/null +++ b/third_party/rust/async-trait/tests/ui/missing-async-in-impl.rs @@ -0,0 +1,15 @@ +use async_trait::async_trait; + +#[async_trait] +pub trait Trait { + async fn method(); +} + +pub struct Struct; + +#[async_trait] +impl Trait for Struct { + fn method() {} +} + +fn main() {} diff --git a/third_party/rust/async-trait/tests/ui/missing-async-in-impl.stderr b/third_party/rust/async-trait/tests/ui/missing-async-in-impl.stderr new file mode 100644 index 0000000000..e461c85d8d --- /dev/null +++ b/third_party/rust/async-trait/tests/ui/missing-async-in-impl.stderr @@ -0,0 +1,8 @@ +error[E0195]: lifetime parameters or bounds on method `method` do not match the trait declaration + --> tests/ui/missing-async-in-impl.rs:12:14 + | +5 | async fn method(); + | -------- lifetimes in impl do not match this method in trait +... +12 | fn method() {} + | ^ lifetimes do not match method in trait diff --git a/third_party/rust/async-trait/tests/ui/missing-async-in-trait.rs b/third_party/rust/async-trait/tests/ui/missing-async-in-trait.rs new file mode 100644 index 0000000000..56fea7a1f8 --- /dev/null +++ b/third_party/rust/async-trait/tests/ui/missing-async-in-trait.rs @@ -0,0 +1,15 @@ +use async_trait::async_trait; + +#[async_trait] +pub trait Trait { + fn method(); +} + +pub struct Struct; + +#[async_trait] +impl Trait for Struct { + async fn method() {} +} + +fn main() {} diff --git a/third_party/rust/async-trait/tests/ui/missing-async-in-trait.stderr b/third_party/rust/async-trait/tests/ui/missing-async-in-trait.stderr new file mode 100644 index 0000000000..c92c38da5e --- /dev/null +++ b/third_party/rust/async-trait/tests/ui/missing-async-in-trait.stderr @@ -0,0 +1,8 @@ +error[E0195]: lifetime parameters or bounds on method `method` do not match the trait declaration + --> tests/ui/missing-async-in-trait.rs:12:14 + | +5 | fn method(); + | - lifetimes in impl do not match this method in trait +... +12 | async fn method() {} + | ^^^^^^^^ lifetimes do not match method in trait diff --git a/third_party/rust/async-trait/tests/ui/missing-body.rs b/third_party/rust/async-trait/tests/ui/missing-body.rs new file mode 100644 index 0000000000..f3e1126d1d --- /dev/null +++ b/third_party/rust/async-trait/tests/ui/missing-body.rs @@ -0,0 +1,15 @@ +use async_trait::async_trait; + +#[async_trait] +trait Trait { + async fn f(&self); +} + +struct Thing; + +#[async_trait] +impl Trait for Thing { + async fn f(&self); +} + +fn main() {} diff --git a/third_party/rust/async-trait/tests/ui/missing-body.stderr b/third_party/rust/async-trait/tests/ui/missing-body.stderr new file mode 100644 index 0000000000..e6ddb425f9 --- /dev/null +++ b/third_party/rust/async-trait/tests/ui/missing-body.stderr @@ -0,0 +1,7 @@ +error: associated function in `impl` without body + --> tests/ui/missing-body.rs:12:5 + | +12 | async fn f(&self); + | ^^^^^^^^^^^^^^^^^- + | | + | help: provide a definition for the function: `{ <body> }` diff --git a/third_party/rust/async-trait/tests/ui/must-use.rs b/third_party/rust/async-trait/tests/ui/must-use.rs new file mode 100644 index 0000000000..7ad0d9bf33 --- /dev/null +++ b/third_party/rust/async-trait/tests/ui/must-use.rs @@ -0,0 +1,21 @@ +#![deny(unused_must_use)] + +use async_trait::async_trait; + +#[async_trait] +trait Interface { + async fn f(&self); +} + +struct Thing; + +#[async_trait] +impl Interface for Thing { + async fn f(&self) {} +} + +pub async fn f() { + Thing.f(); +} + +fn main() {} diff --git a/third_party/rust/async-trait/tests/ui/must-use.stderr b/third_party/rust/async-trait/tests/ui/must-use.stderr new file mode 100644 index 0000000000..fd6fc31d60 --- /dev/null +++ b/third_party/rust/async-trait/tests/ui/must-use.stderr @@ -0,0 +1,11 @@ +error: unused return value of `Interface::f` that must be used + --> tests/ui/must-use.rs:18:5 + | +18 | Thing.f(); + | ^^^^^^^^^ + | +note: the lint level is defined here + --> tests/ui/must-use.rs:1:9 + | +1 | #![deny(unused_must_use)] + | ^^^^^^^^^^^^^^^ diff --git a/third_party/rust/async-trait/tests/ui/self-span.rs b/third_party/rust/async-trait/tests/ui/self-span.rs new file mode 100644 index 0000000000..b01f247032 --- /dev/null +++ b/third_party/rust/async-trait/tests/ui/self-span.rs @@ -0,0 +1,30 @@ +use async_trait::async_trait; + +pub struct S {} + +pub enum E { + V {}, +} + +#[async_trait] +pub trait Trait { + async fn method(self); +} + +#[async_trait] +impl Trait for S { + async fn method(self) { + let _: () = self; + let _: Self = Self; + } +} + +#[async_trait] +impl Trait for E { + async fn method(self) { + let _: () = self; + let _: Self = Self::V; + } +} + +fn main() {} diff --git a/third_party/rust/async-trait/tests/ui/self-span.stderr b/third_party/rust/async-trait/tests/ui/self-span.stderr new file mode 100644 index 0000000000..8743e57934 --- /dev/null +++ b/third_party/rust/async-trait/tests/ui/self-span.stderr @@ -0,0 +1,27 @@ +error[E0308]: mismatched types + --> tests/ui/self-span.rs:17:21 + | +17 | let _: () = self; + | -- ^^^^ expected `()`, found struct `S` + | | + | expected due to this + +error: the `Self` constructor can only be used with tuple or unit structs + --> tests/ui/self-span.rs:18:23 + | +18 | let _: Self = Self; + | ^^^^ help: use curly brackets: `Self { /* fields */ }` + +error[E0308]: mismatched types + --> tests/ui/self-span.rs:25:21 + | +25 | let _: () = self; + | -- ^^^^ expected `()`, found enum `E` + | | + | expected due to this + +error[E0533]: expected value, found struct variant `Self::V` + --> tests/ui/self-span.rs:26:23 + | +26 | let _: Self = Self::V; + | ^^^^^^^ not a value diff --git a/third_party/rust/async-trait/tests/ui/send-not-implemented.rs b/third_party/rust/async-trait/tests/ui/send-not-implemented.rs new file mode 100644 index 0000000000..d8883fb498 --- /dev/null +++ b/third_party/rust/async-trait/tests/ui/send-not-implemented.rs @@ -0,0 +1,22 @@ +use async_trait::async_trait; +use std::sync::Mutex; + +async fn f() {} + +#[async_trait] +trait Test { + async fn test(&self) { + let mutex = Mutex::new(()); + let _guard = mutex.lock().unwrap(); + f().await; + } + + async fn test_ret(&self) -> bool { + let mutex = Mutex::new(()); + let _guard = mutex.lock().unwrap(); + f().await; + true + } +} + +fn main() {} diff --git a/third_party/rust/async-trait/tests/ui/send-not-implemented.stderr b/third_party/rust/async-trait/tests/ui/send-not-implemented.stderr new file mode 100644 index 0000000000..d68fc43c36 --- /dev/null +++ b/third_party/rust/async-trait/tests/ui/send-not-implemented.stderr @@ -0,0 +1,47 @@ +error: future cannot be sent between threads safely + --> tests/ui/send-not-implemented.rs:8:26 + | +8 | async fn test(&self) { + | __________________________^ +9 | | let mutex = Mutex::new(()); +10 | | let _guard = mutex.lock().unwrap(); +11 | | f().await; +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<'_, ()>` +note: future is not `Send` as this value is used across an await + --> tests/ui/send-not-implemented.rs:11:12 + | +10 | let _guard = mutex.lock().unwrap(); + | ------ has type `MutexGuard<'_, ()>` which is not `Send` +11 | f().await; + | ^^^^^^ await occurs here, with `_guard` maybe used later +12 | } + | - `_guard` is later dropped here + = note: required for the cast from `[async block@$DIR/tests/ui/send-not-implemented.rs:8:26: 12:6]` to the object type `dyn Future<Output = ()> + Send` + +error: future cannot be sent between threads safely + --> tests/ui/send-not-implemented.rs:14:38 + | +14 | async fn test_ret(&self) -> bool { + | ______________________________________^ +15 | | let mutex = Mutex::new(()); +16 | | let _guard = mutex.lock().unwrap(); +17 | | f().await; +18 | | true +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<'_, ()>` +note: future is not `Send` as this value is used across an await + --> tests/ui/send-not-implemented.rs:17:12 + | +16 | let _guard = mutex.lock().unwrap(); + | ------ has type `MutexGuard<'_, ()>` which is not `Send` +17 | f().await; + | ^^^^^^ await occurs here, with `_guard` maybe used later +18 | true +19 | } + | - `_guard` is later dropped here + = note: required for the cast from `[async block@$DIR/tests/ui/send-not-implemented.rs:14:38: 19:6]` to the object type `dyn Future<Output = bool> + Send` diff --git a/third_party/rust/async-trait/tests/ui/unreachable.rs b/third_party/rust/async-trait/tests/ui/unreachable.rs new file mode 100644 index 0000000000..cac2826444 --- /dev/null +++ b/third_party/rust/async-trait/tests/ui/unreachable.rs @@ -0,0 +1,20 @@ +#![deny(warnings)] + +use async_trait::async_trait; + +#[async_trait] +pub trait Trait { + async fn f() { + unimplemented!() + } +} + +#[async_trait] +pub trait TraitFoo { + async fn f() { + let _y = unimplemented!(); + let _z = _y; + } +} + +fn main() {} diff --git a/third_party/rust/async-trait/tests/ui/unreachable.stderr b/third_party/rust/async-trait/tests/ui/unreachable.stderr new file mode 100644 index 0000000000..08595e5af7 --- /dev/null +++ b/third_party/rust/async-trait/tests/ui/unreachable.stderr @@ -0,0 +1,14 @@ +error: unreachable statement + --> tests/ui/unreachable.rs:16:9 + | +15 | let _y = unimplemented!(); + | ---------------- any code following this expression is unreachable +16 | let _z = _y; + | ^^^^^^^^^^^^ unreachable statement + | +note: the lint level is defined here + --> tests/ui/unreachable.rs:1:9 + | +1 | #![deny(warnings)] + | ^^^^^^^^ + = note: `#[deny(unreachable_code)]` implied by `#[deny(warnings)]` diff --git a/third_party/rust/async-trait/tests/ui/unsupported-self.rs b/third_party/rust/async-trait/tests/ui/unsupported-self.rs new file mode 100644 index 0000000000..5868c614ad --- /dev/null +++ b/third_party/rust/async-trait/tests/ui/unsupported-self.rs @@ -0,0 +1,15 @@ +use async_trait::async_trait; + +#[async_trait] +pub trait Trait { + async fn method(); +} + +#[async_trait] +impl Trait for &'static str { + async fn method() { + let _ = Self; + } +} + +fn main() {} diff --git a/third_party/rust/async-trait/tests/ui/unsupported-self.stderr b/third_party/rust/async-trait/tests/ui/unsupported-self.stderr new file mode 100644 index 0000000000..14939459e1 --- /dev/null +++ b/third_party/rust/async-trait/tests/ui/unsupported-self.stderr @@ -0,0 +1,5 @@ +error: the `Self` constructor can only be used with tuple or unit structs + --> tests/ui/unsupported-self.rs:11:17 + | +11 | let _ = Self; + | ^^^^ |