3
3
4
4
#![ deny( needless_lifetimes) ]
5
5
#![ allow( dead_code) ]
6
- fn distinct_lifetimes < ' a , ' b > ( _x : & ' a u8 , _y : & ' b u8 , _z : u8 ) { }
6
+ #![ allow( unused) ]
7
+ fn distinct_lifetimes < ' a , ' b > ( x : & ' a u8 , y : & ' b u8 , z : u8 ) { }
7
8
//~^ERROR explicit lifetimes given
8
9
9
- fn distinct_and_static < ' a , ' b > ( _x : & ' a u8 , _y : & ' b u8 , _z : & ' static u8 ) { }
10
+ fn distinct_and_static < ' a , ' b > ( x : & ' a u8 , y : & ' b u8 , z : & ' static u8 ) { }
10
11
//~^ERROR explicit lifetimes given
11
12
12
- fn same_lifetime_on_input < ' a > ( _x : & ' a u8 , _y : & ' a u8 ) { } // no error, same lifetime on two params
13
+ fn same_lifetime_on_input < ' a > ( x : & ' a u8 , y : & ' a u8 ) { } // no error, same lifetime on two params
13
14
14
- fn only_static_on_input ( _x : & u8 , _y : & u8 , _z : & ' static u8 ) { } // no error, static involved
15
+ fn only_static_on_input ( x : & u8 , y : & u8 , z : & ' static u8 ) { } // no error, static involved
15
16
16
- fn mut_and_static_input ( _x : & mut u8 , _y : & ' static str ) { }
17
+ fn mut_and_static_input ( x : & mut u8 , y : & ' static str ) { }
17
18
18
- fn in_and_out < ' a > ( x : & ' a u8 , _y : u8 ) -> & ' a u8 { x }
19
+ fn in_and_out < ' a > ( x : & ' a u8 , y : u8 ) -> & ' a u8 { x }
19
20
//~^ERROR explicit lifetimes given
20
21
21
- fn multiple_in_and_out_1 < ' a > ( x : & ' a u8 , _y : & ' a u8 ) -> & ' a u8 { x } // no error, multiple input refs
22
+ fn multiple_in_and_out_1 < ' a > ( x : & ' a u8 , y : & ' a u8 ) -> & ' a u8 { x } // no error, multiple input refs
22
23
23
- fn multiple_in_and_out_2 < ' a , ' b > ( x : & ' a u8 , _y : & ' b u8 ) -> & ' a u8 { x } // no error, multiple input refs
24
+ fn multiple_in_and_out_2 < ' a , ' b > ( x : & ' a u8 , y : & ' b u8 ) -> & ' a u8 { x } // no error, multiple input refs
24
25
25
- fn in_static_and_out < ' a > ( x : & ' a u8 , _y : & ' static u8 ) -> & ' a u8 { x } // no error, static involved
26
+ fn in_static_and_out < ' a > ( x : & ' a u8 , y : & ' static u8 ) -> & ' a u8 { x } // no error, static involved
26
27
27
- fn deep_reference_1 < ' a , ' b > ( x : & ' a u8 , _y : & ' b u8 ) -> Result < & ' a u8 , ( ) > { Ok ( x) } // no error
28
+ fn deep_reference_1 < ' a , ' b > ( x : & ' a u8 , y : & ' b u8 ) -> Result < & ' a u8 , ( ) > { Ok ( x) } // no error
28
29
29
30
fn deep_reference_2 < ' a > ( x : Result < & ' a u8 , & ' a u8 > ) -> & ' a u8 { x. unwrap ( ) } // no error, two input refs
30
31
31
- fn deep_reference_3 < ' a > ( x : & ' a u8 , _y : u8 ) -> Result < & ' a u8 , ( ) > { Ok ( x) }
32
+ fn deep_reference_3 < ' a > ( x : & ' a u8 , y : u8 ) -> Result < & ' a u8 , ( ) > { Ok ( x) }
32
33
//~^ERROR explicit lifetimes given
33
34
34
35
// where clause, but without lifetimes
35
- fn where_clause_without_lt < ' a , T > ( x : & ' a u8 , _y : u8 ) -> Result < & ' a u8 , ( ) > where T : Copy { Ok ( x) }
36
+ fn where_clause_without_lt < ' a , T > ( x : & ' a u8 , y : u8 ) -> Result < & ' a u8 , ( ) > where T : Copy { Ok ( x) }
36
37
//~^ERROR explicit lifetimes given
37
38
38
39
type Ref < ' r > = & ' r u8 ;
39
40
40
- fn lifetime_param_1 < ' a > ( _x : Ref < ' a > , _y : & ' a u8 ) { } // no error, same lifetime on two params
41
+ fn lifetime_param_1 < ' a > ( x : Ref < ' a > , y : & ' a u8 ) { } // no error, same lifetime on two params
41
42
42
- fn lifetime_param_2 < ' a , ' b > ( _x : Ref < ' a > , _y : & ' b u8 ) { }
43
+ fn lifetime_param_2 < ' a , ' b > ( x : Ref < ' a > , y : & ' b u8 ) { }
43
44
//~^ERROR explicit lifetimes given
44
45
45
- fn lifetime_param_3 < ' a , ' b : ' a > ( _x : Ref < ' a > , _y : & ' b u8 ) { } // no error, bounded lifetime
46
+ fn lifetime_param_3 < ' a , ' b : ' a > ( x : Ref < ' a > , y : & ' b u8 ) { } // no error, bounded lifetime
46
47
47
- fn lifetime_param_4 < ' a , ' b > ( _x : Ref < ' a > , _y : & ' b u8 ) where ' b : ' a { } // no error, bounded lifetime
48
+ fn lifetime_param_4 < ' a , ' b > ( x : Ref < ' a > , y : & ' b u8 ) where ' b : ' a { } // no error, bounded lifetime
48
49
49
50
struct Lt < ' a , I : ' static > {
50
51
x : & ' a I
@@ -62,16 +63,23 @@ struct X {
62
63
x : u8 ,
63
64
}
64
65
66
+ // no errors, bounded lifetimes:
67
+ trait Trait < ' a > { }
68
+ fn trait_bound < ' a , T : Trait < ' a > > ( x : & ' a u8 , y : T ) { }
69
+ fn trait_bound_where < ' a , T > ( x : & ' a u8 , y : T ) where T : Trait < ' a > { }
70
+ fn lt_bound < ' a , T : ' a > ( x : & ' a u8 , y : T ) { }
71
+ fn lt_bound_where < ' a , T > ( x : & ' a u8 , y : T ) where T : ' a { }
72
+
65
73
impl X {
66
74
fn self_and_out < ' s > ( & ' s self ) -> & ' s u8 { & self . x }
67
75
//~^ERROR explicit lifetimes given
68
76
69
- fn self_and_in_out < ' s , ' t > ( & ' s self , _x : & ' t u8 ) -> & ' s u8 { & self . x } // no error, multiple input refs
77
+ fn self_and_in_out < ' s , ' t > ( & ' s self , x : & ' t u8 ) -> & ' s u8 { & self . x } // no error, multiple input refs
70
78
71
- fn distinct_self_and_in < ' s , ' t > ( & ' s self , _x : & ' t u8 ) { }
79
+ fn distinct_self_and_in < ' s , ' t > ( & ' s self , x : & ' t u8 ) { }
72
80
//~^ERROR explicit lifetimes given
73
81
74
- fn self_and_same_in < ' s > ( & ' s self , _x : & ' s u8 ) { } // no error, same lifetimes on two params
82
+ fn self_and_same_in < ' s > ( & ' s self , x : & ' s u8 ) { } // no error, same lifetimes on two params
75
83
}
76
84
77
85
struct Foo < ' a > ( & ' a u8 ) ;
0 commit comments