From 9ffd0868653ad5113962c6f2a42d5061afbcf493 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Mon, 28 Nov 2022 14:04:46 -0800 Subject: [PATCH] review comment: add test case --- .../impl-missing-where-clause-lifetimes-from-trait.rs | 8 ++++++++ ...l-missing-where-clause-lifetimes-from-trait.stderr | 11 ++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) 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 1994120ce1466..dcdbd02287371 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 3a02369e2ee8a..e26cb22163f1e 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`.