Skip to content

Commit

Permalink
Fix another false positive in lifetime elision lint
Browse files Browse the repository at this point in the history
The false positive occurred when we have an anonymous input lifetime and a
named output lifetime. This is not elidable, because if we elided the output
lifetime, it would be inferred to be the same as the input.
  • Loading branch information
fhartwig committed Jan 17, 2016
1 parent 840d870 commit 7e85db6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 0 additions & 1 deletion src/lifetimes.rs
Expand Up @@ -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
}
Expand Down
4 changes: 4 additions & 0 deletions tests/compile-fail/lifetimes.rs
Expand Up @@ -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() {
}

0 comments on commit 7e85db6

Please sign in to comment.