diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/ui/traits/new-solver/assembly/assemble-normalizing-self-ty-impl-ambiguity.rs | 25 | ||||
| -rw-r--r-- | tests/ui/traits/new-solver/assembly/assemble-normalizing-self-ty-impl-ambiguity.stderr | 23 |
2 files changed, 48 insertions, 0 deletions
diff --git a/tests/ui/traits/new-solver/assembly/assemble-normalizing-self-ty-impl-ambiguity.rs b/tests/ui/traits/new-solver/assembly/assemble-normalizing-self-ty-impl-ambiguity.rs new file mode 100644 index 00000000000..727ce84ba35 --- /dev/null +++ b/tests/ui/traits/new-solver/assembly/assemble-normalizing-self-ty-impl-ambiguity.rs @@ -0,0 +1,25 @@ +// compile-flags: -Ztrait-solver=next + +// Checks that we do not get ambiguity by considering an impl +// multiple times if we're able to normalize the self type. +trait Trait<'a> {} + +impl<'a, T: 'a> Trait<'a> for T {} + +fn impls_trait<'a, T: Trait<'a>>() {} + +trait Id { + type Assoc; +} +impl<T> Id for T { + type Assoc = T; +} + +fn call<T>() { + impls_trait::<<T as Id>::Assoc>(); +} + +fn main() { + call::<()>(); + impls_trait::<<<() as Id>::Assoc as Id>::Assoc>(); +} diff --git a/tests/ui/traits/new-solver/assembly/assemble-normalizing-self-ty-impl-ambiguity.stderr b/tests/ui/traits/new-solver/assembly/assemble-normalizing-self-ty-impl-ambiguity.stderr new file mode 100644 index 00000000000..91b635b35eb --- /dev/null +++ b/tests/ui/traits/new-solver/assembly/assemble-normalizing-self-ty-impl-ambiguity.stderr @@ -0,0 +1,23 @@ +error[E0283]: type annotations needed: cannot satisfy `<T as Id>::Assoc: Trait<'_>` + --> $DIR/assemble-normalizing-self-ty-impl-ambiguity.rs:19:5 + | +LL | impls_trait::<<T as Id>::Assoc>(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: cannot satisfy `<T as Id>::Assoc: Trait<'_>` +note: required by a bound in `impls_trait` + --> $DIR/assemble-normalizing-self-ty-impl-ambiguity.rs:9:23 + | +LL | fn impls_trait<'a, T: Trait<'a>>() {} + | ^^^^^^^^^ required by this bound in `impls_trait` + +error[E0282]: type annotations needed + --> $DIR/assemble-normalizing-self-ty-impl-ambiguity.rs:24:5 + | +LL | impls_trait::<<<() as Id>::Assoc as Id>::Assoc>(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type of the type parameter `T` declared on the function `impls_trait` + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0282, E0283. +For more information about an error, try `rustc --explain E0282`. |
