summaryrefslogtreecommitdiffstats
path: root/tests/ui/associated-type-bounds
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:20:39 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:20:39 +0000
commit1376c5a617be5c25655d0d7cb63e3beaa5a6e026 (patch)
tree3bb8d61aee02bc7a15eab3f36e3b921afc2075d0 /tests/ui/associated-type-bounds
parentReleasing progress-linux version 1.69.0+dfsg1-1~progress7.99u1. (diff)
downloadrustc-1376c5a617be5c25655d0d7cb63e3beaa5a6e026.tar.xz
rustc-1376c5a617be5c25655d0d7cb63e3beaa5a6e026.zip
Merging upstream version 1.70.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui/associated-type-bounds')
-rw-r--r--tests/ui/associated-type-bounds/ambiguous-associated-type2.stderr2
-rw-r--r--tests/ui/associated-type-bounds/issue-104916.rs14
-rw-r--r--tests/ui/associated-type-bounds/issue-104916.stderr8
-rw-r--r--tests/ui/associated-type-bounds/return-type-notation/bad-inputs-and-output.rs22
-rw-r--r--tests/ui/associated-type-bounds/return-type-notation/bad-inputs-and-output.stderr56
-rw-r--r--tests/ui/associated-type-bounds/return-type-notation/basic.rs28
-rw-r--r--tests/ui/associated-type-bounds/return-type-notation/basic.with.stderr19
-rw-r--r--tests/ui/associated-type-bounds/return-type-notation/basic.without.stderr37
-rw-r--r--tests/ui/associated-type-bounds/return-type-notation/equality.rs16
-rw-r--r--tests/ui/associated-type-bounds/return-type-notation/equality.stderr25
-rw-r--r--tests/ui/associated-type-bounds/return-type-notation/missing.rs14
-rw-r--r--tests/ui/associated-type-bounds/return-type-notation/missing.stderr25
-rw-r--r--tests/ui/associated-type-bounds/return-type-notation/non-rpitit.rs11
-rw-r--r--tests/ui/associated-type-bounds/return-type-notation/non-rpitit.stderr22
-rw-r--r--tests/ui/associated-type-bounds/return-type-notation/unpretty-parenthesized.rs11
-rw-r--r--tests/ui/associated-type-bounds/return-type-notation/unpretty-parenthesized.stderr12
-rw-r--r--tests/ui/associated-type-bounds/return-type-notation/unpretty-parenthesized.stdout15
17 files changed, 336 insertions, 1 deletions
diff --git a/tests/ui/associated-type-bounds/ambiguous-associated-type2.stderr b/tests/ui/associated-type-bounds/ambiguous-associated-type2.stderr
index 4162cdaa8..575b00e09 100644
--- a/tests/ui/associated-type-bounds/ambiguous-associated-type2.stderr
+++ b/tests/ui/associated-type-bounds/ambiguous-associated-type2.stderr
@@ -5,7 +5,7 @@ LL | trait Baz: Foo + Bar<Self::Item> {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: ...which immediately requires computing the super traits of `Baz` with associated type name `Item` again
-note: cycle used when computing the super traits of `Baz`
+note: cycle used when computing the super predicates of `Baz`
--> $DIR/ambiguous-associated-type2.rs:7:1
|
LL | trait Baz: Foo + Bar<Self::Item> {}
diff --git a/tests/ui/associated-type-bounds/issue-104916.rs b/tests/ui/associated-type-bounds/issue-104916.rs
new file mode 100644
index 000000000..3361fa011
--- /dev/null
+++ b/tests/ui/associated-type-bounds/issue-104916.rs
@@ -0,0 +1,14 @@
+#![feature(associated_type_bounds)]
+
+trait B {
+ type AssocType;
+}
+
+fn f()
+where
+ dyn for<'j> B<AssocType: 'j>:,
+ //~^ ERROR: associated type bounds are only allowed in where clauses and function signatures
+{
+}
+
+fn main() {}
diff --git a/tests/ui/associated-type-bounds/issue-104916.stderr b/tests/ui/associated-type-bounds/issue-104916.stderr
new file mode 100644
index 000000000..35435962f
--- /dev/null
+++ b/tests/ui/associated-type-bounds/issue-104916.stderr
@@ -0,0 +1,8 @@
+error: associated type bounds are only allowed in where clauses and function signatures, not in bounds
+ --> $DIR/issue-104916.rs:9:19
+ |
+LL | dyn for<'j> B<AssocType: 'j>:,
+ | ^^^^^^^^^^^^^
+
+error: aborting due to previous error
+
diff --git a/tests/ui/associated-type-bounds/return-type-notation/bad-inputs-and-output.rs b/tests/ui/associated-type-bounds/return-type-notation/bad-inputs-and-output.rs
new file mode 100644
index 000000000..79cee5517
--- /dev/null
+++ b/tests/ui/associated-type-bounds/return-type-notation/bad-inputs-and-output.rs
@@ -0,0 +1,22 @@
+// edition: 2021
+
+#![feature(return_type_notation, async_fn_in_trait)]
+//~^ WARN the feature `return_type_notation` is incomplete
+//~| WARN the feature `async_fn_in_trait` is incomplete
+
+trait Trait {
+ async fn method() {}
+}
+
+fn foo<T: Trait<method(i32): Send>>() {}
+//~^ ERROR argument types not allowed with return type notation
+//~| ERROR associated type bounds are unstable
+
+fn bar<T: Trait<method() -> (): Send>>() {}
+//~^ ERROR return type not allowed with return type notation
+//~| ERROR associated type bounds are unstable
+
+fn baz<T: Trait<method(..): Send>>() {}
+//~^ ERROR return type notation uses `()` instead of `(..)` for elided arguments
+
+fn main() {}
diff --git a/tests/ui/associated-type-bounds/return-type-notation/bad-inputs-and-output.stderr b/tests/ui/associated-type-bounds/return-type-notation/bad-inputs-and-output.stderr
new file mode 100644
index 000000000..b23e0f791
--- /dev/null
+++ b/tests/ui/associated-type-bounds/return-type-notation/bad-inputs-and-output.stderr
@@ -0,0 +1,56 @@
+error: return type notation uses `()` instead of `(..)` for elided arguments
+ --> $DIR/bad-inputs-and-output.rs:19:24
+ |
+LL | fn baz<T: Trait<method(..): Send>>() {}
+ | ^^ help: remove the `..`
+
+error[E0658]: associated type bounds are unstable
+ --> $DIR/bad-inputs-and-output.rs:11:17
+ |
+LL | fn foo<T: Trait<method(i32): Send>>() {}
+ | ^^^^^^^^^^^^^^^^^
+ |
+ = note: see issue #52662 <https://github.com/rust-lang/rust/issues/52662> for more information
+ = help: add `#![feature(associated_type_bounds)]` to the crate attributes to enable
+
+error[E0658]: associated type bounds are unstable
+ --> $DIR/bad-inputs-and-output.rs:15:17
+ |
+LL | fn bar<T: Trait<method() -> (): Send>>() {}
+ | ^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: see issue #52662 <https://github.com/rust-lang/rust/issues/52662> for more information
+ = help: add `#![feature(associated_type_bounds)]` to the crate attributes to enable
+
+warning: the feature `return_type_notation` is incomplete and may not be safe to use and/or cause compiler crashes
+ --> $DIR/bad-inputs-and-output.rs:3:12
+ |
+LL | #![feature(return_type_notation, async_fn_in_trait)]
+ | ^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: see issue #109417 <https://github.com/rust-lang/rust/issues/109417> for more information
+ = note: `#[warn(incomplete_features)]` on by default
+
+warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes
+ --> $DIR/bad-inputs-and-output.rs:3:34
+ |
+LL | #![feature(return_type_notation, async_fn_in_trait)]
+ | ^^^^^^^^^^^^^^^^^
+ |
+ = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information
+
+error: argument types not allowed with return type notation
+ --> $DIR/bad-inputs-and-output.rs:11:23
+ |
+LL | fn foo<T: Trait<method(i32): Send>>() {}
+ | ^^^^^ help: remove the input types: `()`
+
+error: return type not allowed with return type notation
+ --> $DIR/bad-inputs-and-output.rs:15:25
+ |
+LL | fn bar<T: Trait<method() -> (): Send>>() {}
+ | ^^^^^^ help: remove the return type
+
+error: aborting due to 5 previous errors; 2 warnings emitted
+
+For more information about this error, try `rustc --explain E0658`.
diff --git a/tests/ui/associated-type-bounds/return-type-notation/basic.rs b/tests/ui/associated-type-bounds/return-type-notation/basic.rs
new file mode 100644
index 000000000..0b7530b65
--- /dev/null
+++ b/tests/ui/associated-type-bounds/return-type-notation/basic.rs
@@ -0,0 +1,28 @@
+// revisions: with without
+// edition: 2021
+//[with] check-pass
+
+#![feature(return_type_notation, async_fn_in_trait)]
+//~^ WARN the feature `return_type_notation` is incomplete
+//~| WARN the feature `async_fn_in_trait` is incomplete
+
+trait Foo {
+ async fn method() -> Result<(), ()>;
+}
+
+async fn foo<T: Foo>() -> Result<(), ()> {
+ T::method().await?;
+ Ok(())
+}
+
+fn is_send(_: impl Send) {}
+
+fn test<
+ #[cfg(with)] T: Foo<method(): Send>,
+ #[cfg(without)] T: Foo,
+>() {
+ is_send(foo::<T>());
+ //[without]~^ ERROR future cannot be sent between threads safely
+}
+
+fn main() {}
diff --git a/tests/ui/associated-type-bounds/return-type-notation/basic.with.stderr b/tests/ui/associated-type-bounds/return-type-notation/basic.with.stderr
new file mode 100644
index 000000000..722c774cb
--- /dev/null
+++ b/tests/ui/associated-type-bounds/return-type-notation/basic.with.stderr
@@ -0,0 +1,19 @@
+warning: the feature `return_type_notation` is incomplete and may not be safe to use and/or cause compiler crashes
+ --> $DIR/basic.rs:5:12
+ |
+LL | #![feature(return_type_notation, async_fn_in_trait)]
+ | ^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: see issue #109417 <https://github.com/rust-lang/rust/issues/109417> for more information
+ = note: `#[warn(incomplete_features)]` on by default
+
+warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes
+ --> $DIR/basic.rs:5:34
+ |
+LL | #![feature(return_type_notation, async_fn_in_trait)]
+ | ^^^^^^^^^^^^^^^^^
+ |
+ = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information
+
+warning: 2 warnings emitted
+
diff --git a/tests/ui/associated-type-bounds/return-type-notation/basic.without.stderr b/tests/ui/associated-type-bounds/return-type-notation/basic.without.stderr
new file mode 100644
index 000000000..1645d8c26
--- /dev/null
+++ b/tests/ui/associated-type-bounds/return-type-notation/basic.without.stderr
@@ -0,0 +1,37 @@
+warning: the feature `return_type_notation` is incomplete and may not be safe to use and/or cause compiler crashes
+ --> $DIR/basic.rs:5:12
+ |
+LL | #![feature(return_type_notation, async_fn_in_trait)]
+ | ^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: see issue #109417 <https://github.com/rust-lang/rust/issues/109417> for more information
+ = note: `#[warn(incomplete_features)]` on by default
+
+warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes
+ --> $DIR/basic.rs:5:34
+ |
+LL | #![feature(return_type_notation, async_fn_in_trait)]
+ | ^^^^^^^^^^^^^^^^^
+ |
+ = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information
+
+error: future cannot be sent between threads safely
+ --> $DIR/basic.rs:24:13
+ |
+LL | is_send(foo::<T>());
+ | ^^^^^^^^^^ future returned by `foo` is not `Send`
+ |
+ = help: within `impl Future<Output = Result<(), ()>>`, the trait `Send` is not implemented for `impl Future<Output = Result<(), ()>>`
+note: future is not `Send` as it awaits another future which is not `Send`
+ --> $DIR/basic.rs:14:5
+ |
+LL | T::method().await?;
+ | ^^^^^^^^^^^ await occurs here on type `impl Future<Output = Result<(), ()>>`, which is not `Send`
+note: required by a bound in `is_send`
+ --> $DIR/basic.rs:18:20
+ |
+LL | fn is_send(_: impl Send) {}
+ | ^^^^ required by this bound in `is_send`
+
+error: aborting due to previous error; 2 warnings emitted
+
diff --git a/tests/ui/associated-type-bounds/return-type-notation/equality.rs b/tests/ui/associated-type-bounds/return-type-notation/equality.rs
new file mode 100644
index 000000000..75f757e90
--- /dev/null
+++ b/tests/ui/associated-type-bounds/return-type-notation/equality.rs
@@ -0,0 +1,16 @@
+// edition: 2021
+
+#![feature(return_type_notation, async_fn_in_trait)]
+//~^ WARN the feature `return_type_notation` is incomplete
+//~| WARN the feature `async_fn_in_trait` is incomplete
+
+use std::future::Future;
+
+trait Trait {
+ async fn method() {}
+}
+
+fn test<T: Trait<method() = Box<dyn Future<Output = ()>>>>() {}
+//~^ ERROR return type notation is not allowed to use type equality
+
+fn main() {}
diff --git a/tests/ui/associated-type-bounds/return-type-notation/equality.stderr b/tests/ui/associated-type-bounds/return-type-notation/equality.stderr
new file mode 100644
index 000000000..c5b2e5710
--- /dev/null
+++ b/tests/ui/associated-type-bounds/return-type-notation/equality.stderr
@@ -0,0 +1,25 @@
+warning: the feature `return_type_notation` is incomplete and may not be safe to use and/or cause compiler crashes
+ --> $DIR/equality.rs:3:12
+ |
+LL | #![feature(return_type_notation, async_fn_in_trait)]
+ | ^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: see issue #109417 <https://github.com/rust-lang/rust/issues/109417> for more information
+ = note: `#[warn(incomplete_features)]` on by default
+
+warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes
+ --> $DIR/equality.rs:3:34
+ |
+LL | #![feature(return_type_notation, async_fn_in_trait)]
+ | ^^^^^^^^^^^^^^^^^
+ |
+ = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information
+
+error: return type notation is not allowed to use type equality
+ --> $DIR/equality.rs:13:18
+ |
+LL | fn test<T: Trait<method() = Box<dyn Future<Output = ()>>>>() {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to previous error; 2 warnings emitted
+
diff --git a/tests/ui/associated-type-bounds/return-type-notation/missing.rs b/tests/ui/associated-type-bounds/return-type-notation/missing.rs
new file mode 100644
index 000000000..7b98a5cda
--- /dev/null
+++ b/tests/ui/associated-type-bounds/return-type-notation/missing.rs
@@ -0,0 +1,14 @@
+// edition: 2021
+
+#![feature(return_type_notation, async_fn_in_trait)]
+//~^ WARN the feature `return_type_notation` is incomplete
+//~| WARN the feature `async_fn_in_trait` is incomplete
+
+trait Trait {
+ async fn method() {}
+}
+
+fn bar<T: Trait<methid(): Send>>() {}
+//~^ ERROR cannot find associated function `methid` in trait `Trait`
+
+fn main() {}
diff --git a/tests/ui/associated-type-bounds/return-type-notation/missing.stderr b/tests/ui/associated-type-bounds/return-type-notation/missing.stderr
new file mode 100644
index 000000000..34f5bda88
--- /dev/null
+++ b/tests/ui/associated-type-bounds/return-type-notation/missing.stderr
@@ -0,0 +1,25 @@
+warning: the feature `return_type_notation` is incomplete and may not be safe to use and/or cause compiler crashes
+ --> $DIR/missing.rs:3:12
+ |
+LL | #![feature(return_type_notation, async_fn_in_trait)]
+ | ^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: see issue #109417 <https://github.com/rust-lang/rust/issues/109417> for more information
+ = note: `#[warn(incomplete_features)]` on by default
+
+warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes
+ --> $DIR/missing.rs:3:34
+ |
+LL | #![feature(return_type_notation, async_fn_in_trait)]
+ | ^^^^^^^^^^^^^^^^^
+ |
+ = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information
+
+error: cannot find associated function `methid` in trait `Trait`
+ --> $DIR/missing.rs:11:17
+ |
+LL | fn bar<T: Trait<methid(): Send>>() {}
+ | ^^^^^^^^^^^^^^
+
+error: aborting due to previous error; 2 warnings emitted
+
diff --git a/tests/ui/associated-type-bounds/return-type-notation/non-rpitit.rs b/tests/ui/associated-type-bounds/return-type-notation/non-rpitit.rs
new file mode 100644
index 000000000..db5f6fe38
--- /dev/null
+++ b/tests/ui/associated-type-bounds/return-type-notation/non-rpitit.rs
@@ -0,0 +1,11 @@
+#![feature(return_type_notation)]
+//~^ WARN the feature `return_type_notation` is incomplete
+
+trait Trait {
+ fn method() {}
+}
+
+fn test<T: Trait<method(): Send>>() {}
+//~^ ERROR return type notation used on function that is not `async` and does not return `impl Trait`
+
+fn main() {}
diff --git a/tests/ui/associated-type-bounds/return-type-notation/non-rpitit.stderr b/tests/ui/associated-type-bounds/return-type-notation/non-rpitit.stderr
new file mode 100644
index 000000000..31b793995
--- /dev/null
+++ b/tests/ui/associated-type-bounds/return-type-notation/non-rpitit.stderr
@@ -0,0 +1,22 @@
+warning: the feature `return_type_notation` is incomplete and may not be safe to use and/or cause compiler crashes
+ --> $DIR/non-rpitit.rs:1:12
+ |
+LL | #![feature(return_type_notation)]
+ | ^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: see issue #109417 <https://github.com/rust-lang/rust/issues/109417> for more information
+ = note: `#[warn(incomplete_features)]` on by default
+
+error: return type notation used on function that is not `async` and does not return `impl Trait`
+ --> $DIR/non-rpitit.rs:8:18
+ |
+LL | fn method() {}
+ | ----------- this function must be `async` or return `impl Trait`
+...
+LL | fn test<T: Trait<method(): Send>>() {}
+ | ^^^^^^^^^^^^^^
+ |
+ = note: function returns `()`, which is not compatible with associated type return bounds
+
+error: aborting due to previous error; 1 warning emitted
+
diff --git a/tests/ui/associated-type-bounds/return-type-notation/unpretty-parenthesized.rs b/tests/ui/associated-type-bounds/return-type-notation/unpretty-parenthesized.rs
new file mode 100644
index 000000000..9129f37e0
--- /dev/null
+++ b/tests/ui/associated-type-bounds/return-type-notation/unpretty-parenthesized.rs
@@ -0,0 +1,11 @@
+// edition: 2021
+// compile-flags: -Zunpretty=expanded
+
+trait Trait {
+ async fn method() {}
+}
+
+fn foo<T: Trait<method(i32): Send>>() {}
+//~^ ERROR associated type bounds are unstable
+
+fn main() {}
diff --git a/tests/ui/associated-type-bounds/return-type-notation/unpretty-parenthesized.stderr b/tests/ui/associated-type-bounds/return-type-notation/unpretty-parenthesized.stderr
new file mode 100644
index 000000000..77e015b41
--- /dev/null
+++ b/tests/ui/associated-type-bounds/return-type-notation/unpretty-parenthesized.stderr
@@ -0,0 +1,12 @@
+error[E0658]: associated type bounds are unstable
+ --> $DIR/unpretty-parenthesized.rs:8:17
+ |
+LL | fn foo<T: Trait<method(i32): Send>>() {}
+ | ^^^^^^^^^^^^^^^^^
+ |
+ = note: see issue #52662 <https://github.com/rust-lang/rust/issues/52662> for more information
+ = help: add `#![feature(associated_type_bounds)]` to the crate attributes to enable
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0658`.
diff --git a/tests/ui/associated-type-bounds/return-type-notation/unpretty-parenthesized.stdout b/tests/ui/associated-type-bounds/return-type-notation/unpretty-parenthesized.stdout
new file mode 100644
index 000000000..b3dea8f6e
--- /dev/null
+++ b/tests/ui/associated-type-bounds/return-type-notation/unpretty-parenthesized.stdout
@@ -0,0 +1,15 @@
+#![feature(prelude_import)]
+#[prelude_import]
+use std::prelude::rust_2021::*;
+#[macro_use]
+extern crate std;
+// edition: 2021
+// compile-flags: -Zunpretty=expanded
+
+trait Trait {
+ async fn method() {}
+}
+
+fn foo<T: Trait<method(i32) : Send>>() {}
+
+fn main() {}