summaryrefslogtreecommitdiffstats
path: root/tests/ui/type-alias-impl-trait/not-matching-trait-refs-isnt-defining.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/type-alias-impl-trait/not-matching-trait-refs-isnt-defining.rs')
-rw-r--r--tests/ui/type-alias-impl-trait/not-matching-trait-refs-isnt-defining.rs33
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/ui/type-alias-impl-trait/not-matching-trait-refs-isnt-defining.rs b/tests/ui/type-alias-impl-trait/not-matching-trait-refs-isnt-defining.rs
new file mode 100644
index 000000000..131f8d999
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/not-matching-trait-refs-isnt-defining.rs
@@ -0,0 +1,33 @@
+#![feature(impl_trait_in_assoc_type)]
+
+trait Foo<T> {
+ type Assoc;
+
+ fn test() -> u32;
+}
+
+struct DefinesOpaque;
+impl Foo<DefinesOpaque> for () {
+ type Assoc = impl Sized;
+
+ // This test's return type is `u32`, *not* the opaque that is defined above.
+ // Previously we were only checking that the self type of the assoc matched,
+ // but this doesn't account for other impls with different trait substs.
+ fn test() -> <() as Foo<NoOpaques>>::Assoc {
+ let _: <Self as Foo<DefinesOpaque>>::Assoc = "";
+ //~^ ERROR mismatched types
+
+ 1
+ }
+}
+
+struct NoOpaques;
+impl Foo<NoOpaques> for () {
+ type Assoc = u32;
+
+ fn test() -> u32 {
+ 1
+ }
+}
+
+fn main() {}