summaryrefslogtreecommitdiffstats
path: root/tests/ui/traits
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:43 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:43 +0000
commit3e3e70d529d8c7d7c4d7bc4fefc9f109393b9245 (patch)
treedaf049b282ab10e8c3d03e409b3cd84ff3f7690c /tests/ui/traits
parentAdding debian version 1.68.2+dfsg1-1. (diff)
downloadrustc-3e3e70d529d8c7d7c4d7bc4fefc9f109393b9245.tar.xz
rustc-3e3e70d529d8c7d7c4d7bc4fefc9f109393b9245.zip
Merging upstream version 1.69.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui/traits')
-rw-r--r--tests/ui/traits/alias/ambiguous.stderr4
-rw-r--r--tests/ui/traits/alias/issue-107747-do-not-assemble-supertraits.rs21
-rw-r--r--tests/ui/traits/alias/issue-108072-unmet-trait-alias-bound.rs11
-rw-r--r--tests/ui/traits/alias/issue-108072-unmet-trait-alias-bound.stderr19
-rw-r--r--tests/ui/traits/alias/issue-108132-unmet-trait-alias-bound-on-generic-impl.rs15
-rw-r--r--tests/ui/traits/alias/issue-108132-unmet-trait-alias-bound-on-generic-impl.stderr25
-rw-r--r--tests/ui/traits/alias/issue-60755.rs12
-rw-r--r--tests/ui/traits/alias/self-in-generics.rs4
-rw-r--r--tests/ui/traits/alias/self-in-generics.stderr2
-rw-r--r--tests/ui/traits/associated_type_bound/check-trait-object-bounds-3.stderr2
-rw-r--r--tests/ui/traits/coercion-generic-regions.stderr2
-rw-r--r--tests/ui/traits/inductive-overflow/supertrait-auto-trait.stderr2
-rw-r--r--tests/ui/traits/issue-103563.rs75
-rw-r--r--tests/ui/traits/issue-52893.stderr4
-rw-r--r--tests/ui/traits/issue-68295.stderr2
-rw-r--r--tests/ui/traits/issue-77982.stderr6
-rw-r--r--tests/ui/traits/item-privacy.rs4
-rw-r--r--tests/ui/traits/item-privacy.stderr12
-rw-r--r--tests/ui/traits/method-private.stderr6
-rw-r--r--tests/ui/traits/multidispatch-convert-ambig-dest.stderr2
-rw-r--r--tests/ui/traits/negative-impls/negated-auto-traits-error.stderr4
-rw-r--r--tests/ui/traits/negative-impls/no-items.stderr2
-rw-r--r--tests/ui/traits/new-solver/alias_eq_cant_be_furthur_normalized.rs29
-rw-r--r--tests/ui/traits/new-solver/alias_eq_dont_use_normalizes_to_if_substs_eq.rs45
-rw-r--r--tests/ui/traits/new-solver/alias_eq_dont_use_normalizes_to_if_substs_eq.stderr9
-rw-r--r--tests/ui/traits/new-solver/alias_eq_simple.rs22
-rw-r--r--tests/ui/traits/new-solver/alias_eq_substs_eq_not_intercrate.rs20
-rw-r--r--tests/ui/traits/new-solver/alias_eq_substs_eq_not_intercrate.stderr9
-rw-r--r--tests/ui/traits/new-solver/async.fail.stderr17
-rw-r--r--tests/ui/traits/new-solver/async.rs19
-rw-r--r--tests/ui/traits/new-solver/builtin-fn-must-return-sized.rs17
-rw-r--r--tests/ui/traits/new-solver/builtin-fn-must-return-sized.stderr18
-rw-r--r--tests/ui/traits/new-solver/elaborate-item-bounds.rs12
-rw-r--r--tests/ui/traits/new-solver/fn-trait-closure.rs9
-rw-r--r--tests/ui/traits/new-solver/generator.fail.stderr64
-rw-r--r--tests/ui/traits/new-solver/generator.rs32
-rw-r--r--tests/ui/traits/new-solver/higher-ranked-dyn-bounds.rs17
-rw-r--r--tests/ui/traits/new-solver/more-object-bound.rs27
-rw-r--r--tests/ui/traits/new-solver/more-object-bound.stderr19
-rw-r--r--tests/ui/traits/new-solver/normalizes_to_ignores_unnormalizable_candidate.rs40
-rw-r--r--tests/ui/traits/new-solver/normalizes_to_ignores_unnormalizable_candidate.self_infer.stderr14
-rw-r--r--tests/ui/traits/new-solver/object-unsafety.rs20
-rw-r--r--tests/ui/traits/new-solver/object-unsafety.stderr19
-rw-r--r--tests/ui/traits/new-solver/param-candidate-doesnt-shadow-project.rs25
-rw-r--r--tests/ui/traits/new-solver/pointee.rs23
-rw-r--r--tests/ui/traits/new-solver/pointer-like.rs14
-rw-r--r--tests/ui/traits/new-solver/pointer-like.stderr24
-rw-r--r--tests/ui/traits/new-solver/pointer-sized.rs12
-rw-r--r--tests/ui/traits/new-solver/pointer-sized.stderr24
-rw-r--r--tests/ui/traits/new-solver/provisional-result-done.rs33
-rw-r--r--tests/ui/traits/new-solver/temporary-ambiguity.rs22
-rw-r--r--tests/ui/traits/new-solver/try-example.rs28
-rw-r--r--tests/ui/traits/new-solver/two-projection-param-candidates-are-ambiguous.rs30
-rw-r--r--tests/ui/traits/new-solver/two-projection-param-candidates-are-ambiguous.stderr16
-rw-r--r--tests/ui/traits/new-solver/unsafe-auto-trait-impl.rs8
-rw-r--r--tests/ui/traits/new-solver/unsize-good.rs25
-rw-r--r--tests/ui/traits/new-solver/upcast-right-substs.rs14
-rw-r--r--tests/ui/traits/new-solver/upcast-wrong-substs.rs13
-rw-r--r--tests/ui/traits/new-solver/upcast-wrong-substs.stderr14
-rw-r--r--tests/ui/traits/non_lifetime_binders/bad-sized-cond.rs23
-rw-r--r--tests/ui/traits/non_lifetime_binders/bad-sized-cond.stderr62
-rw-r--r--tests/ui/traits/non_lifetime_binders/basic.rs19
-rw-r--r--tests/ui/traits/non_lifetime_binders/basic.stderr11
-rw-r--r--tests/ui/traits/non_lifetime_binders/fail.rs23
-rw-r--r--tests/ui/traits/non_lifetime_binders/fail.stderr43
-rw-r--r--tests/ui/traits/non_lifetime_binders/late-bound-in-anon-ct.rs11
-rw-r--r--tests/ui/traits/non_lifetime_binders/late-bound-in-anon-ct.stderr27
-rw-r--r--tests/ui/traits/non_lifetime_binders/object-lifetime-default-for-late.rs7
-rw-r--r--tests/ui/traits/non_lifetime_binders/object-lifetime-default-for-late.stderr11
-rw-r--r--tests/ui/traits/non_lifetime_binders/on-dyn.rs13
-rw-r--r--tests/ui/traits/non_lifetime_binders/on-dyn.stderr17
-rw-r--r--tests/ui/traits/non_lifetime_binders/on-ptr.rs13
-rw-r--r--tests/ui/traits/non_lifetime_binders/on-ptr.stderr17
-rw-r--r--tests/ui/traits/non_lifetime_binders/type-match-with-late-bound.rs14
-rw-r--r--tests/ui/traits/non_lifetime_binders/type-match-with-late-bound.stderr11
-rw-r--r--tests/ui/traits/object/enforce-supertrait-projection.stderr2
-rw-r--r--tests/ui/traits/object/vs-lifetime.rs4
-rw-r--r--tests/ui/traits/object/vs-lifetime.stderr4
-rw-r--r--tests/ui/traits/suggest-deferences/issue-39029.stderr4
-rw-r--r--tests/ui/traits/test-2.rs4
-rw-r--r--tests/ui/traits/test-2.stderr8
-rw-r--r--tests/ui/traits/trait-or-new-type-instead.stderr7
-rw-r--r--tests/ui/traits/trait-upcasting/multiple_supertrait_upcastable.rs10
-rw-r--r--tests/ui/traits/trait-upcasting/multiple_supertrait_upcastable.stderr14
-rw-r--r--tests/ui/traits/unsend-future.rs21
-rw-r--r--tests/ui/traits/unsend-future.stderr24
-rw-r--r--tests/ui/traits/vtable/issue-97381.stderr3
87 files changed, 1375 insertions, 91 deletions
diff --git a/tests/ui/traits/alias/ambiguous.stderr b/tests/ui/traits/alias/ambiguous.stderr
index 0fe1a7967..203bdc526 100644
--- a/tests/ui/traits/alias/ambiguous.stderr
+++ b/tests/ui/traits/alias/ambiguous.stderr
@@ -14,11 +14,11 @@ note: candidate #2 is defined in an impl of the trait `B` for the type `u8`
|
LL | fn foo(&self) {}
| ^^^^^^^^^^^^^
-help: disambiguate the associated function for candidate #1
+help: disambiguate the method for candidate #1
|
LL | A::foo(&t);
| ~~~~~~~~~~
-help: disambiguate the associated function for candidate #2
+help: disambiguate the method for candidate #2
|
LL | B::foo(&t);
| ~~~~~~~~~~
diff --git a/tests/ui/traits/alias/issue-107747-do-not-assemble-supertraits.rs b/tests/ui/traits/alias/issue-107747-do-not-assemble-supertraits.rs
new file mode 100644
index 000000000..9b41a8096
--- /dev/null
+++ b/tests/ui/traits/alias/issue-107747-do-not-assemble-supertraits.rs
@@ -0,0 +1,21 @@
+// Regression test for #107747: methods from trait alias supertraits were brought into scope
+//
+// check-pass
+
+#![feature(trait_alias)]
+
+use std::fmt;
+
+trait Foo: fmt::Debug {}
+trait Bar = Foo;
+
+#[derive(Debug)]
+struct Qux(bool);
+
+impl fmt::Display for Qux {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ self.0.fmt(f)
+ }
+}
+
+fn main() {}
diff --git a/tests/ui/traits/alias/issue-108072-unmet-trait-alias-bound.rs b/tests/ui/traits/alias/issue-108072-unmet-trait-alias-bound.rs
new file mode 100644
index 000000000..d254c0ae3
--- /dev/null
+++ b/tests/ui/traits/alias/issue-108072-unmet-trait-alias-bound.rs
@@ -0,0 +1,11 @@
+// Regression test for #108072: do not ICE upon unmet trait alias constraint
+
+#![feature(trait_alias)]
+
+trait IteratorAlias = Iterator;
+
+fn f(_: impl IteratorAlias) {}
+
+fn main() {
+ f(()) //~ `()` is not an iterator
+}
diff --git a/tests/ui/traits/alias/issue-108072-unmet-trait-alias-bound.stderr b/tests/ui/traits/alias/issue-108072-unmet-trait-alias-bound.stderr
new file mode 100644
index 000000000..39f974f96
--- /dev/null
+++ b/tests/ui/traits/alias/issue-108072-unmet-trait-alias-bound.stderr
@@ -0,0 +1,19 @@
+error[E0277]: `()` is not an iterator
+ --> $DIR/issue-108072-unmet-trait-alias-bound.rs:10:7
+ |
+LL | f(())
+ | - ^^ `()` is not an iterator
+ | |
+ | required by a bound introduced by this call
+ |
+ = help: the trait `Iterator` is not implemented for `()`
+ = note: required for `()` to implement `IteratorAlias`
+note: required by a bound in `f`
+ --> $DIR/issue-108072-unmet-trait-alias-bound.rs:7:14
+ |
+LL | fn f(_: impl IteratorAlias) {}
+ | ^^^^^^^^^^^^^ required by this bound in `f`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/traits/alias/issue-108132-unmet-trait-alias-bound-on-generic-impl.rs b/tests/ui/traits/alias/issue-108132-unmet-trait-alias-bound-on-generic-impl.rs
new file mode 100644
index 000000000..0b1f9ab57
--- /dev/null
+++ b/tests/ui/traits/alias/issue-108132-unmet-trait-alias-bound-on-generic-impl.rs
@@ -0,0 +1,15 @@
+// Regression test for #108132: do not ICE upon unmet trait alias constraint in generic impl
+
+#![feature(trait_alias)]
+
+trait IteratorAlias = Iterator;
+
+struct Foo<I>(I);
+
+impl<I: IteratorAlias> Foo<I> {
+ fn f() {}
+}
+
+fn main() {
+ Foo::<()>::f() //~ trait bounds were not satisfied
+}
diff --git a/tests/ui/traits/alias/issue-108132-unmet-trait-alias-bound-on-generic-impl.stderr b/tests/ui/traits/alias/issue-108132-unmet-trait-alias-bound-on-generic-impl.stderr
new file mode 100644
index 000000000..f1b259d5a
--- /dev/null
+++ b/tests/ui/traits/alias/issue-108132-unmet-trait-alias-bound-on-generic-impl.stderr
@@ -0,0 +1,25 @@
+error[E0599]: the function or associated item `f` exists for struct `Foo<()>`, but its trait bounds were not satisfied
+ --> $DIR/issue-108132-unmet-trait-alias-bound-on-generic-impl.rs:14:16
+ |
+LL | struct Foo<I>(I);
+ | ------------- function or associated item `f` not found for this struct
+...
+LL | Foo::<()>::f()
+ | ^ function or associated item cannot be called on `Foo<()>` due to unsatisfied trait bounds
+ |
+note: trait bound `(): Iterator` was not satisfied
+ --> $DIR/issue-108132-unmet-trait-alias-bound-on-generic-impl.rs:5:23
+ |
+LL | trait IteratorAlias = Iterator;
+ | ------------- ^^^^^^^^ unsatisfied trait bound introduced here
+note: trait bound `(): IteratorAlias` was not satisfied
+ --> $DIR/issue-108132-unmet-trait-alias-bound-on-generic-impl.rs:9:9
+ |
+LL | impl<I: IteratorAlias> Foo<I> {
+ | ^^^^^^^^^^^^^ ------
+ | |
+ | unsatisfied trait bound introduced here
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0599`.
diff --git a/tests/ui/traits/alias/issue-60755.rs b/tests/ui/traits/alias/issue-60755.rs
new file mode 100644
index 000000000..6b955a752
--- /dev/null
+++ b/tests/ui/traits/alias/issue-60755.rs
@@ -0,0 +1,12 @@
+// check-pass
+
+#![feature(trait_alias)]
+
+struct MyStruct {}
+trait MyFn = Fn(&MyStruct);
+
+fn foo(_: impl MyFn) {}
+
+fn main() {
+ foo(|_| {});
+}
diff --git a/tests/ui/traits/alias/self-in-generics.rs b/tests/ui/traits/alias/self-in-generics.rs
index 0bb6335f9..dcb33b7a9 100644
--- a/tests/ui/traits/alias/self-in-generics.rs
+++ b/tests/ui/traits/alias/self-in-generics.rs
@@ -1,9 +1,5 @@
// astconv uses `FreshTy(0)` as a dummy `Self` type when instanciating trait objects.
// This `FreshTy(0)` can leak into substs, causing ICEs in several places.
-// Using `save-analysis` triggers type-checking `f` that would be normally skipped
-// as `type_of` emitted an error.
-//
-// compile-flags: -Zsave-analysis
#![feature(trait_alias)]
diff --git a/tests/ui/traits/alias/self-in-generics.stderr b/tests/ui/traits/alias/self-in-generics.stderr
index 110d60e6e..80af4e5aa 100644
--- a/tests/ui/traits/alias/self-in-generics.stderr
+++ b/tests/ui/traits/alias/self-in-generics.stderr
@@ -1,5 +1,5 @@
error[E0038]: the trait alias `SelfInput` cannot be made into an object
- --> $DIR/self-in-generics.rs:12:19
+ --> $DIR/self-in-generics.rs:8:19
|
LL | pub fn f(_f: &dyn SelfInput) {}
| ^^^^^^^^^
diff --git a/tests/ui/traits/associated_type_bound/check-trait-object-bounds-3.stderr b/tests/ui/traits/associated_type_bound/check-trait-object-bounds-3.stderr
index ade552c4b..c7af71a42 100644
--- a/tests/ui/traits/associated_type_bound/check-trait-object-bounds-3.stderr
+++ b/tests/ui/traits/associated_type_bound/check-trait-object-bounds-3.stderr
@@ -1,6 +1,8 @@
error[E0597]: `s` does not live long enough
--> $DIR/check-trait-object-bounds-3.rs:15:34
|
+LL | let s = String::from("abcdef");
+ | - binding `s` declared here
LL | z = f::<dyn X<Y = &str>>(&s);
| ---------------------^^-
| | |
diff --git a/tests/ui/traits/coercion-generic-regions.stderr b/tests/ui/traits/coercion-generic-regions.stderr
index 5cfb64901..ae70202ab 100644
--- a/tests/ui/traits/coercion-generic-regions.stderr
+++ b/tests/ui/traits/coercion-generic-regions.stderr
@@ -1,6 +1,8 @@
error[E0597]: `person` does not live long enough
--> $DIR/coercion-generic-regions.rs:17:24
|
+LL | let person = "Fred".to_string();
+ | ------ binding `person` declared here
LL | let person: &str = &person;
| ^^^^^^^
| |
diff --git a/tests/ui/traits/inductive-overflow/supertrait-auto-trait.stderr b/tests/ui/traits/inductive-overflow/supertrait-auto-trait.stderr
index 3ec288d13..dc967d512 100644
--- a/tests/ui/traits/inductive-overflow/supertrait-auto-trait.stderr
+++ b/tests/ui/traits/inductive-overflow/supertrait-auto-trait.stderr
@@ -4,7 +4,7 @@ error[E0568]: auto traits cannot have super traits or lifetime bounds
LL | auto trait Magic: Copy {}
| -----^^^^^^ help: remove the super traits or lifetime bounds
| |
- | auto trait cannot have super traits or lifetime bounds
+ | auto traits cannot have super traits or lifetime bounds
error[E0277]: the trait bound `NoClone: Copy` is not satisfied
--> $DIR/supertrait-auto-trait.rs:16:23
diff --git a/tests/ui/traits/issue-103563.rs b/tests/ui/traits/issue-103563.rs
new file mode 100644
index 000000000..cd3eea09b
--- /dev/null
+++ b/tests/ui/traits/issue-103563.rs
@@ -0,0 +1,75 @@
+// build-pass
+
+fn main() {
+ let mut log_service = LogService { inner: Inner };
+ log_service.call(());
+}
+
+pub trait Service<Request> {
+ type Response;
+
+ fn call(&mut self, req: Request) -> Self::Response;
+}
+
+pub struct LogService<S> {
+ inner: S,
+}
+
+impl<T, U, S> Service<T> for LogService<S>
+where
+ S: Service<T, Response = U>,
+ U: Extension + 'static,
+ for<'a> U::Item<'a>: std::fmt::Debug,
+{
+ type Response = S::Response;
+
+ fn call(&mut self, req: T) -> Self::Response {
+ self.inner.call(req)
+ }
+}
+
+pub struct Inner;
+
+impl Service<()> for Inner {
+ type Response = Resp;
+
+ fn call(&mut self, req: ()) -> Self::Response {
+ Resp::A(req)
+ }
+}
+
+pub trait Extension {
+ type Item<'a>;
+
+ fn touch<F>(self, f: F) -> Self
+ where
+ for<'a> F: Fn(Self::Item<'a>);
+}
+
+pub enum Resp {
+ A(()),
+}
+
+impl Extension for Resp {
+ type Item<'a> = RespItem<'a>;
+ fn touch<F>(self, _f: F) -> Self
+ where
+ for<'a> F: Fn(Self::Item<'a>),
+ {
+ match self {
+ Self::A(a) => Self::A(a),
+ }
+ }
+}
+
+pub enum RespItem<'a> {
+ A(&'a ()),
+}
+
+impl<'a> std::fmt::Debug for RespItem<'a> {
+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ match self {
+ Self::A(arg0) => f.debug_tuple("A").field(arg0).finish(),
+ }
+ }
+}
diff --git a/tests/ui/traits/issue-52893.stderr b/tests/ui/traits/issue-52893.stderr
index a11867c03..db807a388 100644
--- a/tests/ui/traits/issue-52893.stderr
+++ b/tests/ui/traits/issue-52893.stderr
@@ -5,7 +5,7 @@ LL | impl<F, Name, P> AddClass<Name, F> for Class<P>
| - this type parameter
...
LL | builder.push(output);
- | ---- ^^^^^^ expected type parameter `F`, found struct `Class`
+ | ---- ^^^^^^ expected type parameter `F`, found `Class<P>`
| |
| arguments to this method are incorrect
|
@@ -18,7 +18,7 @@ LL | builder.push(output);
| ^^^^^^^^^^^^^------^
| |
| this argument influences the return type of `push`
-note: associated function defined here
+note: method defined here
--> $DIR/issue-52893.rs:11:8
|
LL | fn push(self, other: T) -> Self::PushRes;
diff --git a/tests/ui/traits/issue-68295.stderr b/tests/ui/traits/issue-68295.stderr
index cb6e6e076..671a97666 100644
--- a/tests/ui/traits/issue-68295.stderr
+++ b/tests/ui/traits/issue-68295.stderr
@@ -5,7 +5,7 @@ LL | fn crash<R, C>(input: Matrix<R, C, ()>) -> Matrix<R, C, u32>
| ----------------- expected `Matrix<R, C, u32>` because of return type
...
LL | input.into_owned()
- | ^^^^^^^^^^^^^^^^^^ expected `u32`, found associated type
+ | ^^^^^^^^^^^^^^^^^^ expected `Matrix<R, C, u32>`, found `Matrix<R, C, ...>`
|
= note: expected struct `Matrix<_, _, u32>`
found struct `Matrix<_, _, <() as Allocator<R, C>>::Buffer>`
diff --git a/tests/ui/traits/issue-77982.stderr b/tests/ui/traits/issue-77982.stderr
index 0b57a8212..d4fea05fe 100644
--- a/tests/ui/traits/issue-77982.stderr
+++ b/tests/ui/traits/issue-77982.stderr
@@ -4,7 +4,7 @@ error[E0283]: type annotations needed
LL | opts.get(opt.as_ref());
| ^^^ ------------ type must be known at this point
| |
- | cannot infer type of the type parameter `Q` declared on the associated function `get`
+ | cannot infer type of the type parameter `Q` declared on the method `get`
|
= note: multiple `impl`s satisfying `String: Borrow<_>` found in the following crates: `alloc`, `core`:
- impl Borrow<str> for String;
@@ -23,7 +23,7 @@ error[E0283]: type annotations needed
LL | opts.get(opt.as_ref());
| ^^^ ------ type must be known at this point
| |
- | cannot infer type of the type parameter `Q` declared on the associated function `get`
+ | cannot infer type of the type parameter `Q` declared on the method `get`
|
= note: multiple `impl`s satisfying `String: AsRef<_>` found in the following crates: `alloc`, `std`:
- impl AsRef<OsStr> for String;
@@ -43,7 +43,7 @@ LL | let ips: Vec<_> = (0..100_000).map(|_| u32::from(0u32.into())).collect(
| |
| required by a bound introduced by this call
|
- = note: multiple `impl`s satisfying `u32: From<_>` found in the following crates: `core`, `std`:
+ = note: multiple `impl`s satisfying `u32: From<_>` found in the `core` crate:
- impl From<Ipv4Addr> for u32;
- impl From<NonZeroU32> for u32;
- impl From<bool> for u32;
diff --git a/tests/ui/traits/item-privacy.rs b/tests/ui/traits/item-privacy.rs
index 38d06b967..a3e1a22e7 100644
--- a/tests/ui/traits/item-privacy.rs
+++ b/tests/ui/traits/item-privacy.rs
@@ -69,7 +69,7 @@ fn check_method() {
S.c(); // OK
// a, b, c are resolved as inherent items, their traits don't need to be in scope
let c = &S as &dyn C;
- c.a(); //~ ERROR associated function `a` is private
+ c.a(); //~ ERROR method `a` is private
c.b(); // OK
c.c(); // OK
@@ -81,7 +81,7 @@ fn check_method() {
//~^ ERROR no function or associated item named `b` found
S::c(&S); // OK
// a, b, c are resolved as inherent items, their traits don't need to be in scope
- <dyn C>::a(&S); //~ ERROR associated function `a` is private
+ <dyn C>::a(&S); //~ ERROR method `a` is private
<dyn C>::b(&S); // OK
C::c(&S); // OK
}
diff --git a/tests/ui/traits/item-privacy.stderr b/tests/ui/traits/item-privacy.stderr
index 293cfbda8..04995b3a1 100644
--- a/tests/ui/traits/item-privacy.stderr
+++ b/tests/ui/traits/item-privacy.stderr
@@ -32,14 +32,14 @@ help: the following trait is implemented but not in scope; perhaps add a `use` f
LL | use method::B;
|
-error[E0624]: associated function `a` is private
+error[E0624]: method `a` is private
--> $DIR/item-privacy.rs:72:7
|
LL | fn a(&self) { }
- | ----------- private associated function defined here
+ | ----------- private method defined here
...
LL | c.a();
- | ^ private associated function
+ | ^ private method
error[E0599]: no function or associated item named `a` found for struct `S` in the current scope
--> $DIR/item-privacy.rs:78:8
@@ -72,14 +72,14 @@ help: the following trait is implemented but not in scope; perhaps add a `use` f
LL | use method::B;
|
-error[E0624]: associated function `a` is private
+error[E0624]: method `a` is private
--> $DIR/item-privacy.rs:84:14
|
LL | fn a(&self) { }
- | ----------- private associated function defined here
+ | ----------- private method defined here
...
LL | <dyn C>::a(&S);
- | ^ private associated function
+ | ^ private method
error[E0599]: no associated item named `A` found for struct `S` in the current scope
--> $DIR/item-privacy.rs:97:8
diff --git a/tests/ui/traits/method-private.stderr b/tests/ui/traits/method-private.stderr
index 8e991ec01..55656f21e 100644
--- a/tests/ui/traits/method-private.stderr
+++ b/tests/ui/traits/method-private.stderr
@@ -1,11 +1,11 @@
-error[E0624]: associated function `method` is private
+error[E0624]: method `method` is private
--> $DIR/method-private.rs:19:9
|
LL | fn method(&self) {}
- | ---------------- private associated function defined here
+ | ---------------- private method defined here
...
LL | foo.method();
- | ^^^^^^ private associated function
+ | ^^^^^^ private method
|
= help: items from traits can only be used if the trait is in scope
help: the following trait is implemented but not in scope; perhaps add a `use` for it:
diff --git a/tests/ui/traits/multidispatch-convert-ambig-dest.stderr b/tests/ui/traits/multidispatch-convert-ambig-dest.stderr
index 6e6172eea..e927f26e9 100644
--- a/tests/ui/traits/multidispatch-convert-ambig-dest.stderr
+++ b/tests/ui/traits/multidispatch-convert-ambig-dest.stderr
@@ -29,7 +29,7 @@ note: required by a bound in `test`
--> $DIR/multidispatch-convert-ambig-dest.rs:21:11
|
LL | fn test<T,U>(_: T, _: U)
- | ---- required by a bound in this
+ | ---- required by a bound in this function
LL | where T : Convert<U>
| ^^^^^^^^^^ required by this bound in `test`
help: consider specifying the generic arguments
diff --git a/tests/ui/traits/negative-impls/negated-auto-traits-error.stderr b/tests/ui/traits/negative-impls/negated-auto-traits-error.stderr
index ce690b749..b680ce7f9 100644
--- a/tests/ui/traits/negative-impls/negated-auto-traits-error.stderr
+++ b/tests/ui/traits/negative-impls/negated-auto-traits-error.stderr
@@ -101,10 +101,10 @@ LL | fn is_send<T: Send>(_: T) {}
| ^^^^ required by this bound in `is_send`
error[E0277]: `main::TestType` cannot be sent between threads safely
- --> $DIR/negated-auto-traits-error.rs:66:13
+ --> $DIR/negated-auto-traits-error.rs:66:20
|
LL | is_sync(Outer2(TestType));
- | ------- ^^^^^^^^^^^^^^^^ `main::TestType` cannot be sent between threads safely
+ | ------- ^^^^^^^^ `main::TestType` cannot be sent between threads safely
| |
| required by a bound introduced by this call
|
diff --git a/tests/ui/traits/negative-impls/no-items.stderr b/tests/ui/traits/negative-impls/no-items.stderr
index 67b94bba1..040d9d145 100644
--- a/tests/ui/traits/negative-impls/no-items.stderr
+++ b/tests/ui/traits/negative-impls/no-items.stderr
@@ -2,7 +2,7 @@ error[E0749]: negative impls cannot have any items
--> $DIR/no-items.rs:8:5
|
LL | type Foo = i32;
- | ^^^^^^^^^^^^^^^
+ | ^^^^^^^^
error: aborting due to previous error
diff --git a/tests/ui/traits/new-solver/alias_eq_cant_be_furthur_normalized.rs b/tests/ui/traits/new-solver/alias_eq_cant_be_furthur_normalized.rs
new file mode 100644
index 000000000..dc726ba51
--- /dev/null
+++ b/tests/ui/traits/new-solver/alias_eq_cant_be_furthur_normalized.rs
@@ -0,0 +1,29 @@
+// check-pass
+// compile-flags: -Ztrait-solver=next
+
+// check that a goal such as `alias-eq(<T as TraitB>::Assoc<bool>, <T as TraitB>::Assoc<?0>)`
+// succeeds with a constraint that `?0 = bool`
+
+// FIXME(deferred_projection_equality): add a test that this is true during coherence
+
+trait TraitA {}
+
+trait TraitB {
+ type Assoc<T: ?Sized>;
+}
+
+impl<T: TraitB> TraitA for (T, T::Assoc<bool>) {}
+
+impl TraitB for i32 {
+ type Assoc<T: ?Sized> = u32;
+}
+
+fn needs_a<T: TraitA>() {}
+
+fn bar<T: TraitB>() {
+ needs_a::<(T, <T as TraitB>::Assoc<_>)>();
+}
+
+fn main() {
+ bar::<i32>();
+}
diff --git a/tests/ui/traits/new-solver/alias_eq_dont_use_normalizes_to_if_substs_eq.rs b/tests/ui/traits/new-solver/alias_eq_dont_use_normalizes_to_if_substs_eq.rs
new file mode 100644
index 000000000..fd5d0e3b1
--- /dev/null
+++ b/tests/ui/traits/new-solver/alias_eq_dont_use_normalizes_to_if_substs_eq.rs
@@ -0,0 +1,45 @@
+// compile-flags: -Ztrait-solver=next
+
+// check that when computing `alias-eq(<() as Foo<u16, T>>::Assoc, <() as Foo<?0, T>>::Assoc)`
+// we do not infer `?0 = u8` via the `for<STOP> (): Foo<u8, STOP>` impl or `?0 = u16` by
+// relating substs as either could be a valid solution.
+
+trait Foo<T, STOP> {
+ type Assoc;
+}
+
+impl<STOP> Foo<u8, STOP> for ()
+where
+ (): Foo<u16, STOP>,
+{
+ type Assoc = <() as Foo<u16, STOP>>::Assoc;
+}
+
+impl Foo<u16, i8> for () {
+ type Assoc = u8;
+}
+
+impl Foo<u16, i16> for () {
+ type Assoc = u16;
+}
+
+fn output<T, U>() -> <() as Foo<T, U>>::Assoc
+where
+ (): Foo<T, U>,
+{
+ todo!()
+}
+
+fn incomplete<T>()
+where
+ (): Foo<u16, T>,
+{
+ // `<() as Foo<u16, STOP>>::Assoc == <() as Foo<_, STOP>>::Assoc`
+ let _: <() as Foo<u16, T>>::Assoc = output::<_, T>();
+ //~^ error: type annotations needed
+
+ // let _: <() as Foo<u16, T>>::Assoc = output::<u8, T>(); // OK
+ // let _: <() as Foo<u16, T>>::Assoc = output::<u16, T>(); // OK
+}
+
+fn main() {}
diff --git a/tests/ui/traits/new-solver/alias_eq_dont_use_normalizes_to_if_substs_eq.stderr b/tests/ui/traits/new-solver/alias_eq_dont_use_normalizes_to_if_substs_eq.stderr
new file mode 100644
index 000000000..a6712332c
--- /dev/null
+++ b/tests/ui/traits/new-solver/alias_eq_dont_use_normalizes_to_if_substs_eq.stderr
@@ -0,0 +1,9 @@
+error[E0282]: type annotations needed
+ --> $DIR/alias_eq_dont_use_normalizes_to_if_substs_eq.rs:38:41
+ |
+LL | let _: <() as Foo<u16, T>>::Assoc = output::<_, T>();
+ | ^^^^^^^^^^^^^^ cannot infer type of the type parameter `T` declared on the function `output`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0282`.
diff --git a/tests/ui/traits/new-solver/alias_eq_simple.rs b/tests/ui/traits/new-solver/alias_eq_simple.rs
new file mode 100644
index 000000000..6792cf3ce
--- /dev/null
+++ b/tests/ui/traits/new-solver/alias_eq_simple.rs
@@ -0,0 +1,22 @@
+// check-pass
+// compile-flags: -Ztrait-solver=next
+
+// test that the new solver can handle `alias-eq(<i32 as TraitB>::Assoc, u32)`
+
+trait TraitA {}
+
+trait TraitB {
+ type Assoc;
+}
+
+impl<T: TraitB> TraitA for (T, T::Assoc) {}
+
+impl TraitB for i32 {
+ type Assoc = u32;
+}
+
+fn needs_a<T: TraitA>() {}
+
+fn main() {
+ needs_a::<(i32, u32)>();
+}
diff --git a/tests/ui/traits/new-solver/alias_eq_substs_eq_not_intercrate.rs b/tests/ui/traits/new-solver/alias_eq_substs_eq_not_intercrate.rs
new file mode 100644
index 000000000..d4cc380fa
--- /dev/null
+++ b/tests/ui/traits/new-solver/alias_eq_substs_eq_not_intercrate.rs
@@ -0,0 +1,20 @@
+// compile-flags: -Ztrait-solver=next
+
+// check that a `alias-eq(<?0 as TraitB>::Assoc, <T as TraitB>::Assoc)` goal fails.
+
+// FIXME(deferred_projection_equality): add a test that this is true during coherence
+
+trait TraitB {
+ type Assoc;
+}
+
+fn needs_a<T: TraitB>() -> T::Assoc {
+ unimplemented!()
+}
+
+fn bar<T: TraitB>() {
+ let _: <_ as TraitB>::Assoc = needs_a::<T>();
+ //~^ error: type annotations needed
+}
+
+fn main() {}
diff --git a/tests/ui/traits/new-solver/alias_eq_substs_eq_not_intercrate.stderr b/tests/ui/traits/new-solver/alias_eq_substs_eq_not_intercrate.stderr
new file mode 100644
index 000000000..d063d8fce
--- /dev/null
+++ b/tests/ui/traits/new-solver/alias_eq_substs_eq_not_intercrate.stderr
@@ -0,0 +1,9 @@
+error[E0282]: type annotations needed
+ --> $DIR/alias_eq_substs_eq_not_intercrate.rs:16:12
+ |
+LL | let _: <_ as TraitB>::Assoc = needs_a::<T>();
+ | ^^^^^^^^^^^^^^^^^^^^ cannot infer type for associated type `<_ as TraitB>::Assoc`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0282`.
diff --git a/tests/ui/traits/new-solver/async.fail.stderr b/tests/ui/traits/new-solver/async.fail.stderr
new file mode 100644
index 000000000..b395c23ae
--- /dev/null
+++ b/tests/ui/traits/new-solver/async.fail.stderr
@@ -0,0 +1,17 @@
+error[E0271]: expected `[async block@$DIR/async.rs:12:17: 12:25]` to be a future that resolves to `i32`, but it resolves to `()`
+ --> $DIR/async.rs:12:17
+ |
+LL | needs_async(async {});
+ | ----------- ^^^^^^^^ expected `i32`, found `()`
+ | |
+ | required by a bound introduced by this call
+ |
+note: required by a bound in `needs_async`
+ --> $DIR/async.rs:8:31
+ |
+LL | fn needs_async(_: impl Future<Output = i32>) {}
+ | ^^^^^^^^^^^^ required by this bound in `needs_async`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0271`.
diff --git a/tests/ui/traits/new-solver/async.rs b/tests/ui/traits/new-solver/async.rs
new file mode 100644
index 000000000..195cc35ca
--- /dev/null
+++ b/tests/ui/traits/new-solver/async.rs
@@ -0,0 +1,19 @@
+// compile-flags: -Ztrait-solver=next
+// edition: 2021
+// revisions: pass fail
+//[pass] check-pass
+
+use std::future::Future;
+
+fn needs_async(_: impl Future<Output = i32>) {}
+
+#[cfg(fail)]
+fn main() {
+ needs_async(async {});
+ //[fail]~^ ERROR to be a future that resolves to `i32`, but it resolves to `()`
+}
+
+#[cfg(pass)]
+fn main() {
+ needs_async(async { 1i32 });
+}
diff --git a/tests/ui/traits/new-solver/builtin-fn-must-return-sized.rs b/tests/ui/traits/new-solver/builtin-fn-must-return-sized.rs
new file mode 100644
index 000000000..ba473653e
--- /dev/null
+++ b/tests/ui/traits/new-solver/builtin-fn-must-return-sized.rs
@@ -0,0 +1,17 @@
+// compile-flags: -Ztrait-solver=next
+
+#![feature(fn_traits)]
+#![feature(unboxed_closures)]
+#![feature(tuple_trait)]
+
+use std::ops::Fn;
+use std::marker::Tuple;
+
+fn foo<F: Fn<T>, T: Tuple>(f: Option<F>, t: T) {
+ let y = (f.unwrap()).call(t);
+}
+
+fn main() {
+ foo::<fn() -> str, _>(None, ());
+ //~^ expected a `Fn<_>` closure, found `fn() -> str`
+}
diff --git a/tests/ui/traits/new-solver/builtin-fn-must-return-sized.stderr b/tests/ui/traits/new-solver/builtin-fn-must-return-sized.stderr
new file mode 100644
index 000000000..f7551739b
--- /dev/null
+++ b/tests/ui/traits/new-solver/builtin-fn-must-return-sized.stderr
@@ -0,0 +1,18 @@
+error[E0277]: expected a `Fn<_>` closure, found `fn() -> str`
+ --> $DIR/builtin-fn-must-return-sized.rs:15:27
+ |
+LL | foo::<fn() -> str, _>(None, ());
+ | --------------------- ^^^^ expected an `Fn<_>` closure, found `fn() -> str`
+ | |
+ | required by a bound introduced by this call
+ |
+ = help: the trait `Fn<_>` is not implemented for `fn() -> str`
+note: required by a bound in `foo`
+ --> $DIR/builtin-fn-must-return-sized.rs:10:11
+ |
+LL | fn foo<F: Fn<T>, T: Tuple>(f: Option<F>, t: T) {
+ | ^^^^^ required by this bound in `foo`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/traits/new-solver/elaborate-item-bounds.rs b/tests/ui/traits/new-solver/elaborate-item-bounds.rs
new file mode 100644
index 000000000..076aefcf8
--- /dev/null
+++ b/tests/ui/traits/new-solver/elaborate-item-bounds.rs
@@ -0,0 +1,12 @@
+// compile-flags: -Ztrait-solver=next
+// check-pass
+
+trait Foo {
+ type Bar: Bar;
+}
+
+trait Bar: Baz {}
+
+trait Baz {}
+
+fn main() {}
diff --git a/tests/ui/traits/new-solver/fn-trait-closure.rs b/tests/ui/traits/new-solver/fn-trait-closure.rs
index c0ecf1c91..bd65737ee 100644
--- a/tests/ui/traits/new-solver/fn-trait-closure.rs
+++ b/tests/ui/traits/new-solver/fn-trait-closure.rs
@@ -1,12 +1,5 @@
// compile-flags: -Ztrait-solver=next
-// known-bug: unknown
-// failure-status: 101
-// dont-check-compiler-stderr
-
-// This test will fail until we fix `FulfillmentCtxt::relationships`. That's
-// because we create a type variable for closure upvar types, which is not
-// constrained until after we try to do fallback on diverging type variables.
-// Thus, we will call that function, which is unimplemented.
+// check-pass
fn require_fn(_: impl Fn() -> i32) {}
diff --git a/tests/ui/traits/new-solver/generator.fail.stderr b/tests/ui/traits/new-solver/generator.fail.stderr
new file mode 100644
index 000000000..d94d41e35
--- /dev/null
+++ b/tests/ui/traits/new-solver/generator.fail.stderr
@@ -0,0 +1,64 @@
+error[E0277]: the trait bound `[generator@$DIR/generator.rs:18:21: 18:23]: Generator<A>` is not satisfied
+ --> $DIR/generator.rs:18:21
+ |
+LL | needs_generator(|| {
+ | _____---------------_^
+ | | |
+ | | required by a bound introduced by this call
+LL | |
+LL | |
+LL | |
+LL | | yield ();
+LL | | });
+ | |_____^ the trait `Generator<A>` is not implemented for `[generator@$DIR/generator.rs:18:21: 18:23]`
+ |
+note: required by a bound in `needs_generator`
+ --> $DIR/generator.rs:14:28
+ |
+LL | fn needs_generator(_: impl Generator<A, Yield = B, Return = C>) {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `needs_generator`
+
+error[E0271]: type mismatch resolving `<[generator@$DIR/generator.rs:18:21: 18:23] as Generator<A>>::Yield == B`
+ --> $DIR/generator.rs:18:21
+ |
+LL | needs_generator(|| {
+ | _____---------------_^
+ | | |
+ | | required by a bound introduced by this call
+LL | |
+LL | |
+LL | |
+LL | | yield ();
+LL | | });
+ | |_____^ types differ
+ |
+note: required by a bound in `needs_generator`
+ --> $DIR/generator.rs:14:41
+ |
+LL | fn needs_generator(_: impl Generator<A, Yield = B, Return = C>) {}
+ | ^^^^^^^^^ required by this bound in `needs_generator`
+
+error[E0271]: type mismatch resolving `<[generator@$DIR/generator.rs:18:21: 18:23] as Generator<A>>::Return == C`
+ --> $DIR/generator.rs:18:21
+ |
+LL | needs_generator(|| {
+ | _____---------------_^
+ | | |
+ | | required by a bound introduced by this call
+LL | |
+LL | |
+LL | |
+LL | | yield ();
+LL | | });
+ | |_____^ types differ
+ |
+note: required by a bound in `needs_generator`
+ --> $DIR/generator.rs:14:52
+ |
+LL | fn needs_generator(_: impl Generator<A, Yield = B, Return = C>) {}
+ | ^^^^^^^^^^ required by this bound in `needs_generator`
+
+error: aborting due to 3 previous errors
+
+Some errors have detailed explanations: E0271, E0277.
+For more information about an error, try `rustc --explain E0271`.
diff --git a/tests/ui/traits/new-solver/generator.rs b/tests/ui/traits/new-solver/generator.rs
new file mode 100644
index 000000000..364373ca8
--- /dev/null
+++ b/tests/ui/traits/new-solver/generator.rs
@@ -0,0 +1,32 @@
+// compile-flags: -Ztrait-solver=next
+// edition: 2021
+// revisions: pass fail
+//[pass] check-pass
+
+#![feature(generator_trait, generators)]
+
+use std::ops::Generator;
+
+struct A;
+struct B;
+struct C;
+
+fn needs_generator(_: impl Generator<A, Yield = B, Return = C>) {}
+
+#[cfg(fail)]
+fn main() {
+ needs_generator(|| {
+ //[fail]~^ ERROR Generator<A>` is not satisfied
+ //[fail]~| ERROR as Generator<A>>::Yield == B`
+ //[fail]~| ERROR as Generator<A>>::Return == C`
+ yield ();
+ });
+}
+
+#[cfg(pass)]
+fn main() {
+ needs_generator(|_: A| {
+ let _: A = yield B;
+ C
+ })
+}
diff --git a/tests/ui/traits/new-solver/higher-ranked-dyn-bounds.rs b/tests/ui/traits/new-solver/higher-ranked-dyn-bounds.rs
new file mode 100644
index 000000000..c886aeeda
--- /dev/null
+++ b/tests/ui/traits/new-solver/higher-ranked-dyn-bounds.rs
@@ -0,0 +1,17 @@
+// compile-flags: -Ztrait-solver=next
+// check-pass
+
+trait Trait<'a> {
+ type Item: for<'b> Trait2<'b>;
+}
+
+trait Trait2<'a> {}
+impl Trait2<'_> for () {}
+
+fn needs_trait(_: Box<impl for<'a> Trait<'a> + ?Sized>) {}
+
+fn foo(x: Box<dyn for<'a> Trait<'a, Item = ()>>) {
+ needs_trait(x);
+}
+
+fn main() {}
diff --git a/tests/ui/traits/new-solver/more-object-bound.rs b/tests/ui/traits/new-solver/more-object-bound.rs
new file mode 100644
index 000000000..712759ef0
--- /dev/null
+++ b/tests/ui/traits/new-solver/more-object-bound.rs
@@ -0,0 +1,27 @@
+// compile-flags: -Ztrait-solver=next
+// From #80800
+
+trait SuperTrait {
+ type A;
+ type B;
+}
+
+trait Trait: SuperTrait<A = <Self as SuperTrait>::B> {}
+
+fn transmute<A, B>(x: A) -> B {
+ foo::<A, B, dyn Trait<A = A, B = B>>(x)
+ //~^ ERROR type annotations needed: cannot satisfy `dyn Trait<A = A, B = B>: Trait`
+}
+
+fn foo<A, B, T: ?Sized>(x: T::A) -> B
+where
+ T: Trait<B = B>,
+{
+ x
+}
+
+static X: u8 = 0;
+fn main() {
+ let x = transmute::<&u8, &[u8; 1_000_000]>(&X);
+ println!("{:?}", x[100_000]);
+}
diff --git a/tests/ui/traits/new-solver/more-object-bound.stderr b/tests/ui/traits/new-solver/more-object-bound.stderr
new file mode 100644
index 000000000..208fdecb0
--- /dev/null
+++ b/tests/ui/traits/new-solver/more-object-bound.stderr
@@ -0,0 +1,19 @@
+error[E0283]: type annotations needed: cannot satisfy `dyn Trait<A = A, B = B>: Trait`
+ --> $DIR/more-object-bound.rs:12:5
+ |
+LL | foo::<A, B, dyn Trait<A = A, B = B>>(x)
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: cannot satisfy `dyn Trait<A = A, B = B>: Trait`
+note: required by a bound in `foo`
+ --> $DIR/more-object-bound.rs:18:8
+ |
+LL | fn foo<A, B, T: ?Sized>(x: T::A) -> B
+ | --- required by a bound in this function
+LL | where
+LL | T: Trait<B = B>,
+ | ^^^^^^^^^^^^ required by this bound in `foo`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0283`.
diff --git a/tests/ui/traits/new-solver/normalizes_to_ignores_unnormalizable_candidate.rs b/tests/ui/traits/new-solver/normalizes_to_ignores_unnormalizable_candidate.rs
new file mode 100644
index 000000000..46343241b
--- /dev/null
+++ b/tests/ui/traits/new-solver/normalizes_to_ignores_unnormalizable_candidate.rs
@@ -0,0 +1,40 @@
+// [no_self_infer] check-pass
+// compile-flags: -Ztrait-solver=next
+// revisions: self_infer no_self_infer
+
+// checks that the new solver is smart enough to infer `?0 = U` when solving:
+// `normalizes-to(<Vec<?0> as Trait>::Assoc, u8)`
+// with `normalizes-to(<Vec<U> as Trait>::Assoc, u8)` in the paramenv even when
+// there is a separate `Vec<T>: Trait` bound in the paramenv.
+//
+// FIXME(-Ztrait-solver=next)
+// This could also compile for `normalizes-to(<?0 as Trait>::Assoc, u8)` but
+// we currently immediately consider a goal ambiguous if the self type is an
+// inference variable.
+
+trait Trait {
+ type Assoc;
+}
+
+fn foo<T: Trait<Assoc = u8>>(x: T) {}
+
+#[cfg(self_infer)]
+fn unconstrained<T>() -> T {
+ todo!()
+}
+
+#[cfg(no_self_infer)]
+fn unconstrained<T>() -> Vec<T> {
+ todo!()
+}
+
+fn bar<T, U>()
+where
+ Vec<T>: Trait,
+ Vec<U>: Trait<Assoc = u8>,
+{
+ foo(unconstrained())
+ //[self_infer]~^ ERROR type annotations needed
+}
+
+fn main() {}
diff --git a/tests/ui/traits/new-solver/normalizes_to_ignores_unnormalizable_candidate.self_infer.stderr b/tests/ui/traits/new-solver/normalizes_to_ignores_unnormalizable_candidate.self_infer.stderr
new file mode 100644
index 000000000..062832012
--- /dev/null
+++ b/tests/ui/traits/new-solver/normalizes_to_ignores_unnormalizable_candidate.self_infer.stderr
@@ -0,0 +1,14 @@
+error[E0282]: type annotations needed
+ --> $DIR/normalizes_to_ignores_unnormalizable_candidate.rs:36:5
+ |
+LL | foo(unconstrained())
+ | ^^^ cannot infer type of the type parameter `T` declared on the function `foo`
+ |
+help: consider specifying the generic argument
+ |
+LL | foo::<T>(unconstrained())
+ | +++++
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0282`.
diff --git a/tests/ui/traits/new-solver/object-unsafety.rs b/tests/ui/traits/new-solver/object-unsafety.rs
new file mode 100644
index 000000000..7bdd863a7
--- /dev/null
+++ b/tests/ui/traits/new-solver/object-unsafety.rs
@@ -0,0 +1,20 @@
+// compile-flags: -Ztrait-solver=next
+
+trait Setup {
+ type From: Copy;
+}
+
+fn copy<U: Setup + ?Sized>(from: &U::From) -> U::From {
+ *from
+}
+
+pub fn copy_any<T>(t: &T) -> T {
+ copy::<dyn Setup<From=T>>(t)
+ //~^ ERROR the trait bound `dyn Setup<From = T>: Setup` is not satisfied
+}
+
+fn main() {
+ let x = String::from("Hello, world");
+ let y = copy_any(&x);
+ println!("{y}");
+}
diff --git a/tests/ui/traits/new-solver/object-unsafety.stderr b/tests/ui/traits/new-solver/object-unsafety.stderr
new file mode 100644
index 000000000..198ac623d
--- /dev/null
+++ b/tests/ui/traits/new-solver/object-unsafety.stderr
@@ -0,0 +1,19 @@
+error[E0277]: the trait bound `dyn Setup<From = T>: Setup` is not satisfied
+ --> $DIR/object-unsafety.rs:12:12
+ |
+LL | copy::<dyn Setup<From=T>>(t)
+ | ^^^^^^^^^^^^^^^^^ the trait `Setup` is not implemented for `dyn Setup<From = T>`
+ |
+note: required by a bound in `copy`
+ --> $DIR/object-unsafety.rs:7:12
+ |
+LL | fn copy<U: Setup + ?Sized>(from: &U::From) -> U::From {
+ | ^^^^^ required by this bound in `copy`
+help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement
+ |
+LL | pub fn copy_any<T>(t: &T) -> T where dyn Setup<From = T>: Setup {
+ | ++++++++++++++++++++++++++++++++
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/traits/new-solver/param-candidate-doesnt-shadow-project.rs b/tests/ui/traits/new-solver/param-candidate-doesnt-shadow-project.rs
new file mode 100644
index 000000000..bdf999ec5
--- /dev/null
+++ b/tests/ui/traits/new-solver/param-candidate-doesnt-shadow-project.rs
@@ -0,0 +1,25 @@
+// compile-flags: -Ztrait-solver=next
+// check-pass
+
+trait Foo {
+ type Assoc;
+}
+
+trait Bar {}
+
+impl<T> Foo for T {
+ type Assoc = i32;
+}
+
+impl<T> Bar for T where T: Foo<Assoc = i32> {}
+
+fn require_bar<T: Bar>() {}
+
+fn foo<T: Foo>() {
+ // Unlike the classic solver, `<T as Foo>::Assoc = _` will still project
+ // down to `i32` even though there's a param-env candidate here, since we
+ // don't assemble any param-env projection candidates for `T: Foo` alone.
+ require_bar::<T>();
+}
+
+fn main() {}
diff --git a/tests/ui/traits/new-solver/pointee.rs b/tests/ui/traits/new-solver/pointee.rs
new file mode 100644
index 000000000..fa6ee2e2d
--- /dev/null
+++ b/tests/ui/traits/new-solver/pointee.rs
@@ -0,0 +1,23 @@
+// compile-flags: -Ztrait-solver=next
+// check-pass
+#![feature(ptr_metadata)]
+
+use std::ptr::{DynMetadata, Pointee};
+
+trait Trait<U> {}
+struct MyDst<T: ?Sized>(T);
+
+fn works<T>() {
+ let _: <T as Pointee>::Metadata = ();
+ let _: <[T] as Pointee>::Metadata = 1_usize;
+ let _: <str as Pointee>::Metadata = 1_usize;
+ let _: <dyn Trait<T> as Pointee>::Metadata = give::<DynMetadata<dyn Trait<T>>>();
+ let _: <MyDst<T> as Pointee>::Metadata = ();
+ let _: <((((([u8],),),),),) as Pointee>::Metadata = 1_usize;
+}
+
+fn give<U>() -> U {
+ loop {}
+}
+
+fn main() {}
diff --git a/tests/ui/traits/new-solver/pointer-like.rs b/tests/ui/traits/new-solver/pointer-like.rs
new file mode 100644
index 000000000..3745a075e
--- /dev/null
+++ b/tests/ui/traits/new-solver/pointer-like.rs
@@ -0,0 +1,14 @@
+// compile-flags: -Ztrait-solver=next
+
+#![feature(pointer_like_trait)]
+
+use std::marker::PointerLike;
+
+fn require_(_: impl PointerLike) {}
+
+fn main() {
+ require_(1usize);
+ require_(1u16);
+ //~^ ERROR `u16` needs to have the same alignment and size as a pointer
+ require_(&1i16);
+}
diff --git a/tests/ui/traits/new-solver/pointer-like.stderr b/tests/ui/traits/new-solver/pointer-like.stderr
new file mode 100644
index 000000000..f695e6418
--- /dev/null
+++ b/tests/ui/traits/new-solver/pointer-like.stderr
@@ -0,0 +1,24 @@
+error[E0277]: `u16` needs to have the same alignment and size as a pointer
+ --> $DIR/pointer-like.rs:11:14
+ |
+LL | require_(1u16);
+ | -------- ^^^^ the trait `PointerLike` is not implemented for `u16`
+ | |
+ | required by a bound introduced by this call
+ |
+ = note: the trait bound `u16: PointerLike` is not satisfied
+note: required by a bound in `require_`
+ --> $DIR/pointer-like.rs:7:21
+ |
+LL | fn require_(_: impl PointerLike) {}
+ | ^^^^^^^^^^^ required by this bound in `require_`
+help: consider borrowing here
+ |
+LL | require_(&1u16);
+ | +
+LL | require_(&mut 1u16);
+ | ++++
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/traits/new-solver/pointer-sized.rs b/tests/ui/traits/new-solver/pointer-sized.rs
deleted file mode 100644
index 15681cd13..000000000
--- a/tests/ui/traits/new-solver/pointer-sized.rs
+++ /dev/null
@@ -1,12 +0,0 @@
-#![feature(pointer_sized_trait)]
-
-use std::marker::PointerSized;
-
-fn require_pointer_sized(_: impl PointerSized) {}
-
-fn main() {
- require_pointer_sized(1usize);
- require_pointer_sized(1u16);
- //~^ ERROR `u16` needs to be a pointer-sized type
- require_pointer_sized(&1i16);
-}
diff --git a/tests/ui/traits/new-solver/pointer-sized.stderr b/tests/ui/traits/new-solver/pointer-sized.stderr
deleted file mode 100644
index b250b1331..000000000
--- a/tests/ui/traits/new-solver/pointer-sized.stderr
+++ /dev/null
@@ -1,24 +0,0 @@
-error[E0277]: `u16` needs to be a pointer-sized type
- --> $DIR/pointer-sized.rs:9:27
- |
-LL | require_pointer_sized(1u16);
- | --------------------- ^^^^ the trait `PointerSized` is not implemented for `u16`
- | |
- | required by a bound introduced by this call
- |
- = note: the trait bound `u16: PointerSized` is not satisfied
-note: required by a bound in `require_pointer_sized`
- --> $DIR/pointer-sized.rs:5:34
- |
-LL | fn require_pointer_sized(_: impl PointerSized) {}
- | ^^^^^^^^^^^^ required by this bound in `require_pointer_sized`
-help: consider borrowing here
- |
-LL | require_pointer_sized(&1u16);
- | +
-LL | require_pointer_sized(&mut 1u16);
- | ++++
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/traits/new-solver/provisional-result-done.rs b/tests/ui/traits/new-solver/provisional-result-done.rs
new file mode 100644
index 000000000..589d34dd7
--- /dev/null
+++ b/tests/ui/traits/new-solver/provisional-result-done.rs
@@ -0,0 +1,33 @@
+// compile-flags: -Ztrait-solver=next
+// check-pass
+
+// This tests checks that we update results in the provisional cache when
+// we pop a goal from the stack.
+#![feature(auto_traits)]
+auto trait Coinductive {}
+struct Foo<T>(T);
+struct Bar<T>(T);
+
+impl<T> Coinductive for Foo<T>
+where
+ Bar<T>: Coinductive
+{}
+
+impl<T> Coinductive for Bar<T>
+where
+ Foo<T>: Coinductive,
+ Bar<T>: ConstrainInfer,
+{}
+
+trait ConstrainInfer {}
+impl ConstrainInfer for Bar<u8> {}
+impl ConstrainInfer for Foo<u16> {}
+
+fn impls<T: Coinductive>() -> T { todo!() }
+
+fn constrain<T: ConstrainInfer>(_: T) {}
+
+fn main() {
+ // This should constrain `_` to `u8`.
+ impls::<Foo<_>>();
+}
diff --git a/tests/ui/traits/new-solver/temporary-ambiguity.rs b/tests/ui/traits/new-solver/temporary-ambiguity.rs
new file mode 100644
index 000000000..18ee05457
--- /dev/null
+++ b/tests/ui/traits/new-solver/temporary-ambiguity.rs
@@ -0,0 +1,22 @@
+// compile-flags: -Ztrait-solver=next
+// check-pass
+
+// Checks that we don't explode when we assemble >1 candidate for a goal.
+
+struct Wrapper<T>(T);
+
+trait Foo {}
+
+impl Foo for Wrapper<i32> {}
+
+impl Foo for Wrapper<()> {}
+
+fn needs_foo(_: impl Foo) {}
+
+fn main() {
+ let mut x = Default::default();
+ let w = Wrapper(x);
+ needs_foo(w);
+ x = 1;
+ drop(x);
+}
diff --git a/tests/ui/traits/new-solver/try-example.rs b/tests/ui/traits/new-solver/try-example.rs
new file mode 100644
index 000000000..e826f3a00
--- /dev/null
+++ b/tests/ui/traits/new-solver/try-example.rs
@@ -0,0 +1,28 @@
+// check-pass
+// compile-flags: -Ztrait-solver=next
+
+use std::error::Error;
+
+fn main() -> Result<(), Box<dyn Error>> {
+ let x: i32 = parse()?;
+ Ok(())
+}
+
+trait Parse {}
+
+impl Parse for i32 {}
+
+#[derive(Debug)]
+struct ParseError;
+
+impl std::fmt::Display for ParseError {
+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ write!(f, "ParseError")
+ }
+}
+
+impl Error for ParseError {}
+
+fn parse<T: Parse>() -> Result<T, ParseError> {
+ todo!()
+}
diff --git a/tests/ui/traits/new-solver/two-projection-param-candidates-are-ambiguous.rs b/tests/ui/traits/new-solver/two-projection-param-candidates-are-ambiguous.rs
new file mode 100644
index 000000000..cde2059ca
--- /dev/null
+++ b/tests/ui/traits/new-solver/two-projection-param-candidates-are-ambiguous.rs
@@ -0,0 +1,30 @@
+// compile-flags: -Ztrait-solver=next
+
+// When we're solving `<T as Foo>::Assoc = i32`, we actually first solve
+// `<T as Foo>::Assoc = _#1t`, then unify `_#1t` with `i32`. That goal
+// with the inference variable is ambiguous when there are >1 param-env
+// candidates.
+
+// We don't unify the RHS of a projection goal eagerly when solving, both
+// for caching reasons and partly to make sure that we don't make the new
+// trait solver smarter than it should be.
+
+// This is (as far as I can tell) a forwards-compatible decision, but if you
+// make this test go from fail to pass, be sure you understand the implications!
+
+trait Foo {
+ type Assoc;
+}
+
+trait Bar {}
+
+impl<T> Bar for T where T: Foo<Assoc = i32> {}
+
+fn needs_bar<T: Bar>() {}
+
+fn foo<T: Foo<Assoc = i32> + Foo<Assoc = u32>>() {
+ needs_bar::<T>();
+ //~^ ERROR type annotations needed: cannot satisfy `T: Bar`
+}
+
+fn main() {}
diff --git a/tests/ui/traits/new-solver/two-projection-param-candidates-are-ambiguous.stderr b/tests/ui/traits/new-solver/two-projection-param-candidates-are-ambiguous.stderr
new file mode 100644
index 000000000..fa5e780ee
--- /dev/null
+++ b/tests/ui/traits/new-solver/two-projection-param-candidates-are-ambiguous.stderr
@@ -0,0 +1,16 @@
+error[E0283]: type annotations needed: cannot satisfy `T: Bar`
+ --> $DIR/two-projection-param-candidates-are-ambiguous.rs:26:5
+ |
+LL | needs_bar::<T>();
+ | ^^^^^^^^^^^^^^
+ |
+ = note: cannot satisfy `T: Bar`
+note: required by a bound in `needs_bar`
+ --> $DIR/two-projection-param-candidates-are-ambiguous.rs:23:17
+ |
+LL | fn needs_bar<T: Bar>() {}
+ | ^^^ required by this bound in `needs_bar`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0283`.
diff --git a/tests/ui/traits/new-solver/unsafe-auto-trait-impl.rs b/tests/ui/traits/new-solver/unsafe-auto-trait-impl.rs
new file mode 100644
index 000000000..bcfc747eb
--- /dev/null
+++ b/tests/ui/traits/new-solver/unsafe-auto-trait-impl.rs
@@ -0,0 +1,8 @@
+// compile-flags: -Ztrait-solver=next
+// check-pass
+
+struct Foo(*mut ());
+
+unsafe impl Sync for Foo {}
+
+fn main() {}
diff --git a/tests/ui/traits/new-solver/unsize-good.rs b/tests/ui/traits/new-solver/unsize-good.rs
new file mode 100644
index 000000000..87ed9cfd1
--- /dev/null
+++ b/tests/ui/traits/new-solver/unsize-good.rs
@@ -0,0 +1,25 @@
+// compile-flags: -Ztrait-solver=next
+// check-pass
+
+#![feature(unsized_tuple_coercion)]
+
+trait Foo {}
+
+impl Foo for i32 {}
+
+fn main() {
+ // Unsizing via struct
+ let _: Box<dyn Foo> = Box::new(1i32);
+
+ // Slice unsizing
+ let y = [1, 2, 3];
+ let _: &[i32] = &y;
+
+ // Tuple unsizing
+ let hi = (1i32,);
+ let _: &(dyn Foo,) = &hi;
+
+ // Dropping auto traits
+ let a: &(dyn Foo + Send) = &1;
+ let _: &dyn Foo = a;
+}
diff --git a/tests/ui/traits/new-solver/upcast-right-substs.rs b/tests/ui/traits/new-solver/upcast-right-substs.rs
new file mode 100644
index 000000000..c19c82acf
--- /dev/null
+++ b/tests/ui/traits/new-solver/upcast-right-substs.rs
@@ -0,0 +1,14 @@
+// compile-flags: -Ztrait-solver=next
+// check-pass
+
+#![feature(trait_upcasting)]
+
+trait Foo: Bar<i32> + Bar<u32> {}
+
+trait Bar<T> {}
+
+fn main() {
+ let x: &dyn Foo = todo!();
+ let y: &dyn Bar<i32> = x;
+ let z: &dyn Bar<u32> = x;
+}
diff --git a/tests/ui/traits/new-solver/upcast-wrong-substs.rs b/tests/ui/traits/new-solver/upcast-wrong-substs.rs
new file mode 100644
index 000000000..f2d04d932
--- /dev/null
+++ b/tests/ui/traits/new-solver/upcast-wrong-substs.rs
@@ -0,0 +1,13 @@
+// compile-flags: -Ztrait-solver=next
+
+#![feature(trait_upcasting)]
+
+trait Foo: Bar<i32> + Bar<u32> {}
+
+trait Bar<T> {}
+
+fn main() {
+ let x: &dyn Foo = todo!();
+ let y: &dyn Bar<usize> = x;
+ //~^ ERROR mismatched types
+}
diff --git a/tests/ui/traits/new-solver/upcast-wrong-substs.stderr b/tests/ui/traits/new-solver/upcast-wrong-substs.stderr
new file mode 100644
index 000000000..8623f395f
--- /dev/null
+++ b/tests/ui/traits/new-solver/upcast-wrong-substs.stderr
@@ -0,0 +1,14 @@
+error[E0308]: mismatched types
+ --> $DIR/upcast-wrong-substs.rs:11:30
+ |
+LL | let y: &dyn Bar<usize> = x;
+ | --------------- ^ expected trait `Bar`, found trait `Foo`
+ | |
+ | expected due to this
+ |
+ = note: expected reference `&dyn Bar<usize>`
+ found reference `&dyn Foo`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0308`.
diff --git a/tests/ui/traits/non_lifetime_binders/bad-sized-cond.rs b/tests/ui/traits/non_lifetime_binders/bad-sized-cond.rs
new file mode 100644
index 000000000..dfc800c8e
--- /dev/null
+++ b/tests/ui/traits/non_lifetime_binders/bad-sized-cond.rs
@@ -0,0 +1,23 @@
+#![feature(non_lifetime_binders)]
+//~^ WARN is incomplete and may not be safe
+
+pub fn foo()
+where
+ for<V> V: Sized,
+{
+}
+
+pub fn bar()
+where
+ for<V> V: IntoIterator,
+{
+}
+
+fn main() {
+ foo();
+ //~^ ERROR the size for values of type `V` cannot be known at compilation time
+
+ bar();
+ //~^ ERROR the size for values of type `V` cannot be known at compilation time
+ //~| ERROR `V` is not an iterator
+}
diff --git a/tests/ui/traits/non_lifetime_binders/bad-sized-cond.stderr b/tests/ui/traits/non_lifetime_binders/bad-sized-cond.stderr
new file mode 100644
index 000000000..ed9b57cb1
--- /dev/null
+++ b/tests/ui/traits/non_lifetime_binders/bad-sized-cond.stderr
@@ -0,0 +1,62 @@
+warning: the feature `non_lifetime_binders` is incomplete and may not be safe to use and/or cause compiler crashes
+ --> $DIR/bad-sized-cond.rs:1:12
+ |
+LL | #![feature(non_lifetime_binders)]
+ | ^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: see issue #108185 <https://github.com/rust-lang/rust/issues/108185> for more information
+ = note: `#[warn(incomplete_features)]` on by default
+
+error[E0277]: the size for values of type `V` cannot be known at compilation time
+ --> $DIR/bad-sized-cond.rs:17:5
+ |
+LL | foo();
+ | ^^^ doesn't have a size known at compile-time
+ |
+ = help: the trait `Sized` is not implemented for `V`
+note: required by a bound in `foo`
+ --> $DIR/bad-sized-cond.rs:6:15
+ |
+LL | pub fn foo()
+ | --- required by a bound in this function
+LL | where
+LL | for<V> V: Sized,
+ | ^^^^^ required by this bound in `foo`
+
+error[E0277]: the size for values of type `V` cannot be known at compilation time
+ --> $DIR/bad-sized-cond.rs:20:5
+ |
+LL | bar();
+ | ^^^ doesn't have a size known at compile-time
+ |
+ = help: the trait `Sized` is not implemented for `V`
+ = note: required for `V` to implement `IntoIterator`
+note: required by a bound in `bar`
+ --> $DIR/bad-sized-cond.rs:12:15
+ |
+LL | pub fn bar()
+ | --- required by a bound in this function
+LL | where
+LL | for<V> V: IntoIterator,
+ | ^^^^^^^^^^^^ required by this bound in `bar`
+
+error[E0277]: `V` is not an iterator
+ --> $DIR/bad-sized-cond.rs:20:5
+ |
+LL | bar();
+ | ^^^ `V` is not an iterator
+ |
+ = help: the trait `Iterator` is not implemented for `V`
+ = note: required for `V` to implement `IntoIterator`
+note: required by a bound in `bar`
+ --> $DIR/bad-sized-cond.rs:12:15
+ |
+LL | pub fn bar()
+ | --- required by a bound in this function
+LL | where
+LL | for<V> V: IntoIterator,
+ | ^^^^^^^^^^^^ required by this bound in `bar`
+
+error: aborting due to 3 previous errors; 1 warning emitted
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/traits/non_lifetime_binders/basic.rs b/tests/ui/traits/non_lifetime_binders/basic.rs
new file mode 100644
index 000000000..a797aae65
--- /dev/null
+++ b/tests/ui/traits/non_lifetime_binders/basic.rs
@@ -0,0 +1,19 @@
+// check-pass
+// Basic test that show's we can succesfully typeck a `for<T>` where clause.
+
+#![feature(non_lifetime_binders)]
+//~^ WARN the feature `non_lifetime_binders` is incomplete
+
+trait Trait {}
+
+impl<T: ?Sized> Trait for T {}
+
+fn foo()
+where
+ for<T> T: Trait,
+{
+}
+
+fn main() {
+ foo();
+}
diff --git a/tests/ui/traits/non_lifetime_binders/basic.stderr b/tests/ui/traits/non_lifetime_binders/basic.stderr
new file mode 100644
index 000000000..0fd16c5d0
--- /dev/null
+++ b/tests/ui/traits/non_lifetime_binders/basic.stderr
@@ -0,0 +1,11 @@
+warning: the feature `non_lifetime_binders` is incomplete and may not be safe to use and/or cause compiler crashes
+ --> $DIR/basic.rs:4:12
+ |
+LL | #![feature(non_lifetime_binders)]
+ | ^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: see issue #108185 <https://github.com/rust-lang/rust/issues/108185> for more information
+ = note: `#[warn(incomplete_features)]` on by default
+
+warning: 1 warning emitted
+
diff --git a/tests/ui/traits/non_lifetime_binders/fail.rs b/tests/ui/traits/non_lifetime_binders/fail.rs
new file mode 100644
index 000000000..460f68907
--- /dev/null
+++ b/tests/ui/traits/non_lifetime_binders/fail.rs
@@ -0,0 +1,23 @@
+// Error reporting for where `for<T> T: Trait` doesn't hold
+
+#![feature(non_lifetime_binders)]
+//~^ WARN the feature `non_lifetime_binders` is incomplete
+
+trait Trait {}
+
+fn fail()
+where
+ for<T> T: Trait,
+{}
+
+fn auto_trait()
+where
+ for<T> T: Send,
+{}
+
+fn main() {
+ fail();
+ //~^ ERROR the trait bound `T: Trait` is not satisfied
+ auto_trait();
+ //~^ ERROR `T` cannot be sent between threads safely
+}
diff --git a/tests/ui/traits/non_lifetime_binders/fail.stderr b/tests/ui/traits/non_lifetime_binders/fail.stderr
new file mode 100644
index 000000000..7bd02550f
--- /dev/null
+++ b/tests/ui/traits/non_lifetime_binders/fail.stderr
@@ -0,0 +1,43 @@
+warning: the feature `non_lifetime_binders` is incomplete and may not be safe to use and/or cause compiler crashes
+ --> $DIR/fail.rs:3:12
+ |
+LL | #![feature(non_lifetime_binders)]
+ | ^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: see issue #108185 <https://github.com/rust-lang/rust/issues/108185> for more information
+ = note: `#[warn(incomplete_features)]` on by default
+
+error[E0277]: the trait bound `T: Trait` is not satisfied
+ --> $DIR/fail.rs:19:5
+ |
+LL | fail();
+ | ^^^^ the trait `Trait` is not implemented for `T`
+ |
+note: required by a bound in `fail`
+ --> $DIR/fail.rs:10:15
+ |
+LL | fn fail()
+ | ---- required by a bound in this function
+LL | where
+LL | for<T> T: Trait,
+ | ^^^^^ required by this bound in `fail`
+
+error[E0277]: `T` cannot be sent between threads safely
+ --> $DIR/fail.rs:21:5
+ |
+LL | auto_trait();
+ | ^^^^^^^^^^ `T` cannot be sent between threads safely
+ |
+ = help: the trait `Send` is not implemented for `T`
+note: required by a bound in `auto_trait`
+ --> $DIR/fail.rs:15:15
+ |
+LL | fn auto_trait()
+ | ---------- required by a bound in this function
+LL | where
+LL | for<T> T: Send,
+ | ^^^^ required by this bound in `auto_trait`
+
+error: aborting due to 2 previous errors; 1 warning emitted
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/traits/non_lifetime_binders/late-bound-in-anon-ct.rs b/tests/ui/traits/non_lifetime_binders/late-bound-in-anon-ct.rs
new file mode 100644
index 000000000..3903bfe9b
--- /dev/null
+++ b/tests/ui/traits/non_lifetime_binders/late-bound-in-anon-ct.rs
@@ -0,0 +1,11 @@
+#![feature(non_lifetime_binders, generic_const_exprs)]
+//~^ WARN the feature `non_lifetime_binders` is incomplete
+//~| WARN the feature `generic_const_exprs` is incomplete
+
+fn foo() -> usize
+where
+ for<T> [i32; { let _: T = todo!(); 0 }]:,
+ //~^ ERROR cannot capture late-bound type parameter in a constant
+{}
+
+fn main() {}
diff --git a/tests/ui/traits/non_lifetime_binders/late-bound-in-anon-ct.stderr b/tests/ui/traits/non_lifetime_binders/late-bound-in-anon-ct.stderr
new file mode 100644
index 000000000..fafff02de
--- /dev/null
+++ b/tests/ui/traits/non_lifetime_binders/late-bound-in-anon-ct.stderr
@@ -0,0 +1,27 @@
+warning: the feature `non_lifetime_binders` is incomplete and may not be safe to use and/or cause compiler crashes
+ --> $DIR/late-bound-in-anon-ct.rs:1:12
+ |
+LL | #![feature(non_lifetime_binders, generic_const_exprs)]
+ | ^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: see issue #108185 <https://github.com/rust-lang/rust/issues/108185> for more information
+ = note: `#[warn(incomplete_features)]` on by default
+
+warning: the feature `generic_const_exprs` is incomplete and may not be safe to use and/or cause compiler crashes
+ --> $DIR/late-bound-in-anon-ct.rs:1:34
+ |
+LL | #![feature(non_lifetime_binders, generic_const_exprs)]
+ | ^^^^^^^^^^^^^^^^^^^
+ |
+ = note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information
+
+error: cannot capture late-bound type parameter in a constant
+ --> $DIR/late-bound-in-anon-ct.rs:7:27
+ |
+LL | for<T> [i32; { let _: T = todo!(); 0 }]:,
+ | - ^
+ | |
+ | parameter defined here
+
+error: aborting due to previous error; 2 warnings emitted
+
diff --git a/tests/ui/traits/non_lifetime_binders/object-lifetime-default-for-late.rs b/tests/ui/traits/non_lifetime_binders/object-lifetime-default-for-late.rs
new file mode 100644
index 000000000..9830241c3
--- /dev/null
+++ b/tests/ui/traits/non_lifetime_binders/object-lifetime-default-for-late.rs
@@ -0,0 +1,7 @@
+// check-pass
+// compile-flags: --crate-type=lib
+
+#![feature(non_lifetime_binders)]
+//~^ WARN the feature `non_lifetime_binders` is incomplete
+
+pub fn f<T>() where for<U> (T, U): Copy {}
diff --git a/tests/ui/traits/non_lifetime_binders/object-lifetime-default-for-late.stderr b/tests/ui/traits/non_lifetime_binders/object-lifetime-default-for-late.stderr
new file mode 100644
index 000000000..667575b72
--- /dev/null
+++ b/tests/ui/traits/non_lifetime_binders/object-lifetime-default-for-late.stderr
@@ -0,0 +1,11 @@
+warning: the feature `non_lifetime_binders` is incomplete and may not be safe to use and/or cause compiler crashes
+ --> $DIR/object-lifetime-default-for-late.rs:4:12
+ |
+LL | #![feature(non_lifetime_binders)]
+ | ^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: see issue #108185 <https://github.com/rust-lang/rust/issues/108185> for more information
+ = note: `#[warn(incomplete_features)]` on by default
+
+warning: 1 warning emitted
+
diff --git a/tests/ui/traits/non_lifetime_binders/on-dyn.rs b/tests/ui/traits/non_lifetime_binders/on-dyn.rs
new file mode 100644
index 000000000..8fb7dd276
--- /dev/null
+++ b/tests/ui/traits/non_lifetime_binders/on-dyn.rs
@@ -0,0 +1,13 @@
+// Tests to make sure that we reject polymorphic dyn trait.
+
+#![feature(non_lifetime_binders)]
+//~^ WARN the feature `non_lifetime_binders` is incomplete
+
+trait Test<T> {}
+
+fn foo() -> &'static dyn for<T> Test<T> {
+ //~^ ERROR late-bound type parameter not allowed on trait object types
+ todo!()
+}
+
+fn main() {}
diff --git a/tests/ui/traits/non_lifetime_binders/on-dyn.stderr b/tests/ui/traits/non_lifetime_binders/on-dyn.stderr
new file mode 100644
index 000000000..95656f999
--- /dev/null
+++ b/tests/ui/traits/non_lifetime_binders/on-dyn.stderr
@@ -0,0 +1,17 @@
+warning: the feature `non_lifetime_binders` is incomplete and may not be safe to use and/or cause compiler crashes
+ --> $DIR/on-dyn.rs:3:12
+ |
+LL | #![feature(non_lifetime_binders)]
+ | ^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: see issue #108185 <https://github.com/rust-lang/rust/issues/108185> for more information
+ = note: `#[warn(incomplete_features)]` on by default
+
+error: late-bound type parameter not allowed on trait object types
+ --> $DIR/on-dyn.rs:8:30
+ |
+LL | fn foo() -> &'static dyn for<T> Test<T> {
+ | ^
+
+error: aborting due to previous error; 1 warning emitted
+
diff --git a/tests/ui/traits/non_lifetime_binders/on-ptr.rs b/tests/ui/traits/non_lifetime_binders/on-ptr.rs
new file mode 100644
index 000000000..0aaff52b6
--- /dev/null
+++ b/tests/ui/traits/non_lifetime_binders/on-ptr.rs
@@ -0,0 +1,13 @@
+// Tests to make sure that we reject polymorphic fn ptrs.
+
+#![feature(non_lifetime_binders)]
+//~^ WARN the feature `non_lifetime_binders` is incomplete
+
+fn foo() -> for<T> fn(T) {
+ //~^ ERROR late-bound type parameter not allowed on function pointer types
+ todo!()
+}
+
+fn main() {
+ foo()(1i32);
+}
diff --git a/tests/ui/traits/non_lifetime_binders/on-ptr.stderr b/tests/ui/traits/non_lifetime_binders/on-ptr.stderr
new file mode 100644
index 000000000..3b17f7697
--- /dev/null
+++ b/tests/ui/traits/non_lifetime_binders/on-ptr.stderr
@@ -0,0 +1,17 @@
+warning: the feature `non_lifetime_binders` is incomplete and may not be safe to use and/or cause compiler crashes
+ --> $DIR/on-ptr.rs:3:12
+ |
+LL | #![feature(non_lifetime_binders)]
+ | ^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: see issue #108185 <https://github.com/rust-lang/rust/issues/108185> for more information
+ = note: `#[warn(incomplete_features)]` on by default
+
+error: late-bound type parameter not allowed on function pointer types
+ --> $DIR/on-ptr.rs:6:17
+ |
+LL | fn foo() -> for<T> fn(T) {
+ | ^
+
+error: aborting due to previous error; 1 warning emitted
+
diff --git a/tests/ui/traits/non_lifetime_binders/type-match-with-late-bound.rs b/tests/ui/traits/non_lifetime_binders/type-match-with-late-bound.rs
new file mode 100644
index 000000000..5ff7089b9
--- /dev/null
+++ b/tests/ui/traits/non_lifetime_binders/type-match-with-late-bound.rs
@@ -0,0 +1,14 @@
+// edition:2021
+// check-pass
+
+// Checks that test_type_match code doesn't ICE when predicates have late-bound types
+
+#![feature(non_lifetime_binders)]
+//~^ WARN is incomplete and may not be safe to use
+
+async fn walk2<'a, T: 'a>(_: T)
+where
+ for<F> F: 'a,
+{}
+
+fn main() {}
diff --git a/tests/ui/traits/non_lifetime_binders/type-match-with-late-bound.stderr b/tests/ui/traits/non_lifetime_binders/type-match-with-late-bound.stderr
new file mode 100644
index 000000000..3609bed28
--- /dev/null
+++ b/tests/ui/traits/non_lifetime_binders/type-match-with-late-bound.stderr
@@ -0,0 +1,11 @@
+warning: the feature `non_lifetime_binders` is incomplete and may not be safe to use and/or cause compiler crashes
+ --> $DIR/type-match-with-late-bound.rs:6:12
+ |
+LL | #![feature(non_lifetime_binders)]
+ | ^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: see issue #108185 <https://github.com/rust-lang/rust/issues/108185> for more information
+ = note: `#[warn(incomplete_features)]` on by default
+
+warning: 1 warning emitted
+
diff --git a/tests/ui/traits/object/enforce-supertrait-projection.stderr b/tests/ui/traits/object/enforce-supertrait-projection.stderr
index cbf093866..848b4e69a 100644
--- a/tests/ui/traits/object/enforce-supertrait-projection.stderr
+++ b/tests/ui/traits/object/enforce-supertrait-projection.stderr
@@ -16,7 +16,7 @@ note: required by a bound in `foo`
--> $DIR/enforce-supertrait-projection.rs:15:8
|
LL | fn foo<A, B, T: ?Sized>(x: T::A) -> B
- | --- required by a bound in this
+ | --- required by a bound in this function
LL | where
LL | T: Trait<B = B>,
| ^^^^^^^^^^^^ required by this bound in `foo`
diff --git a/tests/ui/traits/object/vs-lifetime.rs b/tests/ui/traits/object/vs-lifetime.rs
index 14ae67cff..d3e6c0b21 100644
--- a/tests/ui/traits/object/vs-lifetime.rs
+++ b/tests/ui/traits/object/vs-lifetime.rs
@@ -9,8 +9,8 @@ fn main() {
let _: S<'static, dyn 'static +>;
//~^ at least one trait is required for an object type
let _: S<'static, 'static>;
- //~^ ERROR this struct takes 1 lifetime argument but 2 lifetime arguments were supplied
- //~| ERROR this struct takes 1 generic argument but 0 generic arguments were supplied
+ //~^ ERROR struct takes 1 lifetime argument but 2 lifetime arguments were supplied
+ //~| ERROR struct takes 1 generic argument but 0 generic arguments were supplied
let _: S<dyn 'static +, 'static>;
//~^ ERROR type provided when a lifetime was expected
//~| ERROR at least one trait is required for an object type
diff --git a/tests/ui/traits/object/vs-lifetime.stderr b/tests/ui/traits/object/vs-lifetime.stderr
index 224465228..a69cd1408 100644
--- a/tests/ui/traits/object/vs-lifetime.stderr
+++ b/tests/ui/traits/object/vs-lifetime.stderr
@@ -4,7 +4,7 @@ error[E0224]: at least one trait is required for an object type
LL | let _: S<'static, dyn 'static +>;
| ^^^^^^^^^^^^^
-error[E0107]: this struct takes 1 lifetime argument but 2 lifetime arguments were supplied
+error[E0107]: struct takes 1 lifetime argument but 2 lifetime arguments were supplied
--> $DIR/vs-lifetime.rs:11:12
|
LL | let _: S<'static, 'static>;
@@ -18,7 +18,7 @@ note: struct defined here, with 1 lifetime parameter: `'a`
LL | struct S<'a, T>(&'a u8, T);
| ^ --
-error[E0107]: this struct takes 1 generic argument but 0 generic arguments were supplied
+error[E0107]: struct takes 1 generic argument but 0 generic arguments were supplied
--> $DIR/vs-lifetime.rs:11:12
|
LL | let _: S<'static, 'static>;
diff --git a/tests/ui/traits/suggest-deferences/issue-39029.stderr b/tests/ui/traits/suggest-deferences/issue-39029.stderr
index 49e20c6a7..49105de3d 100644
--- a/tests/ui/traits/suggest-deferences/issue-39029.stderr
+++ b/tests/ui/traits/suggest-deferences/issue-39029.stderr
@@ -1,8 +1,8 @@
error[E0277]: the trait bound `NoToSocketAddrs: ToSocketAddrs` is not satisfied
- --> $DIR/issue-39029.rs:16:37
+ --> $DIR/issue-39029.rs:16:38
|
LL | let _errors = TcpListener::bind(&bad);
- | ----------------- ^^^^ the trait `ToSocketAddrs` is not implemented for `NoToSocketAddrs`
+ | ----------------- ^^^ the trait `ToSocketAddrs` is not implemented for `NoToSocketAddrs`
| |
| required by a bound introduced by this call
|
diff --git a/tests/ui/traits/test-2.rs b/tests/ui/traits/test-2.rs
index 342928e88..ffb778a01 100644
--- a/tests/ui/traits/test-2.rs
+++ b/tests/ui/traits/test-2.rs
@@ -7,9 +7,9 @@ impl bar for u32 { fn dup(&self) -> u32 { *self } fn blah<X>(&self) {} }
fn main() {
10.dup::<i32>();
- //~^ ERROR this associated function takes 0 generic arguments but 1
+ //~^ ERROR method takes 0 generic arguments but 1
10.blah::<i32, i32>();
- //~^ ERROR this associated function takes 1 generic argument but 2
+ //~^ ERROR method takes 1 generic argument but 2
(Box::new(10) as Box<dyn bar>).dup();
//~^ ERROR E0038
//~| ERROR E0038
diff --git a/tests/ui/traits/test-2.stderr b/tests/ui/traits/test-2.stderr
index eaa20b0b4..6c0e8b8af 100644
--- a/tests/ui/traits/test-2.stderr
+++ b/tests/ui/traits/test-2.stderr
@@ -1,4 +1,4 @@
-error[E0107]: this associated function takes 0 generic arguments but 1 generic argument was supplied
+error[E0107]: method takes 0 generic arguments but 1 generic argument was supplied
--> $DIR/test-2.rs:9:8
|
LL | 10.dup::<i32>();
@@ -6,13 +6,13 @@ LL | 10.dup::<i32>();
| |
| expected 0 generic arguments
|
-note: associated function defined here, with 0 generic parameters
+note: method defined here, with 0 generic parameters
--> $DIR/test-2.rs:4:16
|
LL | trait bar { fn dup(&self) -> Self; fn blah<X>(&self); }
| ^^^
-error[E0107]: this associated function takes 1 generic argument but 2 generic arguments were supplied
+error[E0107]: method takes 1 generic argument but 2 generic arguments were supplied
--> $DIR/test-2.rs:11:8
|
LL | 10.blah::<i32, i32>();
@@ -20,7 +20,7 @@ LL | 10.blah::<i32, i32>();
| |
| expected 1 generic argument
|
-note: associated function defined here, with 1 generic parameter: `X`
+note: method defined here, with 1 generic parameter: `X`
--> $DIR/test-2.rs:4:39
|
LL | trait bar { fn dup(&self) -> Self; fn blah<X>(&self); }
diff --git a/tests/ui/traits/trait-or-new-type-instead.stderr b/tests/ui/traits/trait-or-new-type-instead.stderr
index 4726b0668..6fd8a03fd 100644
--- a/tests/ui/traits/trait-or-new-type-instead.stderr
+++ b/tests/ui/traits/trait-or-new-type-instead.stderr
@@ -1,11 +1,8 @@
error[E0116]: cannot define inherent `impl` for a type outside of the crate where the type is defined
--> $DIR/trait-or-new-type-instead.rs:1:1
|
-LL | / impl<T> Option<T> {
-LL | |
-LL | | pub fn foo(&self) { }
-LL | | }
- | |_^ impl for type defined outside of crate.
+LL | impl<T> Option<T> {
+ | ^^^^^^^^^^^^^^^^^ impl for type defined outside of crate.
|
= note: define and implement a trait or new type instead
diff --git a/tests/ui/traits/trait-upcasting/multiple_supertrait_upcastable.rs b/tests/ui/traits/trait-upcasting/multiple_supertrait_upcastable.rs
new file mode 100644
index 000000000..3c6ab86e4
--- /dev/null
+++ b/tests/ui/traits/trait-upcasting/multiple_supertrait_upcastable.rs
@@ -0,0 +1,10 @@
+#![feature(multiple_supertrait_upcastable)]
+#![deny(multiple_supertrait_upcastable)]
+
+trait A {}
+trait B {}
+
+trait C: A + B {}
+//~^ ERROR `C` is object-safe and has multiple supertraits
+
+fn main() {}
diff --git a/tests/ui/traits/trait-upcasting/multiple_supertrait_upcastable.stderr b/tests/ui/traits/trait-upcasting/multiple_supertrait_upcastable.stderr
new file mode 100644
index 000000000..ad80a009e
--- /dev/null
+++ b/tests/ui/traits/trait-upcasting/multiple_supertrait_upcastable.stderr
@@ -0,0 +1,14 @@
+error: `C` is object-safe and has multiple supertraits
+ --> $DIR/multiple_supertrait_upcastable.rs:7:1
+ |
+LL | trait C: A + B {}
+ | ^^^^^^^^^^^^^^
+ |
+note: the lint level is defined here
+ --> $DIR/multiple_supertrait_upcastable.rs:2:9
+ |
+LL | #![deny(multiple_supertrait_upcastable)]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to previous error
+
diff --git a/tests/ui/traits/unsend-future.rs b/tests/ui/traits/unsend-future.rs
new file mode 100644
index 000000000..fbbc07b11
--- /dev/null
+++ b/tests/ui/traits/unsend-future.rs
@@ -0,0 +1,21 @@
+// edition:2021
+
+// issue 108897
+trait Handler {}
+impl<F, Fut> Handler for F
+where
+ Fut: Send,
+ F: FnOnce() -> Fut,
+{}
+
+fn require_handler<H: Handler>(h: H) {}
+
+async fn handler() {
+ let a = &1 as *const i32;
+ async {}.await;
+}
+
+fn main() {
+ require_handler(handler)
+ //~^ ERROR future cannot be sent between threads safely
+}
diff --git a/tests/ui/traits/unsend-future.stderr b/tests/ui/traits/unsend-future.stderr
new file mode 100644
index 000000000..4aaa7c4a9
--- /dev/null
+++ b/tests/ui/traits/unsend-future.stderr
@@ -0,0 +1,24 @@
+error: future cannot be sent between threads safely
+ --> $DIR/unsend-future.rs:19:21
+ |
+LL | require_handler(handler)
+ | ^^^^^^^ future returned by `handler` is not `Send`
+ |
+ = help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `*const i32`
+note: future is not `Send` as this value is used across an await
+ --> $DIR/unsend-future.rs:15:13
+ |
+LL | let a = &1 as *const i32;
+ | - has type `*const i32` which is not `Send`
+LL | async {}.await;
+ | ^^^^^^ await occurs here, with `a` maybe used later
+LL | }
+ | - `a` is later dropped here
+note: required by a bound in `require_handler`
+ --> $DIR/unsend-future.rs:11:23
+ |
+LL | fn require_handler<H: Handler>(h: H) {}
+ | ^^^^^^^ required by this bound in `require_handler`
+
+error: aborting due to previous error
+
diff --git a/tests/ui/traits/vtable/issue-97381.stderr b/tests/ui/traits/vtable/issue-97381.stderr
index c4f8294e2..89360c44e 100644
--- a/tests/ui/traits/vtable/issue-97381.stderr
+++ b/tests/ui/traits/vtable/issue-97381.stderr
@@ -1,6 +1,9 @@
error[E0505]: cannot move out of `v` because it is borrowed
--> $DIR/issue-97381.rs:26:14
|
+LL | let v = [1, 2, 3]
+ | - binding `v` declared here
+...
LL | let el = &v[0];
| - borrow of `v` occurs here
LL |