summaryrefslogtreecommitdiffstats
path: root/tests/ui/traits
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/traits')
-rw-r--r--tests/ui/traits/auxiliary/trivial3.rs1
-rw-r--r--tests/ui/traits/auxiliary/trivial4.rs3
-rw-r--r--tests/ui/traits/bound/assoc-fn-bound-root-obligation.stderr6
-rw-r--r--tests/ui/traits/bound/generic_trait.rs2
-rw-r--r--tests/ui/traits/cache-reached-depth-ice.rs2
-rw-r--r--tests/ui/traits/cache-reached-depth-ice.stderr2
-rw-r--r--tests/ui/traits/deny-builtin-object-impl.current.stderr15
-rw-r--r--tests/ui/traits/deny-builtin-object-impl.next.stderr15
-rw-r--r--tests/ui/traits/deny-builtin-object-impl.rs20
-rw-r--r--tests/ui/traits/ice-with-dyn-pointee-errors.rs15
-rw-r--r--tests/ui/traits/ice-with-dyn-pointee-errors.stderr19
-rw-r--r--tests/ui/traits/ice-with-dyn-pointee.rs11
-rw-r--r--tests/ui/traits/issue-105231.rs9
-rw-r--r--tests/ui/traits/issue-105231.stderr29
-rw-r--r--tests/ui/traits/issue-83538-tainted-cache-after-cycle.rs8
-rw-r--r--tests/ui/traits/issue-83538-tainted-cache-after-cycle.stderr8
-rw-r--r--tests/ui/traits/issue-85360-eval-obligation-ice.rs8
-rw-r--r--tests/ui/traits/issue-85360-eval-obligation-ice.stderr8
-rw-r--r--tests/ui/traits/issue-91949-hangs-on-recursion.rs1
-rw-r--r--tests/ui/traits/issue-91949-hangs-on-recursion.stderr4
-rw-r--r--tests/ui/traits/new-solver/alias-bound-unsound.rs2
-rw-r--r--tests/ui/traits/new-solver/alias-bound-unsound.stderr16
-rw-r--r--tests/ui/traits/new-solver/alias_eq_substs_eq_not_intercrate.rs19
-rw-r--r--tests/ui/traits/new-solver/alias_eq_substs_eq_not_intercrate.stderr11
-rw-r--r--tests/ui/traits/new-solver/array-default.rs8
-rw-r--r--tests/ui/traits/new-solver/async.fail.stderr4
-rw-r--r--tests/ui/traits/new-solver/async.rs2
-rw-r--r--tests/ui/traits/new-solver/closure-substs-ambiguity.rs7
-rw-r--r--tests/ui/traits/new-solver/dedup-regions.rs31
-rw-r--r--tests/ui/traits/new-solver/dont-remap-tait-substs.rs19
-rw-r--r--tests/ui/traits/new-solver/dont-type_of-tait-in-defining-scope.not_send.stderr16
-rw-r--r--tests/ui/traits/new-solver/dont-type_of-tait-in-defining-scope.rs24
-rw-r--r--tests/ui/traits/new-solver/dyn-any-dont-prefer-impl.rs13
-rw-r--r--tests/ui/traits/new-solver/equating-projection-cyclically.rs12
-rw-r--r--tests/ui/traits/new-solver/equating-projection-cyclically.stderr9
-rw-r--r--tests/ui/traits/new-solver/lazy-nested-obligations-2.rs3
-rw-r--r--tests/ui/traits/new-solver/lazy-nested-obligations-2.stderr39
-rw-r--r--tests/ui/traits/new-solver/leak-check-coinductive-cycle.rs33
-rw-r--r--tests/ui/traits/new-solver/member-constraints-in-root-universe.rs17
-rw-r--r--tests/ui/traits/new-solver/normalized-const-built-in-op.rs11
-rw-r--r--tests/ui/traits/new-solver/object-unsafety.rs10
-rw-r--r--tests/ui/traits/new-solver/object-unsafety.stderr63
-rw-r--r--tests/ui/traits/new-solver/opportunistic-region-resolve.rs19
-rw-r--r--tests/ui/traits/new-solver/recursive-self-normalization-2.rs1
-rw-r--r--tests/ui/traits/new-solver/recursive-self-normalization-2.stderr10
-rw-r--r--tests/ui/traits/new-solver/recursive-self-normalization.rs1
-rw-r--r--tests/ui/traits/new-solver/recursive-self-normalization.stderr10
-rw-r--r--tests/ui/traits/new-solver/slice-match-byte-lit.rs11
-rw-r--r--tests/ui/traits/new-solver/specialization-transmute.rs12
-rw-r--r--tests/ui/traits/new-solver/specialization-transmute.stderr22
-rw-r--r--tests/ui/traits/new-solver/specialization-unconstrained.rs2
-rw-r--r--tests/ui/traits/new-solver/specialization-unconstrained.stderr11
-rw-r--r--tests/ui/traits/new-solver/tait-eq-proj-2.rs23
-rw-r--r--tests/ui/traits/new-solver/tait-eq-proj.rs35
-rw-r--r--tests/ui/traits/new-solver/tait-eq-tait.rs18
-rw-r--r--tests/ui/traits/new-solver/two-projection-param-candidates-are-ambiguous.stderr1
-rw-r--r--tests/ui/traits/new-solver/unevaluated-const-impl-trait-ref.fails.stderr18
-rw-r--r--tests/ui/traits/new-solver/unevaluated-const-impl-trait-ref.rs22
-rw-r--r--tests/ui/traits/new-solver/winnow-specializing-impls.rs22
-rw-r--r--tests/ui/traits/non_lifetime_binders/foreach-partial-eq.rs12
-rw-r--r--tests/ui/traits/non_lifetime_binders/foreach-partial-eq.stderr28
-rw-r--r--tests/ui/traits/non_lifetime_binders/nested-apit-mentioning-outer-bound-var.rs11
-rw-r--r--tests/ui/traits/non_lifetime_binders/nested-apit-mentioning-outer-bound-var.stderr17
-rw-r--r--tests/ui/traits/object/print_vtable_sizes.rs61
-rw-r--r--tests/ui/traits/object/print_vtable_sizes.stdout11
-rw-r--r--tests/ui/traits/project-modulo-regions.rs4
-rw-r--r--tests/ui/traits/project-modulo-regions.with_clause.stderr2
-rw-r--r--tests/ui/traits/project-modulo-regions.without_clause.stderr2
-rw-r--r--tests/ui/traits/suggest-where-clause.stderr4
-rw-r--r--tests/ui/traits/trivial_impl.rs18
-rw-r--r--tests/ui/traits/trivial_impl.stderr14
-rw-r--r--tests/ui/traits/trivial_impl2.rs13
-rw-r--r--tests/ui/traits/trivial_impl2.stderr14
-rw-r--r--tests/ui/traits/trivial_impl3.rs19
-rw-r--r--tests/ui/traits/trivial_impl3.stderr14
-rw-r--r--tests/ui/traits/trivial_impl4.rs21
-rw-r--r--tests/ui/traits/trivial_impl4.stderr14
-rw-r--r--tests/ui/traits/trivial_impl_sized.rs26
-rw-r--r--tests/ui/traits/trivial_impl_sized.stderr25
79 files changed, 1016 insertions, 107 deletions
diff --git a/tests/ui/traits/auxiliary/trivial3.rs b/tests/ui/traits/auxiliary/trivial3.rs
new file mode 100644
index 000000000..0a47fdc74
--- /dev/null
+++ b/tests/ui/traits/auxiliary/trivial3.rs
@@ -0,0 +1 @@
+pub trait Trait {}
diff --git a/tests/ui/traits/auxiliary/trivial4.rs b/tests/ui/traits/auxiliary/trivial4.rs
new file mode 100644
index 000000000..a527d1a95
--- /dev/null
+++ b/tests/ui/traits/auxiliary/trivial4.rs
@@ -0,0 +1,3 @@
+pub trait Trait {}
+
+impl Trait for () {}
diff --git a/tests/ui/traits/bound/assoc-fn-bound-root-obligation.stderr b/tests/ui/traits/bound/assoc-fn-bound-root-obligation.stderr
index ce9ab2d81..b1c683e47 100644
--- a/tests/ui/traits/bound/assoc-fn-bound-root-obligation.stderr
+++ b/tests/ui/traits/bound/assoc-fn-bound-root-obligation.stderr
@@ -6,13 +6,13 @@ LL | s.strip_suffix(b'\n').unwrap_or(s)
|
= help: the trait `FnMut<(char,)>` is not implemented for `u8`
= help: the following other types implement trait `Pattern<'a>`:
+ char
+ [char; N]
&'b String
&'b [char; N]
&'b [char]
- &'b str
&'c &'b str
- [char; N]
- char
+ &'b str
= note: required for `u8` to implement `Pattern<'_>`
error: aborting due to previous error
diff --git a/tests/ui/traits/bound/generic_trait.rs b/tests/ui/traits/bound/generic_trait.rs
index 18382bb59..2484c5a88 100644
--- a/tests/ui/traits/bound/generic_trait.rs
+++ b/tests/ui/traits/bound/generic_trait.rs
@@ -24,7 +24,7 @@ impl connection_factory<my_connection> for my_connection_factory {
pub fn main() {
let factory = ();
- let connection = factory.create();
+ let connection: () = factory.create();
let result = connection.read();
assert_eq!(result, 43);
}
diff --git a/tests/ui/traits/cache-reached-depth-ice.rs b/tests/ui/traits/cache-reached-depth-ice.rs
index c36ac0857..8c2391113 100644
--- a/tests/ui/traits/cache-reached-depth-ice.rs
+++ b/tests/ui/traits/cache-reached-depth-ice.rs
@@ -41,5 +41,5 @@ fn test<X: ?Sized + Send>() {}
fn main() {
test::<A>();
- //~^ ERROR evaluate(Binder(TraitPredicate(<A as std::marker::Send>, polarity:Positive), [])) = Ok(EvaluatedToOk)
+ //~^ ERROR evaluate(Binder { value: TraitPredicate(<A as std::marker::Send>, polarity:Positive), bound_vars: [] }) = Ok(EvaluatedToOk)
}
diff --git a/tests/ui/traits/cache-reached-depth-ice.stderr b/tests/ui/traits/cache-reached-depth-ice.stderr
index 082aa0f5c..7cd758192 100644
--- a/tests/ui/traits/cache-reached-depth-ice.stderr
+++ b/tests/ui/traits/cache-reached-depth-ice.stderr
@@ -1,4 +1,4 @@
-error: evaluate(Binder(TraitPredicate(<A as std::marker::Send>, polarity:Positive), [])) = Ok(EvaluatedToOk)
+error: evaluate(Binder { value: TraitPredicate(<A as std::marker::Send>, polarity:Positive), bound_vars: [] }) = Ok(EvaluatedToOk)
--> $DIR/cache-reached-depth-ice.rs:43:5
|
LL | fn test<X: ?Sized + Send>() {}
diff --git a/tests/ui/traits/deny-builtin-object-impl.current.stderr b/tests/ui/traits/deny-builtin-object-impl.current.stderr
new file mode 100644
index 000000000..5c1987426
--- /dev/null
+++ b/tests/ui/traits/deny-builtin-object-impl.current.stderr
@@ -0,0 +1,15 @@
+error[E0277]: the trait bound `dyn NotObject: NotObject` is not satisfied
+ --> $DIR/deny-builtin-object-impl.rs:18:23
+ |
+LL | test_not_object::<dyn NotObject>();
+ | ^^^^^^^^^^^^^ the trait `NotObject` is not implemented for `dyn NotObject`
+ |
+note: required by a bound in `test_not_object`
+ --> $DIR/deny-builtin-object-impl.rs:14:23
+ |
+LL | fn test_not_object<T: NotObject + ?Sized>() {}
+ | ^^^^^^^^^ required by this bound in `test_not_object`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/traits/deny-builtin-object-impl.next.stderr b/tests/ui/traits/deny-builtin-object-impl.next.stderr
new file mode 100644
index 000000000..5c1987426
--- /dev/null
+++ b/tests/ui/traits/deny-builtin-object-impl.next.stderr
@@ -0,0 +1,15 @@
+error[E0277]: the trait bound `dyn NotObject: NotObject` is not satisfied
+ --> $DIR/deny-builtin-object-impl.rs:18:23
+ |
+LL | test_not_object::<dyn NotObject>();
+ | ^^^^^^^^^^^^^ the trait `NotObject` is not implemented for `dyn NotObject`
+ |
+note: required by a bound in `test_not_object`
+ --> $DIR/deny-builtin-object-impl.rs:14:23
+ |
+LL | fn test_not_object<T: NotObject + ?Sized>() {}
+ | ^^^^^^^^^ required by this bound in `test_not_object`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/traits/deny-builtin-object-impl.rs b/tests/ui/traits/deny-builtin-object-impl.rs
new file mode 100644
index 000000000..dce03a43b
--- /dev/null
+++ b/tests/ui/traits/deny-builtin-object-impl.rs
@@ -0,0 +1,20 @@
+// revisions: current next
+//[next] compile-flags: -Ztrait-solver=next
+
+#![feature(rustc_attrs)]
+
+#[rustc_deny_explicit_impl(implement_via_object = true)]
+trait YesObject {}
+
+#[rustc_deny_explicit_impl(implement_via_object = false)]
+trait NotObject {}
+
+fn test_yes_object<T: YesObject + ?Sized>() {}
+
+fn test_not_object<T: NotObject + ?Sized>() {}
+
+fn main() {
+ test_yes_object::<dyn YesObject>();
+ test_not_object::<dyn NotObject>();
+ //~^ ERROR the trait bound `dyn NotObject: NotObject` is not satisfied
+}
diff --git a/tests/ui/traits/ice-with-dyn-pointee-errors.rs b/tests/ui/traits/ice-with-dyn-pointee-errors.rs
new file mode 100644
index 000000000..46cef2c8b
--- /dev/null
+++ b/tests/ui/traits/ice-with-dyn-pointee-errors.rs
@@ -0,0 +1,15 @@
+#![feature(ptr_metadata)]
+// Address issue #112737 -- ICE with dyn Pointee
+extern crate core;
+use core::ptr::Pointee;
+
+fn unknown_sized_object_ptr_in(_: &(impl Pointee<Metadata = ()> + ?Sized)) {}
+
+fn raw_pointer_in(x: &dyn Pointee<Metadata = ()>) {
+ unknown_sized_object_ptr_in(x)
+ //~^ ERROR type mismatch resolving `<dyn Pointee<Metadata = ()> as Pointee>::Metadata == ()`
+}
+
+fn main() {
+ raw_pointer_in(&42)
+}
diff --git a/tests/ui/traits/ice-with-dyn-pointee-errors.stderr b/tests/ui/traits/ice-with-dyn-pointee-errors.stderr
new file mode 100644
index 000000000..8ad11c334
--- /dev/null
+++ b/tests/ui/traits/ice-with-dyn-pointee-errors.stderr
@@ -0,0 +1,19 @@
+error[E0271]: type mismatch resolving `<dyn Pointee<Metadata = ()> as Pointee>::Metadata == ()`
+ --> $DIR/ice-with-dyn-pointee-errors.rs:9:33
+ |
+LL | unknown_sized_object_ptr_in(x)
+ | --------------------------- ^ expected `()`, found `DynMetadata<dyn Pointee<Metadata = ...>>`
+ | |
+ | required by a bound introduced by this call
+ |
+ = note: expected unit type `()`
+ found struct `DynMetadata<dyn Pointee<Metadata = ()>>`
+note: required by a bound in `unknown_sized_object_ptr_in`
+ --> $DIR/ice-with-dyn-pointee-errors.rs:6:50
+ |
+LL | fn unknown_sized_object_ptr_in(_: &(impl Pointee<Metadata = ()> + ?Sized)) {}
+ | ^^^^^^^^^^^^^ required by this bound in `unknown_sized_object_ptr_in`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0271`.
diff --git a/tests/ui/traits/ice-with-dyn-pointee.rs b/tests/ui/traits/ice-with-dyn-pointee.rs
new file mode 100644
index 000000000..9b3b9c8cd
--- /dev/null
+++ b/tests/ui/traits/ice-with-dyn-pointee.rs
@@ -0,0 +1,11 @@
+// run-pass
+#![feature(ptr_metadata)]
+// Address issue #112737 -- ICE with dyn Pointee
+extern crate core;
+use core::ptr::Pointee;
+
+fn raw_pointer_in(_: &dyn Pointee<Metadata = ()>) {}
+
+fn main() {
+ raw_pointer_in(&42)
+}
diff --git a/tests/ui/traits/issue-105231.rs b/tests/ui/traits/issue-105231.rs
new file mode 100644
index 000000000..74c7afd6b
--- /dev/null
+++ b/tests/ui/traits/issue-105231.rs
@@ -0,0 +1,9 @@
+//~ ERROR overflow evaluating the requirement `A<A<A<A<A<A<A<...>>>>>>>: Send`
+struct A<T>(B<T>);
+//~^ ERROR recursive types `A` and `B` have infinite size
+struct B<T>(A<A<T>>);
+trait Foo {}
+impl<T> Foo for T where T: Send {}
+impl Foo for B<u8> {}
+
+fn main() {}
diff --git a/tests/ui/traits/issue-105231.stderr b/tests/ui/traits/issue-105231.stderr
new file mode 100644
index 000000000..fe20c47c5
--- /dev/null
+++ b/tests/ui/traits/issue-105231.stderr
@@ -0,0 +1,29 @@
+error[E0072]: recursive types `A` and `B` have infinite size
+ --> $DIR/issue-105231.rs:2:1
+ |
+LL | struct A<T>(B<T>);
+ | ^^^^^^^^^^^ ---- recursive without indirection
+LL |
+LL | struct B<T>(A<A<T>>);
+ | ^^^^^^^^^^^ ------- recursive without indirection
+ |
+help: insert some indirection (e.g., a `Box`, `Rc`, or `&`) to break the cycle
+ |
+LL ~ struct A<T>(Box<B<T>>);
+LL |
+LL ~ struct B<T>(Box<A<A<T>>>);
+ |
+
+error[E0275]: overflow evaluating the requirement `A<A<A<A<A<A<A<...>>>>>>>: Send`
+ |
+ = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`issue_105231`)
+note: required because it appears within the type `B<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<u8>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>`
+ --> $DIR/issue-105231.rs:4:8
+ |
+LL | struct B<T>(A<A<T>>);
+ | ^
+
+error: aborting due to 2 previous errors
+
+Some errors have detailed explanations: E0072, E0275.
+For more information about an error, try `rustc --explain E0072`.
diff --git a/tests/ui/traits/issue-83538-tainted-cache-after-cycle.rs b/tests/ui/traits/issue-83538-tainted-cache-after-cycle.rs
index 3cd68ff6f..5136aef4f 100644
--- a/tests/ui/traits/issue-83538-tainted-cache-after-cycle.rs
+++ b/tests/ui/traits/issue-83538-tainted-cache-after-cycle.rs
@@ -57,10 +57,10 @@ fn main() {
// Key is that Vec<First> is "ok" and Third<'_, Ty> is "ok modulo regions":
forward();
- //~^ ERROR evaluate(Binder(TraitPredicate(<std::vec::Vec<First> as std::marker::Unpin>, polarity:Positive), [])) = Ok(EvaluatedToOk)
- //~| ERROR evaluate(Binder(TraitPredicate(<Third<'_, Ty> as std::marker::Unpin>, polarity:Positive), [])) = Ok(EvaluatedToOkModuloRegions)
+ //~^ ERROR evaluate(Binder { value: TraitPredicate(<std::vec::Vec<First> as std::marker::Unpin>, polarity:Positive), bound_vars: [] }) = Ok(EvaluatedToOk)
+ //~| ERROR evaluate(Binder { value: TraitPredicate(<Third<'_, Ty> as std::marker::Unpin>, polarity:Positive), bound_vars: [] }) = Ok(EvaluatedToOkModuloRegions)
reverse();
- //~^ ERROR evaluate(Binder(TraitPredicate(<std::vec::Vec<First> as std::marker::Unpin>, polarity:Positive), [])) = Ok(EvaluatedToOk)
- //~| ERROR evaluate(Binder(TraitPredicate(<Third<'_, Ty> as std::marker::Unpin>, polarity:Positive), [])) = Ok(EvaluatedToOkModuloRegions)
+ //~^ ERROR evaluate(Binder { value: TraitPredicate(<std::vec::Vec<First> as std::marker::Unpin>, polarity:Positive), bound_vars: [] }) = Ok(EvaluatedToOk)
+ //~| ERROR evaluate(Binder { value: TraitPredicate(<Third<'_, Ty> as std::marker::Unpin>, polarity:Positive), bound_vars: [] }) = Ok(EvaluatedToOkModuloRegions)
}
diff --git a/tests/ui/traits/issue-83538-tainted-cache-after-cycle.stderr b/tests/ui/traits/issue-83538-tainted-cache-after-cycle.stderr
index 7c4041144..96baec76a 100644
--- a/tests/ui/traits/issue-83538-tainted-cache-after-cycle.stderr
+++ b/tests/ui/traits/issue-83538-tainted-cache-after-cycle.stderr
@@ -1,4 +1,4 @@
-error: evaluate(Binder(TraitPredicate(<std::vec::Vec<First> as std::marker::Unpin>, polarity:Positive), [])) = Ok(EvaluatedToOk)
+error: evaluate(Binder { value: TraitPredicate(<std::vec::Vec<First> as std::marker::Unpin>, polarity:Positive), bound_vars: [] }) = Ok(EvaluatedToOk)
--> $DIR/issue-83538-tainted-cache-after-cycle.rs:59:5
|
LL | Vec<First>: Unpin,
@@ -7,7 +7,7 @@ LL | Vec<First>: Unpin,
LL | forward();
| ^^^^^^^
-error: evaluate(Binder(TraitPredicate(<Third<'_, Ty> as std::marker::Unpin>, polarity:Positive), [])) = Ok(EvaluatedToOkModuloRegions)
+error: evaluate(Binder { value: TraitPredicate(<Third<'_, Ty> as std::marker::Unpin>, polarity:Positive), bound_vars: [] }) = Ok(EvaluatedToOkModuloRegions)
--> $DIR/issue-83538-tainted-cache-after-cycle.rs:59:5
|
LL | Third<'a, Ty>: Unpin,
@@ -16,7 +16,7 @@ LL | Third<'a, Ty>: Unpin,
LL | forward();
| ^^^^^^^
-error: evaluate(Binder(TraitPredicate(<Third<'_, Ty> as std::marker::Unpin>, polarity:Positive), [])) = Ok(EvaluatedToOkModuloRegions)
+error: evaluate(Binder { value: TraitPredicate(<Third<'_, Ty> as std::marker::Unpin>, polarity:Positive), bound_vars: [] }) = Ok(EvaluatedToOkModuloRegions)
--> $DIR/issue-83538-tainted-cache-after-cycle.rs:63:5
|
LL | Third<'a, Ty>: Unpin,
@@ -25,7 +25,7 @@ LL | Third<'a, Ty>: Unpin,
LL | reverse();
| ^^^^^^^
-error: evaluate(Binder(TraitPredicate(<std::vec::Vec<First> as std::marker::Unpin>, polarity:Positive), [])) = Ok(EvaluatedToOk)
+error: evaluate(Binder { value: TraitPredicate(<std::vec::Vec<First> as std::marker::Unpin>, polarity:Positive), bound_vars: [] }) = Ok(EvaluatedToOk)
--> $DIR/issue-83538-tainted-cache-after-cycle.rs:63:5
|
LL | Vec<First>: Unpin,
diff --git a/tests/ui/traits/issue-85360-eval-obligation-ice.rs b/tests/ui/traits/issue-85360-eval-obligation-ice.rs
index 19131684a..ac8bda9c0 100644
--- a/tests/ui/traits/issue-85360-eval-obligation-ice.rs
+++ b/tests/ui/traits/issue-85360-eval-obligation-ice.rs
@@ -7,12 +7,12 @@ use core::marker::PhantomData;
fn main() {
test::<MaskedStorage<GenericComp<Pos>>>(make());
- //~^ ERROR evaluate(Binder(TraitPredicate(<MaskedStorage<GenericComp<Pos>> as std::marker::Sized>, polarity:Positive), [])) = Ok(EvaluatedToOk)
- //~| ERROR evaluate(Binder(TraitPredicate(<MaskedStorage<GenericComp<Pos>> as std::marker::Sized>, polarity:Positive), [])) = Ok(EvaluatedToOk)
+ //~^ ERROR evaluate(Binder { value: TraitPredicate(<MaskedStorage<GenericComp<Pos>> as std::marker::Sized>, polarity:Positive), bound_vars: [] }) = Ok(EvaluatedToOk)
+ //~| ERROR evaluate(Binder { value: TraitPredicate(<MaskedStorage<GenericComp<Pos>> as std::marker::Sized>, polarity:Positive), bound_vars: [] }) = Ok(EvaluatedToOk)
test::<MaskedStorage<GenericComp2<Pos>>>(make());
- //~^ ERROR evaluate(Binder(TraitPredicate(<MaskedStorage<GenericComp2<Pos>> as std::marker::Sized>, polarity:Positive), [])) = Ok(EvaluatedToOkModuloRegions)
- //~| ERROR evaluate(Binder(TraitPredicate(<MaskedStorage<GenericComp2<Pos>> as std::marker::Sized>, polarity:Positive), [])) = Ok(EvaluatedToOkModuloRegions)
+ //~^ ERROR evaluate(Binder { value: TraitPredicate(<MaskedStorage<GenericComp2<Pos>> as std::marker::Sized>, polarity:Positive), bound_vars: [] }) = Ok(EvaluatedToOkModuloRegions)
+ //~| ERROR evaluate(Binder { value: TraitPredicate(<MaskedStorage<GenericComp2<Pos>> as std::marker::Sized>, polarity:Positive), bound_vars: [] }) = Ok(EvaluatedToOkModuloRegions)
}
#[rustc_evaluate_where_clauses]
diff --git a/tests/ui/traits/issue-85360-eval-obligation-ice.stderr b/tests/ui/traits/issue-85360-eval-obligation-ice.stderr
index ebf977dd6..9590ea12c 100644
--- a/tests/ui/traits/issue-85360-eval-obligation-ice.stderr
+++ b/tests/ui/traits/issue-85360-eval-obligation-ice.stderr
@@ -1,4 +1,4 @@
-error: evaluate(Binder(TraitPredicate(<MaskedStorage<GenericComp<Pos>> as std::marker::Sized>, polarity:Positive), [])) = Ok(EvaluatedToOk)
+error: evaluate(Binder { value: TraitPredicate(<MaskedStorage<GenericComp<Pos>> as std::marker::Sized>, polarity:Positive), bound_vars: [] }) = Ok(EvaluatedToOk)
--> $DIR/issue-85360-eval-obligation-ice.rs:9:5
|
LL | test::<MaskedStorage<GenericComp<Pos>>>(make());
@@ -7,7 +7,7 @@ LL | test::<MaskedStorage<GenericComp<Pos>>>(make());
LL | fn test<T: Sized>(_: T) {}
| - predicate
-error: evaluate(Binder(TraitPredicate(<MaskedStorage<GenericComp<Pos>> as std::marker::Sized>, polarity:Positive), [])) = Ok(EvaluatedToOk)
+error: evaluate(Binder { value: TraitPredicate(<MaskedStorage<GenericComp<Pos>> as std::marker::Sized>, polarity:Positive), bound_vars: [] }) = Ok(EvaluatedToOk)
--> $DIR/issue-85360-eval-obligation-ice.rs:9:5
|
LL | test::<MaskedStorage<GenericComp<Pos>>>(make());
@@ -16,7 +16,7 @@ LL | test::<MaskedStorage<GenericComp<Pos>>>(make());
LL | fn test<T: Sized>(_: T) {}
| ----- predicate
-error: evaluate(Binder(TraitPredicate(<MaskedStorage<GenericComp2<Pos>> as std::marker::Sized>, polarity:Positive), [])) = Ok(EvaluatedToOkModuloRegions)
+error: evaluate(Binder { value: TraitPredicate(<MaskedStorage<GenericComp2<Pos>> as std::marker::Sized>, polarity:Positive), bound_vars: [] }) = Ok(EvaluatedToOkModuloRegions)
--> $DIR/issue-85360-eval-obligation-ice.rs:13:5
|
LL | test::<MaskedStorage<GenericComp2<Pos>>>(make());
@@ -25,7 +25,7 @@ LL | test::<MaskedStorage<GenericComp2<Pos>>>(make());
LL | fn test<T: Sized>(_: T) {}
| - predicate
-error: evaluate(Binder(TraitPredicate(<MaskedStorage<GenericComp2<Pos>> as std::marker::Sized>, polarity:Positive), [])) = Ok(EvaluatedToOkModuloRegions)
+error: evaluate(Binder { value: TraitPredicate(<MaskedStorage<GenericComp2<Pos>> as std::marker::Sized>, polarity:Positive), bound_vars: [] }) = Ok(EvaluatedToOkModuloRegions)
--> $DIR/issue-85360-eval-obligation-ice.rs:13:5
|
LL | test::<MaskedStorage<GenericComp2<Pos>>>(make());
diff --git a/tests/ui/traits/issue-91949-hangs-on-recursion.rs b/tests/ui/traits/issue-91949-hangs-on-recursion.rs
index 4eca643a9..312d5d08c 100644
--- a/tests/ui/traits/issue-91949-hangs-on-recursion.rs
+++ b/tests/ui/traits/issue-91949-hangs-on-recursion.rs
@@ -3,6 +3,7 @@
// error-pattern: overflow evaluating the requirement `<std::iter::Empty<()> as Iterator>::Item == ()`
// error-pattern: function cannot return without recursing
// normalize-stderr-test: "long-type-\d+" -> "long-type-hash"
+// ignore-compare-mode-next-solver (hangs)
// Regression test for #91949.
// This hanged *forever* on 1.56, fixed by #90423.
diff --git a/tests/ui/traits/issue-91949-hangs-on-recursion.stderr b/tests/ui/traits/issue-91949-hangs-on-recursion.stderr
index 144990d50..c721dd41a 100644
--- a/tests/ui/traits/issue-91949-hangs-on-recursion.stderr
+++ b/tests/ui/traits/issue-91949-hangs-on-recursion.stderr
@@ -1,5 +1,5 @@
warning: function cannot return without recursing
- --> $DIR/issue-91949-hangs-on-recursion.rs:23:1
+ --> $DIR/issue-91949-hangs-on-recursion.rs:24:1
|
LL | / fn recurse<T>(elements: T) -> Vec<char>
LL | | where
@@ -16,7 +16,7 @@ error[E0275]: overflow evaluating the requirement `<std::iter::Empty<()> as Iter
|
= help: consider increasing the recursion limit by adding a `#![recursion_limit = "512"]` attribute to your crate (`issue_91949_hangs_on_recursion`)
note: required for `IteratorOfWrapped<(), std::iter::Empty<()>>` to implement `Iterator`
- --> $DIR/issue-91949-hangs-on-recursion.rs:16:32
+ --> $DIR/issue-91949-hangs-on-recursion.rs:17:32
|
LL | impl<T, I: Iterator<Item = T>> Iterator for IteratorOfWrapped<T, I> {
| -------- ^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^
diff --git a/tests/ui/traits/new-solver/alias-bound-unsound.rs b/tests/ui/traits/new-solver/alias-bound-unsound.rs
index 00294c708..959f1afa0 100644
--- a/tests/ui/traits/new-solver/alias-bound-unsound.rs
+++ b/tests/ui/traits/new-solver/alias-bound-unsound.rs
@@ -21,7 +21,7 @@ impl Foo for () {
fn main() {
let x = String::from("hello, world");
drop(<() as Foo>::copy_me(&x));
- //~^ ERROR `<() as Foo>::Item: Copy` is not satisfied
+ //~^ ERROR the type `&<() as Foo>::Item` is not well-formed
//~| ERROR `<() as Foo>::Item` is not well-formed
println!("{x}");
}
diff --git a/tests/ui/traits/new-solver/alias-bound-unsound.stderr b/tests/ui/traits/new-solver/alias-bound-unsound.stderr
index 9a43d2a66..5800e2c43 100644
--- a/tests/ui/traits/new-solver/alias-bound-unsound.stderr
+++ b/tests/ui/traits/new-solver/alias-bound-unsound.stderr
@@ -1,17 +1,8 @@
-error[E0277]: the trait bound `<() as Foo>::Item: Copy` is not satisfied
- --> $DIR/alias-bound-unsound.rs:23:10
+error: the type `&<() as Foo>::Item` is not well-formed
+ --> $DIR/alias-bound-unsound.rs:23:31
|
LL | drop(<() as Foo>::copy_me(&x));
- | ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `<() as Foo>::Item`
- |
-note: required by a bound in `Foo::Item`
- --> $DIR/alias-bound-unsound.rs:10:30
- |
-LL | type Item: Copy
- | ---- required by a bound in this associated type
-LL | where
-LL | <Self as Foo>::Item: Copy;
- | ^^^^ required by this bound in `Foo::Item`
+ | ^^
error: the type `<() as Foo>::Item` is not well-formed
--> $DIR/alias-bound-unsound.rs:23:10
@@ -21,4 +12,3 @@ LL | drop(<() as Foo>::copy_me(&x));
error: aborting due to 2 previous errors
-For more information about this error, try `rustc --explain E0277`.
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
index b036411be..204f6e8b0 100644
--- 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
@@ -1,22 +1,17 @@
// compile-flags: -Ztrait-solver=next
-// check-pass
-// (should not pass, should be turned into a coherence-only test)
-
-// 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
+// check that a `alias-eq(<?a as TraitB>::Assoc, <?b as TraitB>::Assoc)` goal fails
+// during coherence. We must not incorrectly constrain `?a` and `?b` to be
+// equal.
trait TraitB {
type Assoc;
}
-fn needs_a<T: TraitB>() -> T::Assoc {
- unimplemented!()
-}
+trait Overlaps<T> {}
-fn bar<T: TraitB>() {
- let _: <_ as TraitB>::Assoc = needs_a::<T>();
-}
+impl<T: TraitB> Overlaps<Box<T>> for <T as TraitB>::Assoc {}
+impl<U: TraitB> Overlaps<U> for <U as TraitB>::Assoc {}
+//~^ ERROR conflicting implementations of trait
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..8eda64e44
--- /dev/null
+++ b/tests/ui/traits/new-solver/alias_eq_substs_eq_not_intercrate.stderr
@@ -0,0 +1,11 @@
+error[E0119]: conflicting implementations of trait `Overlaps<Box<_>>` for type `<_ as TraitB>::Assoc`
+ --> $DIR/alias_eq_substs_eq_not_intercrate.rs:14:1
+ |
+LL | impl<T: TraitB> Overlaps<Box<T>> for <T as TraitB>::Assoc {}
+ | --------------------------------------------------------- first implementation here
+LL | impl<U: TraitB> Overlaps<U> for <U as TraitB>::Assoc {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `<_ as TraitB>::Assoc`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0119`.
diff --git a/tests/ui/traits/new-solver/array-default.rs b/tests/ui/traits/new-solver/array-default.rs
new file mode 100644
index 000000000..5077137b0
--- /dev/null
+++ b/tests/ui/traits/new-solver/array-default.rs
@@ -0,0 +1,8 @@
+// compile-flags: -Ztrait-solver=next
+// check-pass
+
+fn has_default<const N: usize>() where [(); N]: Default {}
+
+fn main() {
+ has_default::<1>();
+}
diff --git a/tests/ui/traits/new-solver/async.fail.stderr b/tests/ui/traits/new-solver/async.fail.stderr
index b395c23ae..72fa2eb31 100644
--- a/tests/ui/traits/new-solver/async.fail.stderr
+++ b/tests/ui/traits/new-solver/async.fail.stderr
@@ -1,8 +1,8 @@
-error[E0271]: expected `[async block@$DIR/async.rs:12:17: 12:25]` to be a future that resolves to `i32`, but it resolves to `()`
+error[E0271]: type mismatch resolving `<[async block@$DIR/async.rs:12:17: 12:25] as Future>::Output == i32`
--> $DIR/async.rs:12:17
|
LL | needs_async(async {});
- | ----------- ^^^^^^^^ expected `i32`, found `()`
+ | ----------- ^^^^^^^^ types differ
| |
| required by a bound introduced by this call
|
diff --git a/tests/ui/traits/new-solver/async.rs b/tests/ui/traits/new-solver/async.rs
index 195cc35ca..155b71eb7 100644
--- a/tests/ui/traits/new-solver/async.rs
+++ b/tests/ui/traits/new-solver/async.rs
@@ -10,7 +10,7 @@ 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 `()`
+ //[fail]~^ ERROR type mismatch
}
#[cfg(pass)]
diff --git a/tests/ui/traits/new-solver/closure-substs-ambiguity.rs b/tests/ui/traits/new-solver/closure-substs-ambiguity.rs
new file mode 100644
index 000000000..48432f402
--- /dev/null
+++ b/tests/ui/traits/new-solver/closure-substs-ambiguity.rs
@@ -0,0 +1,7 @@
+// compile-flags: -Ztrait-solver=next
+// check-pass
+
+fn main() {
+ let mut x: Vec<_> = vec![];
+ x.extend(Some(1i32).into_iter().map(|x| x));
+}
diff --git a/tests/ui/traits/new-solver/dedup-regions.rs b/tests/ui/traits/new-solver/dedup-regions.rs
new file mode 100644
index 000000000..f376f39a5
--- /dev/null
+++ b/tests/ui/traits/new-solver/dedup-regions.rs
@@ -0,0 +1,31 @@
+// compile-flags: -Ztrait-solver=next
+// check-pass
+
+struct A(*mut ());
+
+unsafe impl Send for A where A: 'static {}
+
+macro_rules! mk {
+ ($name:ident $ty:ty) => {
+ struct $name($ty, $ty, $ty, $ty, $ty, $ty, $ty, $ty, $ty, $ty);
+ };
+}
+
+mk!(B A);
+mk!(C B);
+mk!(D C);
+mk!(E D);
+mk!(F E);
+mk!(G F);
+mk!(H G);
+mk!(I H);
+mk!(J I);
+mk!(K J);
+mk!(L K);
+mk!(M L);
+
+fn needs_send<T: Send>() {}
+
+fn main() {
+ needs_send::<M>();
+}
diff --git a/tests/ui/traits/new-solver/dont-remap-tait-substs.rs b/tests/ui/traits/new-solver/dont-remap-tait-substs.rs
new file mode 100644
index 000000000..309bee8aa
--- /dev/null
+++ b/tests/ui/traits/new-solver/dont-remap-tait-substs.rs
@@ -0,0 +1,19 @@
+// compile-flags: -Ztrait-solver=next
+// check-pass
+
+// Makes sure we don't prepopulate the MIR typeck of `define`
+// with `Foo<T, U> = T`, but instead, `Foo<B, A> = B`, so that
+// the param-env predicates actually apply.
+
+#![feature(type_alias_impl_trait)]
+
+type Foo<T: Send, U> = impl NeedsSend<T>;
+
+trait NeedsSend<T> {}
+impl<T: Send> NeedsSend<T> for T {}
+
+fn define<A, B: Send>(a: A, b: B, _: Foo<B, A>) {
+ let y: Option<Foo<B, A>> = Some(b);
+}
+
+fn main() {}
diff --git a/tests/ui/traits/new-solver/dont-type_of-tait-in-defining-scope.not_send.stderr b/tests/ui/traits/new-solver/dont-type_of-tait-in-defining-scope.not_send.stderr
new file mode 100644
index 000000000..ec1c3231a
--- /dev/null
+++ b/tests/ui/traits/new-solver/dont-type_of-tait-in-defining-scope.not_send.stderr
@@ -0,0 +1,16 @@
+error[E0283]: type annotations needed: cannot satisfy `Foo: Send`
+ --> $DIR/dont-type_of-tait-in-defining-scope.rs:16:5
+ |
+LL | needs_send::<Foo>();
+ | ^^^^^^^^^^^^^^^^^
+ |
+ = note: cannot satisfy `Foo: Send`
+note: required by a bound in `needs_send`
+ --> $DIR/dont-type_of-tait-in-defining-scope.rs:13:18
+ |
+LL | fn needs_send<T: Send>() {}
+ | ^^^^ required by this bound in `needs_send`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0283`.
diff --git a/tests/ui/traits/new-solver/dont-type_of-tait-in-defining-scope.rs b/tests/ui/traits/new-solver/dont-type_of-tait-in-defining-scope.rs
new file mode 100644
index 000000000..08f14d749
--- /dev/null
+++ b/tests/ui/traits/new-solver/dont-type_of-tait-in-defining-scope.rs
@@ -0,0 +1,24 @@
+// revisions: is_send not_send
+// compile-flags: -Ztrait-solver=next
+//[is_send] check-pass
+
+#![feature(type_alias_impl_trait)]
+
+#[cfg(is_send)]
+type Foo = impl Send;
+
+#[cfg(not_send)]
+type Foo = impl Sized;
+
+fn needs_send<T: Send>() {}
+
+fn test(_: Foo) {
+ needs_send::<Foo>();
+ //[not_send]~^ ERROR type annotations needed: cannot satisfy `Foo: Send`
+}
+
+fn defines(_: Foo) {
+ let _: Foo = ();
+}
+
+fn main() {}
diff --git a/tests/ui/traits/new-solver/dyn-any-dont-prefer-impl.rs b/tests/ui/traits/new-solver/dyn-any-dont-prefer-impl.rs
new file mode 100644
index 000000000..7d15b8c63
--- /dev/null
+++ b/tests/ui/traits/new-solver/dyn-any-dont-prefer-impl.rs
@@ -0,0 +1,13 @@
+// compile-flags: -Ztrait-solver=next
+// check-pass
+
+use std::any::Any;
+
+fn needs_usize(_: &usize) {}
+
+fn main() {
+ let x: &dyn Any = &1usize;
+ if let Some(x) = x.downcast_ref::<usize>() {
+ needs_usize(x);
+ }
+}
diff --git a/tests/ui/traits/new-solver/equating-projection-cyclically.rs b/tests/ui/traits/new-solver/equating-projection-cyclically.rs
index 019c6e81c..2668da1b7 100644
--- a/tests/ui/traits/new-solver/equating-projection-cyclically.rs
+++ b/tests/ui/traits/new-solver/equating-projection-cyclically.rs
@@ -1,11 +1,10 @@
// compile-flags: -Ztrait-solver=next
-// known-bug: unknown
trait Test {
type Assoc;
}
-fn transform<T: Test>(x: T) -> T::Assoc {
+fn transform<T: Test>(x: Inv<T>) -> Inv<T::Assoc> {
todo!()
}
@@ -17,8 +16,13 @@ impl Test for String {
type Assoc = String;
}
+struct Inv<T>(Option<*mut T>);
+
fn main() {
- let mut x = Default::default();
+ let mut x: Inv<_> = Inv(None);
+ // This ends up equating `Inv<?x>` with `Inv<<?x as Test>::Assoc>`
+ // which fails the occurs check when generalizing `?x`.
x = transform(x);
- x = 1i32;
+ //~^ ERROR mismatched types
+ x = Inv::<i32>(None);
}
diff --git a/tests/ui/traits/new-solver/equating-projection-cyclically.stderr b/tests/ui/traits/new-solver/equating-projection-cyclically.stderr
index 57cbc65a1..6031d4f08 100644
--- a/tests/ui/traits/new-solver/equating-projection-cyclically.stderr
+++ b/tests/ui/traits/new-solver/equating-projection-cyclically.stderr
@@ -1,13 +1,8 @@
error[E0308]: mismatched types
- --> $DIR/equating-projection-cyclically.rs:22:19
+ --> $DIR/equating-projection-cyclically.rs:25:9
|
LL | x = transform(x);
- | ^ expected inferred type, found associated type
- |
- = note: expected type `_`
- found associated type `<_ as Test>::Assoc`
- = help: consider constraining the associated type `<_ as Test>::Assoc` to `_`
- = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html
+ | ^^^^^^^^^^^^ cyclic type of infinite size
error: aborting due to previous error
diff --git a/tests/ui/traits/new-solver/lazy-nested-obligations-2.rs b/tests/ui/traits/new-solver/lazy-nested-obligations-2.rs
index 32addd829..fd91d81cd 100644
--- a/tests/ui/traits/new-solver/lazy-nested-obligations-2.rs
+++ b/tests/ui/traits/new-solver/lazy-nested-obligations-2.rs
@@ -1,6 +1,5 @@
-// check-pass
// compile-flags: -Ztrait-solver=next
-// Issue 95863
+// known-bug: #95863
pub trait With {
type F;
diff --git a/tests/ui/traits/new-solver/lazy-nested-obligations-2.stderr b/tests/ui/traits/new-solver/lazy-nested-obligations-2.stderr
new file mode 100644
index 000000000..d0a4cd661
--- /dev/null
+++ b/tests/ui/traits/new-solver/lazy-nested-obligations-2.stderr
@@ -0,0 +1,39 @@
+error[E0308]: mismatched types
+ --> $DIR/lazy-nested-obligations-2.rs:15:23
+ |
+LL | let _: V<i32> = V(f);
+ | - ^ types differ
+ | |
+ | arguments to this struct are incorrect
+ |
+ = note: expected associated type `<i32 as With>::F`
+ found fn item `for<'a> fn(&'a str) {f}`
+ = help: consider constraining the associated type `<i32 as With>::F` to `for<'a> fn(&'a str) {f}` or calling a method that returns `<i32 as With>::F`
+ = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html
+note: tuple struct defined here
+ --> $DIR/lazy-nested-obligations-2.rs:16:16
+ |
+LL | pub struct V<T: With>(<T as With>::F);
+ | ^
+
+error[E0308]: mismatched types
+ --> $DIR/lazy-nested-obligations-2.rs:21:30
+ |
+LL | let _: E3<i32> = E3::Var(f);
+ | ------- ^ types differ
+ | |
+ | arguments to this enum variant are incorrect
+ |
+ = note: expected associated type `<i32 as With>::F`
+ found fn item `for<'a> fn(&'a str) {f}`
+ = help: consider constraining the associated type `<i32 as With>::F` to `for<'a> fn(&'a str) {f}` or calling a method that returns `<i32 as With>::F`
+ = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html
+note: tuple variant defined here
+ --> $DIR/lazy-nested-obligations-2.rs:19:9
+ |
+LL | Var(<T as With>::F),
+ | ^^^
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0308`.
diff --git a/tests/ui/traits/new-solver/leak-check-coinductive-cycle.rs b/tests/ui/traits/new-solver/leak-check-coinductive-cycle.rs
new file mode 100644
index 000000000..1f7d4a49c
--- /dev/null
+++ b/tests/ui/traits/new-solver/leak-check-coinductive-cycle.rs
@@ -0,0 +1,33 @@
+// check-pass
+// compile-flags: -Ztrait-solver=next
+#![feature(rustc_attrs)]
+
+#[rustc_coinductive]
+trait Trait<T> {}
+impl<'a, 'b, T> Trait<T> for (&'a (), &'b ())
+where
+ 'b: 'a,
+ &'a (): Trait<T>,
+{}
+
+impl Trait<i32> for &'static () {}
+impl<'a> Trait<u32> for &'a ()
+where
+ for<'b> (&'a (), &'b ()): Trait<u32>,
+{}
+
+
+fn impls_trait<T: Trait<U>, U>() {}
+
+fn main() {
+ // This infers to `impls_trait::<(&'static (), &'static ()), i32>();`
+ //
+ // In the first attempt we have 2 candidates for `&'a (): Trait<_>`
+ // and we get ambiguity. The result is therefore ambiguity with a `'b: 'a`
+ // constraint. The next attempt then uses that provisional result when
+ // trying to apply `impl<'a> Trait<u32> for &'a ()`. This means we get a
+ // `for<'b> 'b: 'a` bound which fails the leak check. Because of this we
+ // end up with a single impl for `&'a (): Trait<_>` which infers `_` to `i32`
+ // and succeeds.
+ impls_trait::<(&(), &()), _>();
+}
diff --git a/tests/ui/traits/new-solver/member-constraints-in-root-universe.rs b/tests/ui/traits/new-solver/member-constraints-in-root-universe.rs
new file mode 100644
index 000000000..97c443058
--- /dev/null
+++ b/tests/ui/traits/new-solver/member-constraints-in-root-universe.rs
@@ -0,0 +1,17 @@
+// compile-flags: -Ztrait-solver=next
+// check-pass
+
+trait Trait {
+ type Ty;
+}
+
+impl Trait for for<'a> fn(&'a u8, &'a u8) {
+ type Ty = ();
+}
+
+// argument is necessary to create universes before registering the hidden type.
+fn test<'a>(_: <fn(&u8, &u8) as Trait>::Ty) -> impl Sized {
+ "hidden type is `&'?0 str` with '?0 member of ['static,]"
+}
+
+fn main() {}
diff --git a/tests/ui/traits/new-solver/normalized-const-built-in-op.rs b/tests/ui/traits/new-solver/normalized-const-built-in-op.rs
new file mode 100644
index 000000000..2443e5178
--- /dev/null
+++ b/tests/ui/traits/new-solver/normalized-const-built-in-op.rs
@@ -0,0 +1,11 @@
+// compile-flags: -Ztrait-solver=next
+// check-pass
+
+const fn foo() {
+ let mut x = [1, 2, 3];
+ // We need to fix up `<<[i32; 3] as Index<usize>>::Output as AddAssign>`
+ // to be treated like a built-in operation.
+ x[1] += 5;
+}
+
+fn main() {}
diff --git a/tests/ui/traits/new-solver/object-unsafety.rs b/tests/ui/traits/new-solver/object-unsafety.rs
index 7bdd863a7..da843c914 100644
--- a/tests/ui/traits/new-solver/object-unsafety.rs
+++ b/tests/ui/traits/new-solver/object-unsafety.rs
@@ -10,7 +10,15 @@ fn copy<U: Setup + ?Sized>(from: &U::From) -> U::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
+ //~^ ERROR the type `&<dyn Setup<From = T> as Setup>::From` is not well-formed
+ //~| ERROR the trait bound `dyn Setup<From = T>: Setup` is not satisfied
+ //~| ERROR mismatched types
+ //~| ERROR mismatched types
+ //~| ERROR the type `<dyn Setup<From = T> as Setup>::From` is not well-formed
+ //~| ERROR the size for values of type `<dyn Setup<From = T> as Setup>::From` cannot be known at compilation time
+
+ // FIXME(-Ztrait-solver=next): These error messages are horrible and some of them
+ // are even simple fallout from previous error.
}
fn main() {
diff --git a/tests/ui/traits/new-solver/object-unsafety.stderr b/tests/ui/traits/new-solver/object-unsafety.stderr
index 198ac623d..bb7c68b89 100644
--- a/tests/ui/traits/new-solver/object-unsafety.stderr
+++ b/tests/ui/traits/new-solver/object-unsafety.stderr
@@ -14,6 +14,65 @@ help: consider introducing a `where` clause, but there might be an alternative b
LL | pub fn copy_any<T>(t: &T) -> T where dyn Setup<From = T>: Setup {
| ++++++++++++++++++++++++++++++++
-error: aborting due to previous error
+error: the type `&<dyn Setup<From = T> as Setup>::From` is not well-formed
+ --> $DIR/object-unsafety.rs:12:31
+ |
+LL | copy::<dyn Setup<From=T>>(t)
+ | ^
+
+error[E0308]: mismatched types
+ --> $DIR/object-unsafety.rs:12:31
+ |
+LL | copy::<dyn Setup<From=T>>(t)
+ | ------------------------- ^ types differ
+ | |
+ | arguments to this function are incorrect
+ |
+ = note: expected reference `&<dyn Setup<From = T> as Setup>::From`
+ found reference `&T`
+note: function defined here
+ --> $DIR/object-unsafety.rs:7:4
+ |
+LL | fn copy<U: Setup + ?Sized>(from: &U::From) -> U::From {
+ | ^^^^ --------------
+
+error[E0308]: mismatched types
+ --> $DIR/object-unsafety.rs:12:5
+ |
+LL | pub fn copy_any<T>(t: &T) -> T {
+ | - - expected `T` because of return type
+ | |
+ | this type parameter
+LL | copy::<dyn Setup<From=T>>(t)
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ types differ
+ |
+ = note: expected type parameter `T`
+ found associated type `<dyn Setup<From = T> as Setup>::From`
+ = note: you might be missing a type parameter or trait bound
+
+error: the type `<dyn Setup<From = T> as Setup>::From` is not well-formed
+ --> $DIR/object-unsafety.rs:12:5
+ |
+LL | copy::<dyn Setup<From=T>>(t)
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error[E0277]: the size for values of type `<dyn Setup<From = T> as Setup>::From` cannot be known at compilation time
+ --> $DIR/object-unsafety.rs:12:5
+ |
+LL | copy::<dyn Setup<From=T>>(t)
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^---
+ | |
+ | doesn't have a size known at compile-time
+ | this returned value is of type `<dyn Setup<From = T> as Setup>::From`
+ |
+ = help: the trait `Sized` is not implemented for `<dyn Setup<From = T> as Setup>::From`
+ = note: the return type of a function must have a statically known size
+help: consider further restricting the associated type
+ |
+LL | pub fn copy_any<T>(t: &T) -> T where <dyn Setup<From = T> as Setup>::From: Sized {
+ | +++++++++++++++++++++++++++++++++++++++++++++++++
+
+error: aborting due to 6 previous errors
-For more information about this error, try `rustc --explain E0277`.
+Some errors have detailed explanations: E0277, E0308.
+For more information about an error, try `rustc --explain E0277`.
diff --git a/tests/ui/traits/new-solver/opportunistic-region-resolve.rs b/tests/ui/traits/new-solver/opportunistic-region-resolve.rs
new file mode 100644
index 000000000..2610789cd
--- /dev/null
+++ b/tests/ui/traits/new-solver/opportunistic-region-resolve.rs
@@ -0,0 +1,19 @@
+// compile-flags: -Ztrait-solver=next
+// check-pass
+
+#![feature(rustc_attrs)]
+
+#[rustc_coinductive]
+trait Trait {}
+
+#[rustc_coinductive]
+trait Indirect {}
+impl<T: Trait + ?Sized> Indirect for T {}
+
+impl<'a> Trait for &'a () where &'a (): Indirect {}
+
+fn impls_trait<T: Trait>() {}
+
+fn main() {
+ impls_trait::<&'static ()>();
+}
diff --git a/tests/ui/traits/new-solver/recursive-self-normalization-2.rs b/tests/ui/traits/new-solver/recursive-self-normalization-2.rs
index 8c029f517..d086db475 100644
--- a/tests/ui/traits/new-solver/recursive-self-normalization-2.rs
+++ b/tests/ui/traits/new-solver/recursive-self-normalization-2.rs
@@ -1,3 +1,4 @@
+//~ ERROR overflow
// compile-flags: -Ztrait-solver=next
trait Foo1 {
diff --git a/tests/ui/traits/new-solver/recursive-self-normalization-2.stderr b/tests/ui/traits/new-solver/recursive-self-normalization-2.stderr
index 139b0a456..eebaf21d7 100644
--- a/tests/ui/traits/new-solver/recursive-self-normalization-2.stderr
+++ b/tests/ui/traits/new-solver/recursive-self-normalization-2.stderr
@@ -1,16 +1,20 @@
error[E0275]: overflow evaluating the requirement `<T as Foo1>::Assoc1: Bar`
- --> $DIR/recursive-self-normalization-2.rs:15:5
+ --> $DIR/recursive-self-normalization-2.rs:16:5
|
LL | needs_bar::<T::Assoc1>();
| ^^^^^^^^^^^^^^^^^^^^^^
|
= help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`recursive_self_normalization_2`)
note: required by a bound in `needs_bar`
- --> $DIR/recursive-self-normalization-2.rs:12:17
+ --> $DIR/recursive-self-normalization-2.rs:13:17
|
LL | fn needs_bar<S: Bar>() {}
| ^^^ required by this bound in `needs_bar`
-error: aborting due to previous error
+error[E0275]: overflow evaluating the requirement `<T as Foo2>::Assoc2`
+ |
+ = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`recursive_self_normalization_2`)
+
+error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0275`.
diff --git a/tests/ui/traits/new-solver/recursive-self-normalization.rs b/tests/ui/traits/new-solver/recursive-self-normalization.rs
index 06d187b5f..d15df7dea 100644
--- a/tests/ui/traits/new-solver/recursive-self-normalization.rs
+++ b/tests/ui/traits/new-solver/recursive-self-normalization.rs
@@ -1,3 +1,4 @@
+//~ ERROR overflow evaluating the requirement `<T as Foo>::Assoc` [E0275]
// compile-flags: -Ztrait-solver=next
trait Foo {
diff --git a/tests/ui/traits/new-solver/recursive-self-normalization.stderr b/tests/ui/traits/new-solver/recursive-self-normalization.stderr
index 8e9b9b4b4..6a87fe2f1 100644
--- a/tests/ui/traits/new-solver/recursive-self-normalization.stderr
+++ b/tests/ui/traits/new-solver/recursive-self-normalization.stderr
@@ -1,16 +1,20 @@
error[E0275]: overflow evaluating the requirement `<T as Foo>::Assoc: Bar`
- --> $DIR/recursive-self-normalization.rs:11:5
+ --> $DIR/recursive-self-normalization.rs:12:5
|
LL | needs_bar::<T::Assoc>();
| ^^^^^^^^^^^^^^^^^^^^^
|
= help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`recursive_self_normalization`)
note: required by a bound in `needs_bar`
- --> $DIR/recursive-self-normalization.rs:8:17
+ --> $DIR/recursive-self-normalization.rs:9:17
|
LL | fn needs_bar<S: Bar>() {}
| ^^^ required by this bound in `needs_bar`
-error: aborting due to previous error
+error[E0275]: overflow evaluating the requirement `<T as Foo>::Assoc`
+ |
+ = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`recursive_self_normalization`)
+
+error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0275`.
diff --git a/tests/ui/traits/new-solver/slice-match-byte-lit.rs b/tests/ui/traits/new-solver/slice-match-byte-lit.rs
new file mode 100644
index 000000000..4f8480625
--- /dev/null
+++ b/tests/ui/traits/new-solver/slice-match-byte-lit.rs
@@ -0,0 +1,11 @@
+// compile-flags: -Ztrait-solver=next
+// check-pass
+
+fn test(s: &[u8]) {
+ match &s[0..3] {
+ b"uwu" => {}
+ _ => {}
+ }
+}
+
+fn main() {}
diff --git a/tests/ui/traits/new-solver/specialization-transmute.rs b/tests/ui/traits/new-solver/specialization-transmute.rs
index a54701df4..f6b19e7ad 100644
--- a/tests/ui/traits/new-solver/specialization-transmute.rs
+++ b/tests/ui/traits/new-solver/specialization-transmute.rs
@@ -10,12 +10,11 @@ trait Default {
}
impl<T> Default for T {
- default type Id = T;
-
- fn intu(&self) -> &Self::Id {
+ default type Id = T;
+ // This will be fixed by #111994
+ fn intu(&self) -> &Self::Id { //~ ERROR type annotations needed
self
- //~^ ERROR cannot satisfy `T <: <T as Default>::Id`
- }
+ }
}
fn transmute<T: Default<Id = U>, U: Copy>(t: T) -> U {
@@ -24,7 +23,6 @@ fn transmute<T: Default<Id = U>, U: Copy>(t: T) -> U {
use std::num::NonZeroU8;
fn main() {
- let s = transmute::<u8, Option<NonZeroU8>>(0);
- //~^ ERROR cannot satisfy `<u8 as Default>::Id == Option<NonZeroU8>
+ let s = transmute::<u8, Option<NonZeroU8>>(0); // this call should then error
assert_eq!(s, None);
}
diff --git a/tests/ui/traits/new-solver/specialization-transmute.stderr b/tests/ui/traits/new-solver/specialization-transmute.stderr
index e67c56afc..09b1405fe 100644
--- a/tests/ui/traits/new-solver/specialization-transmute.stderr
+++ b/tests/ui/traits/new-solver/specialization-transmute.stderr
@@ -8,24 +8,14 @@ LL | #![feature(specialization)]
= help: consider using `min_specialization` instead, which is more stable and complete
= note: `#[warn(incomplete_features)]` on by default
-error[E0284]: type annotations needed: cannot satisfy `T <: <T as Default>::Id`
- --> $DIR/specialization-transmute.rs:16:9
+error[E0284]: type annotations needed
+ --> $DIR/specialization-transmute.rs:15:23
|
-LL | self
- | ^^^^ cannot satisfy `T <: <T as Default>::Id`
-
-error[E0284]: type annotations needed: cannot satisfy `<u8 as Default>::Id == Option<NonZeroU8>`
- --> $DIR/specialization-transmute.rs:27:13
- |
-LL | let s = transmute::<u8, Option<NonZeroU8>>(0);
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot satisfy `<u8 as Default>::Id == Option<NonZeroU8>`
- |
-note: required by a bound in `transmute`
- --> $DIR/specialization-transmute.rs:21:25
+LL | fn intu(&self) -> &Self::Id {
+ | ^^^^^^^^^ cannot infer type
|
-LL | fn transmute<T: Default<Id = U>, U: Copy>(t: T) -> U {
- | ^^^^^^ required by this bound in `transmute`
+ = note: cannot satisfy `<T as Default>::Id == _`
-error: aborting due to 2 previous errors; 1 warning emitted
+error: aborting due to previous error; 1 warning emitted
For more information about this error, try `rustc --explain E0284`.
diff --git a/tests/ui/traits/new-solver/specialization-unconstrained.rs b/tests/ui/traits/new-solver/specialization-unconstrained.rs
index 02150689e..7fd753109 100644
--- a/tests/ui/traits/new-solver/specialization-unconstrained.rs
+++ b/tests/ui/traits/new-solver/specialization-unconstrained.rs
@@ -11,7 +11,7 @@ trait Default {
}
impl<T> Default for T {
- default type Id = T;
+ default type Id = T; //~ ERROR type annotations needed
}
fn test<T: Default<Id = U>, U>() {}
diff --git a/tests/ui/traits/new-solver/specialization-unconstrained.stderr b/tests/ui/traits/new-solver/specialization-unconstrained.stderr
index 910925cba..9915da1a2 100644
--- a/tests/ui/traits/new-solver/specialization-unconstrained.stderr
+++ b/tests/ui/traits/new-solver/specialization-unconstrained.stderr
@@ -8,6 +8,12 @@ LL | #![feature(specialization)]
= help: consider using `min_specialization` instead, which is more stable and complete
= note: `#[warn(incomplete_features)]` on by default
+error[E0282]: type annotations needed
+ --> $DIR/specialization-unconstrained.rs:14:22
+ |
+LL | default type Id = T;
+ | ^ cannot infer type for associated type `<T as Default>::Id`
+
error[E0284]: type annotations needed: cannot satisfy `<u32 as Default>::Id == ()`
--> $DIR/specialization-unconstrained.rs:20:5
|
@@ -20,6 +26,7 @@ note: required by a bound in `test`
LL | fn test<T: Default<Id = U>, U>() {}
| ^^^^^^ required by this bound in `test`
-error: aborting due to previous error; 1 warning emitted
+error: aborting due to 2 previous errors; 1 warning emitted
-For more information about this error, try `rustc --explain E0284`.
+Some errors have detailed explanations: E0282, E0284.
+For more information about an error, try `rustc --explain E0282`.
diff --git a/tests/ui/traits/new-solver/tait-eq-proj-2.rs b/tests/ui/traits/new-solver/tait-eq-proj-2.rs
new file mode 100644
index 000000000..77ea8bc24
--- /dev/null
+++ b/tests/ui/traits/new-solver/tait-eq-proj-2.rs
@@ -0,0 +1,23 @@
+// compile-flags: -Ztrait-solver=next
+// check-pass
+
+#![feature(type_alias_impl_trait)]
+
+// Similar to tests/ui/traits/new-solver/tait-eq-proj.rs
+// but check the alias-sub relation in the other direction.
+
+type Tait = impl Iterator<Item = impl Sized>;
+
+fn mk<T>() -> T {
+ todo!()
+}
+
+fn a(_: Tait) {
+ let x: Tait = mk();
+ let mut array = mk();
+ let mut z = IntoIterator::into_iter(array);
+ z = x;
+ array = [0i32; 32];
+}
+
+fn main() {}
diff --git a/tests/ui/traits/new-solver/tait-eq-proj.rs b/tests/ui/traits/new-solver/tait-eq-proj.rs
new file mode 100644
index 000000000..01ef2ec95
--- /dev/null
+++ b/tests/ui/traits/new-solver/tait-eq-proj.rs
@@ -0,0 +1,35 @@
+// compile-flags: -Ztrait-solver=next
+// check-pass
+
+#![feature(type_alias_impl_trait)]
+
+type Tait = impl Iterator<Item = impl Sized>;
+
+/*
+
+Consider the goal - AliasRelate(Tait, <[i32; 32] as IntoIterator>::IntoIter)
+which is registered on the line above.
+
+A. SubstRelate - fails (of course).
+
+B. NormalizesToRhs - Tait normalizes-to <[i32; 32] as IntoIterator>::IntoIter
+ * infer definition - Tait := <[i32; 32] as IntoIterator>::IntoIter
+
+C. NormalizesToLhs - <[i32; 32] as IntoIterator>::IntoIter normalizes-to Tait
+ * Find impl candidate, after substitute - std::array::IntoIter<i32, 32>
+ * Equate std::array::IntoIter<i32, 32> and Tait
+ * infer definition - Tait := std::array::IntoIter<i32, 32>
+
+B and C are not equal, but they are equivalent modulo normalization.
+
+We get around this by evaluating both the NormalizesToRhs and NormalizesToLhs
+goals together. Essentially:
+ A alias-relate B if A normalizes-to B and B normalizes-to A.
+
+*/
+
+fn a(_: Tait) {
+ let _: Tait = IntoIterator::into_iter([0i32; 32]);
+}
+
+fn main() {}
diff --git a/tests/ui/traits/new-solver/tait-eq-tait.rs b/tests/ui/traits/new-solver/tait-eq-tait.rs
new file mode 100644
index 000000000..70d9dc0ea
--- /dev/null
+++ b/tests/ui/traits/new-solver/tait-eq-tait.rs
@@ -0,0 +1,18 @@
+// compile-flags: -Ztrait-solver=next
+// check-pass
+
+// Not exactly sure if this is the inference behavior we *want*,
+// but it is a side-effect of the lazy normalization of TAITs.
+
+#![feature(type_alias_impl_trait)]
+
+fn mk<T>() -> T {
+ todo!()
+}
+
+fn main() {
+ type Tait = impl Sized;
+ type Tait2 = impl Sized;
+ let x: Tait = 1u32;
+ let y: Tait2 = x;
+}
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
index fa5e780ee..83a0452b0 100644
--- 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
@@ -5,6 +5,7 @@ LL | needs_bar::<T>();
| ^^^^^^^^^^^^^^
|
= note: cannot satisfy `T: Bar`
+ = help: the trait `Bar` is implemented for `T`
note: required by a bound in `needs_bar`
--> $DIR/two-projection-param-candidates-are-ambiguous.rs:23:17
|
diff --git a/tests/ui/traits/new-solver/unevaluated-const-impl-trait-ref.fails.stderr b/tests/ui/traits/new-solver/unevaluated-const-impl-trait-ref.fails.stderr
new file mode 100644
index 000000000..072ac32a5
--- /dev/null
+++ b/tests/ui/traits/new-solver/unevaluated-const-impl-trait-ref.fails.stderr
@@ -0,0 +1,18 @@
+error[E0277]: the trait bound `(): Trait<1>` is not satisfied
+ --> $DIR/unevaluated-const-impl-trait-ref.rs:20:13
+ |
+LL | needs::<1>();
+ | ^ the trait `Trait<1>` is not implemented for `()`
+ |
+ = help: the following other types implement trait `Trait<N>`:
+ <() as Trait<0>>
+ <() as Trait<2>>
+note: required by a bound in `needs`
+ --> $DIR/unevaluated-const-impl-trait-ref.rs:10:38
+ |
+LL | fn needs<const N: usize>() where (): Trait<N> {}
+ | ^^^^^^^^ required by this bound in `needs`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/traits/new-solver/unevaluated-const-impl-trait-ref.rs b/tests/ui/traits/new-solver/unevaluated-const-impl-trait-ref.rs
new file mode 100644
index 000000000..26c595bc9
--- /dev/null
+++ b/tests/ui/traits/new-solver/unevaluated-const-impl-trait-ref.rs
@@ -0,0 +1,22 @@
+// compile-flags: -Ztrait-solver=next
+// revisions: works fails
+//[works] check-pass
+
+trait Trait<const N: usize> {}
+
+impl Trait<{ 1 - 1 }> for () {}
+impl Trait<{ 1 + 1 }> for () {}
+
+fn needs<const N: usize>() where (): Trait<N> {}
+
+#[cfg(works)]
+fn main() {
+ needs::<0>();
+ needs::<2>();
+}
+
+#[cfg(fails)]
+fn main() {
+ needs::<1>();
+ //[fails]~^ ERROR the trait bound `(): Trait<1>` is not satisfied
+}
diff --git a/tests/ui/traits/new-solver/winnow-specializing-impls.rs b/tests/ui/traits/new-solver/winnow-specializing-impls.rs
new file mode 100644
index 000000000..06f64de74
--- /dev/null
+++ b/tests/ui/traits/new-solver/winnow-specializing-impls.rs
@@ -0,0 +1,22 @@
+// build-pass
+// compile-flags: -Ztrait-solver=next
+
+// Tests that the specializing impl `<() as Foo>` holds during codegen.
+
+#![feature(min_specialization)]
+
+trait Foo {
+ fn bar();
+}
+
+impl<T> Foo for T {
+ default fn bar() {}
+}
+
+impl Foo for () {
+ fn bar() {}
+}
+
+fn main() {
+ <() as Foo>::bar();
+}
diff --git a/tests/ui/traits/non_lifetime_binders/foreach-partial-eq.rs b/tests/ui/traits/non_lifetime_binders/foreach-partial-eq.rs
new file mode 100644
index 000000000..96a7424f0
--- /dev/null
+++ b/tests/ui/traits/non_lifetime_binders/foreach-partial-eq.rs
@@ -0,0 +1,12 @@
+#![feature(non_lifetime_binders)]
+//~^ WARN the feature `non_lifetime_binders` is incomplete
+
+fn auto_trait()
+where
+ for<T> T: PartialEq + PartialOrd,
+{}
+
+fn main() {
+ auto_trait();
+ //~^ ERROR can't compare `T` with `T`
+}
diff --git a/tests/ui/traits/non_lifetime_binders/foreach-partial-eq.stderr b/tests/ui/traits/non_lifetime_binders/foreach-partial-eq.stderr
new file mode 100644
index 000000000..da09343fb
--- /dev/null
+++ b/tests/ui/traits/non_lifetime_binders/foreach-partial-eq.stderr
@@ -0,0 +1,28 @@
+warning: the feature `non_lifetime_binders` is incomplete and may not be safe to use and/or cause compiler crashes
+ --> $DIR/foreach-partial-eq.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]: can't compare `T` with `T`
+ --> $DIR/foreach-partial-eq.rs:10:5
+ |
+LL | auto_trait();
+ | ^^^^^^^^^^ no implementation for `T < T` and `T > T`
+ |
+ = help: the trait `PartialOrd` is not implemented for `T`
+note: required by a bound in `auto_trait`
+ --> $DIR/foreach-partial-eq.rs:6:27
+ |
+LL | fn auto_trait()
+ | ---------- required by a bound in this function
+LL | where
+LL | for<T> T: PartialEq + PartialOrd,
+ | ^^^^^^^^^^ required by this bound in `auto_trait`
+
+error: aborting due to previous error; 1 warning emitted
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/traits/non_lifetime_binders/nested-apit-mentioning-outer-bound-var.rs b/tests/ui/traits/non_lifetime_binders/nested-apit-mentioning-outer-bound-var.rs
new file mode 100644
index 000000000..e9ae00df7
--- /dev/null
+++ b/tests/ui/traits/non_lifetime_binders/nested-apit-mentioning-outer-bound-var.rs
@@ -0,0 +1,11 @@
+#![feature(non_lifetime_binders)]
+//~^ WARN the feature `non_lifetime_binders` is incomplete
+
+trait Trait<Input> {
+ type Assoc;
+}
+
+fn uwu(_: impl for<T> Trait<(), Assoc = impl Trait<T>>) {}
+//~^ ERROR `impl Trait` can only mention type parameters from an fn or impl
+
+fn main() {}
diff --git a/tests/ui/traits/non_lifetime_binders/nested-apit-mentioning-outer-bound-var.stderr b/tests/ui/traits/non_lifetime_binders/nested-apit-mentioning-outer-bound-var.stderr
new file mode 100644
index 000000000..1124076c2
--- /dev/null
+++ b/tests/ui/traits/non_lifetime_binders/nested-apit-mentioning-outer-bound-var.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/nested-apit-mentioning-outer-bound-var.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: `impl Trait` can only mention type parameters from an fn or impl
+ --> $DIR/nested-apit-mentioning-outer-bound-var.rs:8:52
+ |
+LL | fn uwu(_: impl for<T> Trait<(), Assoc = impl Trait<T>>) {}
+ | - type parameter declared here ^
+
+error: aborting due to previous error; 1 warning emitted
+
diff --git a/tests/ui/traits/object/print_vtable_sizes.rs b/tests/ui/traits/object/print_vtable_sizes.rs
new file mode 100644
index 000000000..565609499
--- /dev/null
+++ b/tests/ui/traits/object/print_vtable_sizes.rs
@@ -0,0 +1,61 @@
+// check-pass
+// compile-flags: -Z print-vtable-sizes
+#![crate_type = "lib"]
+
+trait A<T: help::V>: AsRef<[T::V]> + AsMut<[T::V]> {}
+
+trait B<T>: AsRef<T> + AsRef<T> + AsRef<T> + AsRef<T> {}
+
+trait C {
+ fn x() {} // not object safe, shouldn't be reported
+}
+
+// This ideally should not have any upcasting cost,
+// but currently does due to a bug
+trait D: Send + Sync + help::MarkerWithSuper {}
+
+// This can't have no cost without reordering,
+// because `Super::f`.
+trait E: help::MarkerWithSuper + Send + Sync {}
+
+trait F {
+ fn a(&self);
+ fn b(&self);
+ fn c(&self);
+
+ fn d() -> Self
+ where
+ Self: Sized;
+}
+
+trait G: AsRef<u8> + AsRef<u16> + help::MarkerWithSuper {
+ fn a(&self);
+ fn b(&self);
+ fn c(&self);
+ fn d(&self);
+ fn e(&self);
+
+ fn f() -> Self
+ where
+ Self: Sized;
+}
+
+// Traits with the same name
+const _: () = {
+ trait S {}
+};
+const _: () = {
+ trait S {}
+};
+
+mod help {
+ pub trait V {
+ type V;
+ }
+
+ pub trait MarkerWithSuper: Super {}
+
+ pub trait Super {
+ fn f(&self);
+ }
+}
diff --git a/tests/ui/traits/object/print_vtable_sizes.stdout b/tests/ui/traits/object/print_vtable_sizes.stdout
new file mode 100644
index 000000000..3ba650bc3
--- /dev/null
+++ b/tests/ui/traits/object/print_vtable_sizes.stdout
@@ -0,0 +1,11 @@
+print-vtable-sizes { "crate_name": "<UNKNOWN_CRATE>", "trait_name": "D", "entries": "7", "entries_ignoring_upcasting": "4", "entries_for_upcasting": "3", "upcasting_cost_percent": "75" }
+print-vtable-sizes { "crate_name": "<UNKNOWN_CRATE>", "trait_name": "E", "entries": "6", "entries_ignoring_upcasting": "4", "entries_for_upcasting": "2", "upcasting_cost_percent": "50" }
+print-vtable-sizes { "crate_name": "<UNKNOWN_CRATE>", "trait_name": "G", "entries": "14", "entries_ignoring_upcasting": "11", "entries_for_upcasting": "3", "upcasting_cost_percent": "27.27272727272727" }
+print-vtable-sizes { "crate_name": "<UNKNOWN_CRATE>", "trait_name": "A", "entries": "6", "entries_ignoring_upcasting": "5", "entries_for_upcasting": "1", "upcasting_cost_percent": "20" }
+print-vtable-sizes { "crate_name": "<UNKNOWN_CRATE>", "trait_name": "B", "entries": "4", "entries_ignoring_upcasting": "4", "entries_for_upcasting": "0", "upcasting_cost_percent": "0" }
+print-vtable-sizes { "crate_name": "<UNKNOWN_CRATE>", "trait_name": "F", "entries": "6", "entries_ignoring_upcasting": "6", "entries_for_upcasting": "0", "upcasting_cost_percent": "0" }
+print-vtable-sizes { "crate_name": "<UNKNOWN_CRATE>", "trait_name": "_::S", "entries": "3", "entries_ignoring_upcasting": "3", "entries_for_upcasting": "0", "upcasting_cost_percent": "0" }
+print-vtable-sizes { "crate_name": "<UNKNOWN_CRATE>", "trait_name": "_::S", "entries": "3", "entries_ignoring_upcasting": "3", "entries_for_upcasting": "0", "upcasting_cost_percent": "0" }
+print-vtable-sizes { "crate_name": "<UNKNOWN_CRATE>", "trait_name": "help::MarkerWithSuper", "entries": "4", "entries_ignoring_upcasting": "4", "entries_for_upcasting": "0", "upcasting_cost_percent": "0" }
+print-vtable-sizes { "crate_name": "<UNKNOWN_CRATE>", "trait_name": "help::Super", "entries": "4", "entries_ignoring_upcasting": "4", "entries_for_upcasting": "0", "upcasting_cost_percent": "0" }
+print-vtable-sizes { "crate_name": "<UNKNOWN_CRATE>", "trait_name": "help::V", "entries": "3", "entries_ignoring_upcasting": "3", "entries_for_upcasting": "0", "upcasting_cost_percent": "0" }
diff --git a/tests/ui/traits/project-modulo-regions.rs b/tests/ui/traits/project-modulo-regions.rs
index f0c0dd3ed..e88f21ecf 100644
--- a/tests/ui/traits/project-modulo-regions.rs
+++ b/tests/ui/traits/project-modulo-regions.rs
@@ -48,8 +48,8 @@ fn test(val: MyStruct) where Helper: HelperTrait {
fn foo(val: MyStruct) {
test(val);
- //[with_clause]~^ ERROR evaluate(Binder(TraitPredicate(<Helper as HelperTrait>, polarity:Positive), [])) = Ok(EvaluatedToOkModuloRegions)
- //[without_clause]~^^ ERROR evaluate(Binder(TraitPredicate(<Helper as HelperTrait>, polarity:Positive), [])) = Ok(EvaluatedToOk)
+ //[with_clause]~^ ERROR evaluate(Binder { value: TraitPredicate(<Helper as HelperTrait>, polarity:Positive), bound_vars: [] }) = Ok(EvaluatedToOkModuloRegions)
+ //[without_clause]~^^ ERROR evaluate(Binder { value: TraitPredicate(<Helper as HelperTrait>, polarity:Positive), bound_vars: [] }) = Ok(EvaluatedToOk)
}
fn main() {}
diff --git a/tests/ui/traits/project-modulo-regions.with_clause.stderr b/tests/ui/traits/project-modulo-regions.with_clause.stderr
index 2434c32c8..dcc98e855 100644
--- a/tests/ui/traits/project-modulo-regions.with_clause.stderr
+++ b/tests/ui/traits/project-modulo-regions.with_clause.stderr
@@ -1,4 +1,4 @@
-error: evaluate(Binder(TraitPredicate(<Helper as HelperTrait>, polarity:Positive), [])) = Ok(EvaluatedToOkModuloRegions)
+error: evaluate(Binder { value: TraitPredicate(<Helper as HelperTrait>, polarity:Positive), bound_vars: [] }) = Ok(EvaluatedToOkModuloRegions)
--> $DIR/project-modulo-regions.rs:50:5
|
LL | fn test(val: MyStruct) where Helper: HelperTrait {
diff --git a/tests/ui/traits/project-modulo-regions.without_clause.stderr b/tests/ui/traits/project-modulo-regions.without_clause.stderr
index 9d35690d5..e9959567e 100644
--- a/tests/ui/traits/project-modulo-regions.without_clause.stderr
+++ b/tests/ui/traits/project-modulo-regions.without_clause.stderr
@@ -1,4 +1,4 @@
-error: evaluate(Binder(TraitPredicate(<Helper as HelperTrait>, polarity:Positive), [])) = Ok(EvaluatedToOk)
+error: evaluate(Binder { value: TraitPredicate(<Helper as HelperTrait>, polarity:Positive), bound_vars: [] }) = Ok(EvaluatedToOk)
--> $DIR/project-modulo-regions.rs:50:5
|
LL | fn test(val: MyStruct) where Helper: HelperTrait {
diff --git a/tests/ui/traits/suggest-where-clause.stderr b/tests/ui/traits/suggest-where-clause.stderr
index 44e63b78c..f3a4c6890 100644
--- a/tests/ui/traits/suggest-where-clause.stderr
+++ b/tests/ui/traits/suggest-where-clause.stderr
@@ -2,7 +2,7 @@ error[E0277]: the size for values of type `U` cannot be known at compilation tim
--> $DIR/suggest-where-clause.rs:7:20
|
LL | fn check<T: Iterator, U: ?Sized>() {
- | - this type parameter needs to be `std::marker::Sized`
+ | - this type parameter needs to be `Sized`
LL | // suggest a where-clause, if needed
LL | mem::size_of::<U>();
| ^ doesn't have a size known at compile-time
@@ -19,7 +19,7 @@ error[E0277]: the size for values of type `U` cannot be known at compilation tim
--> $DIR/suggest-where-clause.rs:10:20
|
LL | fn check<T: Iterator, U: ?Sized>() {
- | - this type parameter needs to be `std::marker::Sized`
+ | - this type parameter needs to be `Sized`
...
LL | mem::size_of::<Misc<U>>();
| ^^^^^^^ doesn't have a size known at compile-time
diff --git a/tests/ui/traits/trivial_impl.rs b/tests/ui/traits/trivial_impl.rs
new file mode 100644
index 000000000..6ac8c744b
--- /dev/null
+++ b/tests/ui/traits/trivial_impl.rs
@@ -0,0 +1,18 @@
+//! This test checks that we do need to implement
+//! all members, even if their where bounds only hold
+//! due to other impls.
+
+trait Foo<T> {
+ fn foo()
+ where
+ Self: Foo<()>;
+}
+
+impl Foo<()> for () {
+ fn foo() {}
+}
+
+impl Foo<u32> for () {}
+//~^ ERROR: not all trait items implemented, missing: `foo`
+
+fn main() {}
diff --git a/tests/ui/traits/trivial_impl.stderr b/tests/ui/traits/trivial_impl.stderr
new file mode 100644
index 000000000..4b29b55be
--- /dev/null
+++ b/tests/ui/traits/trivial_impl.stderr
@@ -0,0 +1,14 @@
+error[E0046]: not all trait items implemented, missing: `foo`
+ --> $DIR/trivial_impl.rs:15:1
+ |
+LL | / fn foo()
+LL | | where
+LL | | Self: Foo<()>;
+ | |______________________- `foo` from trait
+...
+LL | impl Foo<u32> for () {}
+ | ^^^^^^^^^^^^^^^^^^^^ missing `foo` in implementation
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0046`.
diff --git a/tests/ui/traits/trivial_impl2.rs b/tests/ui/traits/trivial_impl2.rs
new file mode 100644
index 000000000..be5809600
--- /dev/null
+++ b/tests/ui/traits/trivial_impl2.rs
@@ -0,0 +1,13 @@
+//! This test checks that we currently need to implement
+//! members, even if their where bounds don't hold for the impl type.
+
+trait Foo<T> {
+ fn foo()
+ where
+ Self: Foo<()>;
+}
+
+impl Foo<u32> for () {}
+//~^ ERROR: not all trait items implemented, missing: `foo`
+
+fn main() {}
diff --git a/tests/ui/traits/trivial_impl2.stderr b/tests/ui/traits/trivial_impl2.stderr
new file mode 100644
index 000000000..04c05df06
--- /dev/null
+++ b/tests/ui/traits/trivial_impl2.stderr
@@ -0,0 +1,14 @@
+error[E0046]: not all trait items implemented, missing: `foo`
+ --> $DIR/trivial_impl2.rs:10:1
+ |
+LL | / fn foo()
+LL | | where
+LL | | Self: Foo<()>;
+ | |______________________- `foo` from trait
+...
+LL | impl Foo<u32> for () {}
+ | ^^^^^^^^^^^^^^^^^^^^ missing `foo` in implementation
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0046`.
diff --git a/tests/ui/traits/trivial_impl3.rs b/tests/ui/traits/trivial_impl3.rs
new file mode 100644
index 000000000..714f643bc
--- /dev/null
+++ b/tests/ui/traits/trivial_impl3.rs
@@ -0,0 +1,19 @@
+//! Check that we don't break orphan rules.
+//! The dependency may add an impl for `u8` later,
+//! which would break this crate. We want to avoid adding
+//! more ways in which adding an impl can be a breaking change.
+
+// aux-build:trivial3.rs
+
+extern crate trivial3;
+
+pub trait Foo {
+ fn foo()
+ where
+ Self: trivial3::Trait;
+}
+
+impl Foo for u8 {}
+//~^ ERROR not all trait items implemented, missing: `foo`
+
+fn main() {}
diff --git a/tests/ui/traits/trivial_impl3.stderr b/tests/ui/traits/trivial_impl3.stderr
new file mode 100644
index 000000000..dfb39d6ce
--- /dev/null
+++ b/tests/ui/traits/trivial_impl3.stderr
@@ -0,0 +1,14 @@
+error[E0046]: not all trait items implemented, missing: `foo`
+ --> $DIR/trivial_impl3.rs:16:1
+ |
+LL | / fn foo()
+LL | | where
+LL | | Self: trivial3::Trait;
+ | |______________________________- `foo` from trait
+...
+LL | impl Foo for u8 {}
+ | ^^^^^^^^^^^^^^^ missing `foo` in implementation
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0046`.
diff --git a/tests/ui/traits/trivial_impl4.rs b/tests/ui/traits/trivial_impl4.rs
new file mode 100644
index 000000000..518f159c1
--- /dev/null
+++ b/tests/ui/traits/trivial_impl4.rs
@@ -0,0 +1,21 @@
+//! Check that we don't break orphan rules.
+//! The dependency may add an impl for `u8` later,
+//! which would break this crate. We want to avoid adding
+//! more ways in which adding an impl can be a breaking change.
+//! This test differs from `trivial_impl3` because there actually
+//! exists any impl for `Trait`, which has an effect on coherence.
+
+// aux-build:trivial4.rs
+
+extern crate trivial4;
+
+pub trait Foo {
+ fn foo()
+ where
+ Self: trivial4::Trait;
+}
+
+impl Foo for u8 {}
+//~^ ERROR not all trait items implemented, missing: `foo`
+
+fn main() {}
diff --git a/tests/ui/traits/trivial_impl4.stderr b/tests/ui/traits/trivial_impl4.stderr
new file mode 100644
index 000000000..04b29ed77
--- /dev/null
+++ b/tests/ui/traits/trivial_impl4.stderr
@@ -0,0 +1,14 @@
+error[E0046]: not all trait items implemented, missing: `foo`
+ --> $DIR/trivial_impl4.rs:18:1
+ |
+LL | / fn foo()
+LL | | where
+LL | | Self: trivial4::Trait;
+ | |______________________________- `foo` from trait
+...
+LL | impl Foo for u8 {}
+ | ^^^^^^^^^^^^^^^ missing `foo` in implementation
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0046`.
diff --git a/tests/ui/traits/trivial_impl_sized.rs b/tests/ui/traits/trivial_impl_sized.rs
new file mode 100644
index 000000000..501a34050
--- /dev/null
+++ b/tests/ui/traits/trivial_impl_sized.rs
@@ -0,0 +1,26 @@
+//! This test checks that we currently need to implement
+//! members, even if their where bounds don't hold for the impl type.
+
+trait Foo {
+ fn foo()
+ where
+ Self: Sized;
+}
+
+impl Foo for () {
+ fn foo() {}
+}
+
+// Must not be allowed
+impl Foo for i32 {}
+//~^ ERROR: not all trait items implemented, missing: `foo`
+
+// Should be allowed
+impl Foo for dyn std::fmt::Debug {}
+//~^ ERROR: not all trait items implemented, missing: `foo`
+
+impl Foo for dyn std::fmt::Display {
+ fn foo() {}
+}
+
+fn main() {}
diff --git a/tests/ui/traits/trivial_impl_sized.stderr b/tests/ui/traits/trivial_impl_sized.stderr
new file mode 100644
index 000000000..ebf6dfc9d
--- /dev/null
+++ b/tests/ui/traits/trivial_impl_sized.stderr
@@ -0,0 +1,25 @@
+error[E0046]: not all trait items implemented, missing: `foo`
+ --> $DIR/trivial_impl_sized.rs:15:1
+ |
+LL | / fn foo()
+LL | | where
+LL | | Self: Sized;
+ | |____________________- `foo` from trait
+...
+LL | impl Foo for i32 {}
+ | ^^^^^^^^^^^^^^^^ missing `foo` in implementation
+
+error[E0046]: not all trait items implemented, missing: `foo`
+ --> $DIR/trivial_impl_sized.rs:19:1
+ |
+LL | / fn foo()
+LL | | where
+LL | | Self: Sized;
+ | |____________________- `foo` from trait
+...
+LL | impl Foo for dyn std::fmt::Debug {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `foo` in implementation
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0046`.