diff options
| author | lcnr <rust@lcnr.de> | 2023-07-18 18:07:42 +0200 |
|---|---|---|
| committer | lcnr <rust@lcnr.de> | 2023-07-20 11:05:52 +0200 |
| commit | 2d99f40ec5ee10df8f7325e4e71d8249f8dacd92 (patch) | |
| tree | 7ffff32f14f5e0ba09f02c199ba6db145e1870ed /tests | |
| parent | fdaec57a28ab6a8cd60fd7a2842d366a9b452a2e (diff) | |
| download | rust-2d99f40ec5ee10df8f7325e4e71d8249f8dacd92.tar.gz rust-2d99f40ec5ee10df8f7325e4e71d8249f8dacd92.zip | |
assembly: only consider blanket impls once
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`. |
