diff --git a/src/lifetimes.rs b/src/lifetimes.rs index 1edd75a45..83da3d864 100644 --- a/src/lifetimes.rs +++ b/src/lifetimes.rs @@ -144,7 +144,6 @@ fn could_use_elision(cx: &LateContext, func: &FnDecl, slf: Option<&ExplicitSelf> match (&input_lts[0], &output_lts[0]) { (&Named(n1), &Named(n2)) if n1 == n2 => true, (&Named(_), &Unnamed) => true, - (&Unnamed, &Named(_)) => true, _ => false, // already elided, different named lifetimes // or something static going on } diff --git a/tests/compile-fail/lifetimes.rs b/tests/compile-fail/lifetimes.rs index 99c169174..eb161af9d 100644 --- a/tests/compile-fail/lifetimes.rs +++ b/tests/compile-fail/lifetimes.rs @@ -119,5 +119,9 @@ fn alias_with_lt3<'a>(_foo: &FooAlias<'a> ) -> &'a str { unimplemented!() } // no warning, two input lifetimes fn alias_with_lt4<'a, 'b>(_foo: &'a FooAlias<'b> ) -> &'a str { unimplemented!() } +fn named_input_elided_output<'a>(_arg: &'a str) -> &str { unimplemented!() } //~ERROR explicit lifetimes given + +fn elided_input_named_output<'a>(_arg: &str) -> &'a str { unimplemented!() } + fn main() { }