Merge pull request #176 from birkenfeld/static_lt_fix
lifetimes: fix case with one unnamed and one static ref (fixes #171)
This commit is contained in:
commit
767fa915ce
2 changed files with 4 additions and 3 deletions
|
@ -115,8 +115,8 @@ fn could_use_elision(func: &FnDecl, slf: Option<&ExplicitSelf>,
|
|||
} else if output_lts.is_empty() {
|
||||
// no output lifetimes, check distinctness of input lifetimes
|
||||
|
||||
// only one reference with unnamed lifetime, ok
|
||||
if input_lts.len() == 1 && input_lts[0] == Unnamed {
|
||||
// only unnamed and static, ok
|
||||
if input_lts.iter().all(|lt| *lt == Unnamed || *lt == Static) {
|
||||
return false;
|
||||
}
|
||||
// we have no output reference, so we only need all distinct lifetimes
|
||||
|
|
|
@ -13,6 +13,8 @@ fn same_lifetime_on_input<'a>(_x: &'a u8, _y: &'a u8) { } // no error, same life
|
|||
|
||||
fn only_static_on_input(_x: &u8, _y: &u8, _z: &'static u8) { } // no error, static involved
|
||||
|
||||
fn mut_and_static_input(_x: &mut u8, _y: &'static str) { }
|
||||
|
||||
fn in_and_out<'a>(x: &'a u8, _y: u8) -> &'a u8 { x }
|
||||
//~^ERROR explicit lifetimes given
|
||||
|
||||
|
@ -60,7 +62,6 @@ impl<'a> Foo<'a> {
|
|||
fn self_shared_lifetime(&self, _: &'a u8) {} // no error, lifetime 'a not defined in method
|
||||
fn self_bound_lifetime<'b: 'a>(&self, _: &'b u8) {} // no error, bounds exist
|
||||
}
|
||||
static STATIC: u8 = 1;
|
||||
|
||||
fn main() {
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue