about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorMichael Goulet <michael@errs.io>2022-12-28 06:44:29 +0000
committerMichael Goulet <michael@errs.io>2022-12-28 18:35:21 +0000
commit992ba801c271aeb087b1619467c487e35bae4e65 (patch)
tree1e414eeb4d38416a4cd6431b5954559e3991bef6 /src
parent01d784131f0a11d19d0ab5398b00ca6bbfd283b1 (diff)
downloadrust-992ba801c271aeb087b1619467c487e35bae4e65.tar.gz
rust-992ba801c271aeb087b1619467c487e35bae4e65.zip
Add test for bad suggestion
Diffstat (limited to 'src')
-rw-r--r--src/test/ui/generic-associated-types/mismatched-where-clause-regions.rs12
-rw-r--r--src/test/ui/generic-associated-types/mismatched-where-clause-regions.stderr17
2 files changed, 29 insertions, 0 deletions
diff --git a/src/test/ui/generic-associated-types/mismatched-where-clause-regions.rs b/src/test/ui/generic-associated-types/mismatched-where-clause-regions.rs
new file mode 100644
index 00000000000..8caf5317693
--- /dev/null
+++ b/src/test/ui/generic-associated-types/mismatched-where-clause-regions.rs
@@ -0,0 +1,12 @@
+trait Foo {
+    type T<'a1, 'b1>
+    where
+        'a1: 'b1;
+}
+
+impl Foo for () {
+    type T<'a2, 'b2> = () where 'b2: 'a2;
+    //~^ ERROR impl has stricter requirements than trait
+}
+
+fn main() {}
diff --git a/src/test/ui/generic-associated-types/mismatched-where-clause-regions.stderr b/src/test/ui/generic-associated-types/mismatched-where-clause-regions.stderr
new file mode 100644
index 00000000000..91a03007640
--- /dev/null
+++ b/src/test/ui/generic-associated-types/mismatched-where-clause-regions.stderr
@@ -0,0 +1,17 @@
+error[E0276]: impl has stricter requirements than trait
+  --> $DIR/mismatched-where-clause-regions.rs:8:38
+   |
+LL |     type T<'a1, 'b1>
+   |     ---------------- definition of `T` from trait
+...
+LL |     type T<'a2, 'b2> = () where 'b2: 'a2;
+   |                                      ^^^ impl has extra requirement `'b2: 'a2`
+   |
+help: copy the `where` clause predicates from the trait
+   |
+LL |     type T<'a2, 'b2> = () where 'a2: 'b2;
+   |                           ~~~~~~~~~~~~~~
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0276`.