about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorMichael Goulet <michael@errs.io>2023-05-30 20:35:10 +0000
committerMichael Goulet <michael@errs.io>2023-06-08 16:30:05 +0000
commitc92140e83831286c36882fa50cc9edc0ecbbc578 (patch)
treedec8848b5b53184ef85c929a9c84503b7f4cf997 /tests
parentacf257e62cbd2011f987ee67b5c5dc02f60da88c (diff)
downloadrust-c92140e83831286c36882fa50cc9edc0ecbbc578.tar.gz
rust-c92140e83831286c36882fa50cc9edc0ecbbc578.zip
Don't suggest cyclic associated type constraint
Diffstat (limited to 'tests')
-rw-r--r--tests/ui/associated-types/dont-suggest-cyclic-constraint.rs11
-rw-r--r--tests/ui/associated-types/dont-suggest-cyclic-constraint.stderr12
2 files changed, 23 insertions, 0 deletions
diff --git a/tests/ui/associated-types/dont-suggest-cyclic-constraint.rs b/tests/ui/associated-types/dont-suggest-cyclic-constraint.rs
new file mode 100644
index 00000000000..6894f6b6cc4
--- /dev/null
+++ b/tests/ui/associated-types/dont-suggest-cyclic-constraint.rs
@@ -0,0 +1,11 @@
+use std::fmt::Debug;
+
+fn foo<I: Iterator>(mut iter: I, value: &I::Item)
+where
+    I::Item: Eq + Debug,
+{
+    debug_assert_eq!(iter.next(), Some(value));
+    //~^ ERROR mismatched types
+}
+
+fn main() {}
diff --git a/tests/ui/associated-types/dont-suggest-cyclic-constraint.stderr b/tests/ui/associated-types/dont-suggest-cyclic-constraint.stderr
new file mode 100644
index 00000000000..3ecac9c83e5
--- /dev/null
+++ b/tests/ui/associated-types/dont-suggest-cyclic-constraint.stderr
@@ -0,0 +1,12 @@
+error[E0308]: mismatched types
+  --> $DIR/dont-suggest-cyclic-constraint.rs:7:35
+   |
+LL |     debug_assert_eq!(iter.next(), Some(value));
+   |                                   ^^^^^^^^^^^ expected `Option<<I as Iterator>::Item>`, found `Option<&<I as Iterator>::Item>`
+   |
+   = note: expected enum `Option<<I as Iterator>::Item>`
+              found enum `Option<&<I as Iterator>::Item>`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0308`.