From 5952a2954376d6086672f5c166a24b87d93ddbb4 Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Thu, 13 Aug 2015 07:51:24 +0200 Subject: [PATCH] lifetimes test: use explicit message prefix --- tests/compile-fail/lifetimes.rs | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/tests/compile-fail/lifetimes.rs b/tests/compile-fail/lifetimes.rs index 0f0f95ac5f5..36daa69fb31 100755 --- a/tests/compile-fail/lifetimes.rs +++ b/tests/compile-fail/lifetimes.rs @@ -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 }