diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/ui/associated-inherent-types/impl_params_are_infers.rs | 34 | ||||
| -rw-r--r-- | tests/ui/associated-inherent-types/impl_params_are_infers.stderr | 20 |
2 files changed, 54 insertions, 0 deletions
diff --git a/tests/ui/associated-inherent-types/impl_params_are_infers.rs b/tests/ui/associated-inherent-types/impl_params_are_infers.rs new file mode 100644 index 00000000000..55d29a35a23 --- /dev/null +++ b/tests/ui/associated-inherent-types/impl_params_are_infers.rs @@ -0,0 +1,34 @@ +#![feature(inherent_associated_types)] +#![expect(incomplete_features)] + +// Test whether IAT resolution in item signatures will actually instantiate the +// impl's params with infers before equating self types, or if we "cheat" and +// use a heuristic (e.g. DeepRejectCtxt). + +struct Foo<T, U, V>(T, U, V); + +impl<T> Foo<T, T, u8> { + type IAT = u8; +} + +impl<T, U> Foo<T, U, u16> { + type IAT = u16; +} + +trait Identity { + type This; +} +impl<T> Identity for T { + type This = T; +} + +struct Bar<T, U> { + // It would be illegal to resolve to `Foo<T, T, u8>::IAT` as `T` and `U` are + // different types. However, currently we treat all impl-side params sort of like + // they're infers and assume they can unify with anything, so we consider it a + // valid candidate. + field: Foo<T, U, <u16 as Identity>::This>::IAT, + //~^ ERROR: multiple applicable items in scope +} + +fn main() {} diff --git a/tests/ui/associated-inherent-types/impl_params_are_infers.stderr b/tests/ui/associated-inherent-types/impl_params_are_infers.stderr new file mode 100644 index 00000000000..fd31693cbed --- /dev/null +++ b/tests/ui/associated-inherent-types/impl_params_are_infers.stderr @@ -0,0 +1,20 @@ +error[E0034]: multiple applicable items in scope + --> $DIR/impl_params_are_infers.rs:30:48 + | +LL | field: Foo<T, U, <u16 as Identity>::This>::IAT, + | ^^^ multiple `IAT` found + | +note: candidate #1 is defined in an impl for the type `Foo<T, T, u8>` + --> $DIR/impl_params_are_infers.rs:11:5 + | +LL | type IAT = u8; + | ^^^^^^^^ +note: candidate #2 is defined in an impl for the type `Foo<T, U, u16>` + --> $DIR/impl_params_are_infers.rs:15:5 + | +LL | type IAT = u16; + | ^^^^^^^^ + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0034`. |
