about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEsteban Küber <esteban@kuber.com.ar>2022-11-28 14:04:46 -0800
committerEsteban Küber <esteban@kuber.com.ar>2022-12-05 20:43:41 -0800
commit9ffd0868653ad5113962c6f2a42d5061afbcf493 (patch)
tree84096545a8399df5a18fb3cf87efd9dfb6e145a8
parente802165dfe346e92a3ef9b0e49634943df862a67 (diff)
downloadrust-9ffd0868653ad5113962c6f2a42d5061afbcf493.tar.gz
rust-9ffd0868653ad5113962c6f2a42d5061afbcf493.zip
review comment: add test case
-rw-r--r--src/test/ui/trait-bounds/impl-missing-where-clause-lifetimes-from-trait.rs8
-rw-r--r--src/test/ui/trait-bounds/impl-missing-where-clause-lifetimes-from-trait.stderr11
2 files changed, 18 insertions, 1 deletions
diff --git a/src/test/ui/trait-bounds/impl-missing-where-clause-lifetimes-from-trait.rs b/src/test/ui/trait-bounds/impl-missing-where-clause-lifetimes-from-trait.rs
index 1994120ce14..dcdbd022873 100644
--- a/src/test/ui/trait-bounds/impl-missing-where-clause-lifetimes-from-trait.rs
+++ b/src/test/ui/trait-bounds/impl-missing-where-clause-lifetimes-from-trait.rs
@@ -25,6 +25,14 @@ where
     }
 }
 
+trait Bar {
+    fn foo<'a>(&'a self) {}
+}
+
+impl Bar for () {
+    fn foo<'a: 'a>(&'a self) {} //~ ERROR E0195
+}
+
 fn main() {
     ().foo((), ());
 }
diff --git a/src/test/ui/trait-bounds/impl-missing-where-clause-lifetimes-from-trait.stderr b/src/test/ui/trait-bounds/impl-missing-where-clause-lifetimes-from-trait.stderr
index 3a02369e2ee..e26cb22163f 100644
--- a/src/test/ui/trait-bounds/impl-missing-where-clause-lifetimes-from-trait.stderr
+++ b/src/test/ui/trait-bounds/impl-missing-where-clause-lifetimes-from-trait.stderr
@@ -22,6 +22,15 @@ LL |         T: 'a;
 LL |     fn foo<'a>(&self, state: &'a State) -> &'a T {
    |           ^^^^ lifetimes do not match method in trait
 
-error: aborting due to 2 previous errors
+error[E0195]: lifetime parameters or bounds on method `foo` do not match the trait declaration
+  --> $DIR/impl-missing-where-clause-lifetimes-from-trait.rs:33:11
+   |
+LL |     fn foo<'a>(&'a self) {}
+   |           ---- lifetimes in impl do not match this method in trait
+...
+LL |     fn foo<'a: 'a>(&'a self) {}
+   |           ^^^^^^^^ lifetimes do not match method in trait
+
+error: aborting due to 3 previous errors
 
 For more information about this error, try `rustc --explain E0195`.