lifetimes test: use explicit message prefix

This commit is contained in:
Georg Brandl 2015-08-13 07:51:24 +02:00
parent 2f7693094f
commit 5952a29543

View file

@ -3,15 +3,18 @@
#![deny(needless_lifetimes)]
fn distinct_lifetimes<'a, 'b>(_x: &'a u8, _y: &'b u8, _z: u8) { } //~ERROR
fn distinct_lifetimes<'a, 'b>(_x: &'a u8, _y: &'b u8, _z: u8) { }
//~^ERROR explicit lifetimes given
fn distinct_and_static<'a, 'b>(_x: &'a u8, _y: &'b u8, _z: &'static u8) { } //~ERROR
fn distinct_and_static<'a, 'b>(_x: &'a u8, _y: &'b u8, _z: &'static u8) { }
//~^ERROR explicit lifetimes given
fn same_lifetime_on_input<'a>(_x: &'a u8, _y: &'a u8) { } // no error, same lifetime on two params
fn only_static_on_input(_x: &u8, _y: &u8, _z: &'static u8) { } // no error, static involved
fn in_and_out<'a>(x: &'a u8, _y: u8) -> &'a u8 { x } //~ERROR
fn in_and_out<'a>(x: &'a u8, _y: u8) -> &'a u8 { x }
//~^ERROR explicit lifetimes given
fn multiple_in_and_out_1<'a>(x: &'a u8, _y: &'a u8) -> &'a u8 { x } // no error, multiple input refs
@ -23,24 +26,28 @@ fn deep_reference_1<'a, 'b>(x: &'a u8, _y: &'b u8) -> Result<&'a u8, ()> { Ok(x)
fn deep_reference_2<'a>(x: Result<&'a u8, &'a u8>) -> &'a u8 { x.unwrap() } // no error, two input refs
fn deep_reference_3<'a>(x: &'a u8, _y: u8) -> Result<&'a u8, ()> { Ok(x) } //~ERROR
fn deep_reference_3<'a>(x: &'a u8, _y: u8) -> Result<&'a u8, ()> { Ok(x) }
//~^ERROR explicit lifetimes given
type Ref<'r> = &'r u8;
fn lifetime_param_1<'a>(_x: Ref<'a>, _y: &'a u8) { }
fn lifetime_param_2<'a, 'b: 'a>(_x: Ref<'a>, _y: &'b u8) { } //~ERROR
fn lifetime_param_2<'a, 'b: 'a>(_x: Ref<'a>, _y: &'b u8) { }
//~^ERROR explicit lifetimes given
struct X {
x: u8,
}
impl X {
fn self_and_out<'s>(&'s self) -> &'s u8 { &self.x } //~ERROR
fn self_and_out<'s>(&'s self) -> &'s u8 { &self.x }
//~^ERROR explicit lifetimes given
fn self_and_in_out<'s, 't>(&'s self, _x: &'t u8) -> &'s u8 { &self.x } // no error, multiple input refs
fn distinct_self_and_in<'s, 't>(&'s self, _x: &'t u8) { } //~ERROR
fn distinct_self_and_in<'s, 't>(&'s self, _x: &'t u8) { }
//~^ERROR explicit lifetimes given
fn self_and_same_in<'s>(&'s self, _x: &'s u8) { } // no error, same lifetimes on two params
}