about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorMichael Goulet <michael@errs.io>2025-04-25 15:13:51 +0000
committerMichael Goulet <michael@errs.io>2025-04-30 18:07:52 +0000
commitf2930001aa6dd5f5056c69c96c1eaf4b31dfedd8 (patch)
tree03862966f26faf1d9d16b38bd00b845481c1a027 /tests
parent7188f453111502962326022740e2657fce0a6939 (diff)
downloadrust-f2930001aa6dd5f5056c69c96c1eaf4b31dfedd8.tar.gz
rust-f2930001aa6dd5f5056c69c96c1eaf4b31dfedd8.zip
Use select in projection lookup
Diffstat (limited to 'tests')
-rw-r--r--tests/ui/associated-types/mismatch-two-relevant-impls.rs20
-rw-r--r--tests/ui/associated-types/mismatch-two-relevant-impls.stderr20
2 files changed, 40 insertions, 0 deletions
diff --git a/tests/ui/associated-types/mismatch-two-relevant-impls.rs b/tests/ui/associated-types/mismatch-two-relevant-impls.rs
new file mode 100644
index 00000000000..58fd567c278
--- /dev/null
+++ b/tests/ui/associated-types/mismatch-two-relevant-impls.rs
@@ -0,0 +1,20 @@
+trait Tr {
+    type Assoc;
+}
+
+struct W<T>(T);
+
+impl Tr for W<i32> {
+    type Assoc = u32;
+}
+
+impl Tr for W<u32> {
+    type Assoc = i32;
+}
+
+fn needs_unit<T: Tr<Assoc = ()>>() {}
+
+fn main() {
+    needs_unit::<W<i32>>();
+    //~^ ERROR type mismatch resolving `<W<i32> as Tr>::Assoc == ()`
+}
diff --git a/tests/ui/associated-types/mismatch-two-relevant-impls.stderr b/tests/ui/associated-types/mismatch-two-relevant-impls.stderr
new file mode 100644
index 00000000000..2a1f3ef23ca
--- /dev/null
+++ b/tests/ui/associated-types/mismatch-two-relevant-impls.stderr
@@ -0,0 +1,20 @@
+error[E0271]: type mismatch resolving `<W<i32> as Tr>::Assoc == ()`
+  --> $DIR/mismatch-two-relevant-impls.rs:18:18
+   |
+LL |     needs_unit::<W<i32>>();
+   |                  ^^^^^^ type mismatch resolving `<W<i32> as Tr>::Assoc == ()`
+   |
+note: expected this to be `()`
+  --> $DIR/mismatch-two-relevant-impls.rs:8:18
+   |
+LL |     type Assoc = u32;
+   |                  ^^^
+note: required by a bound in `needs_unit`
+  --> $DIR/mismatch-two-relevant-impls.rs:15:21
+   |
+LL | fn needs_unit<T: Tr<Assoc = ()>>() {}
+   |                     ^^^^^^^^^^ required by this bound in `needs_unit`
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0271`.