1 error: the following explicit lifetimes could be elided: 'a, 'b
2 --> $DIR/needless_lifetimes.rs:11:1
4 LL | fn distinct_lifetimes<'a, 'b>(_x: &'a u8, _y: &'b u8, _z: u8) {}
5 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
7 = note: `-D clippy::needless-lifetimes` implied by `-D warnings`
9 error: the following explicit lifetimes could be elided: 'a, 'b
10 --> $DIR/needless_lifetimes.rs:13:1
12 LL | fn distinct_and_static<'a, 'b>(_x: &'a u8, _y: &'b u8, _z: &'static u8) {}
13 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
15 error: the following explicit lifetimes could be elided: 'a
16 --> $DIR/needless_lifetimes.rs:23:1
18 LL | fn in_and_out<'a>(x: &'a u8, _y: u8) -> &'a u8 {
19 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
21 error: the following explicit lifetimes could be elided: 'b
22 --> $DIR/needless_lifetimes.rs:35:1
24 LL | fn multiple_in_and_out_2a<'a, 'b>(x: &'a u8, _y: &'b u8) -> &'a u8 {
25 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
27 error: the following explicit lifetimes could be elided: 'a
28 --> $DIR/needless_lifetimes.rs:42:1
30 LL | fn multiple_in_and_out_2b<'a, 'b>(_x: &'a u8, y: &'b u8) -> &'b u8 {
31 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
33 error: the following explicit lifetimes could be elided: 'b
34 --> $DIR/needless_lifetimes.rs:59:1
36 LL | fn deep_reference_1a<'a, 'b>(x: &'a u8, _y: &'b u8) -> Result<&'a u8, ()> {
37 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
39 error: the following explicit lifetimes could be elided: 'a
40 --> $DIR/needless_lifetimes.rs:66:1
42 LL | fn deep_reference_1b<'a, 'b>(_x: &'a u8, y: &'b u8) -> Result<&'b u8, ()> {
43 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
45 error: the following explicit lifetimes could be elided: 'a
46 --> $DIR/needless_lifetimes.rs:75:1
48 LL | fn deep_reference_3<'a>(x: &'a u8, _y: u8) -> Result<&'a u8, ()> {
49 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
51 error: the following explicit lifetimes could be elided: 'a
52 --> $DIR/needless_lifetimes.rs:80:1
54 LL | fn where_clause_without_lt<'a, T>(x: &'a u8, _y: u8) -> Result<&'a u8, ()>
55 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
57 error: the following explicit lifetimes could be elided: 'a, 'b
58 --> $DIR/needless_lifetimes.rs:92:1
60 LL | fn lifetime_param_2<'a, 'b>(_x: Ref<'a>, _y: &'b u8) {}
61 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
63 help: replace with `'_` in generic arguments such as here
64 --> $DIR/needless_lifetimes.rs:92:37
66 LL | fn lifetime_param_2<'a, 'b>(_x: Ref<'a>, _y: &'b u8) {}
69 error: the following explicit lifetimes could be elided: 'a
70 --> $DIR/needless_lifetimes.rs:116:1
72 LL | fn fn_bound_2<'a, F, I>(_m: Lt<'a, I>, _f: F) -> Lt<'a, I>
73 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
75 help: replace with `'_` in generic arguments such as here
76 --> $DIR/needless_lifetimes.rs:116:32
78 LL | fn fn_bound_2<'a, F, I>(_m: Lt<'a, I>, _f: F) -> Lt<'a, I>
81 error: the following explicit lifetimes could be elided: 's
82 --> $DIR/needless_lifetimes.rs:146:5
84 LL | fn self_and_out<'s>(&'s self) -> &'s u8 {
85 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
87 error: the following explicit lifetimes could be elided: 't
88 --> $DIR/needless_lifetimes.rs:153:5
90 LL | fn self_and_in_out_1<'s, 't>(&'s self, _x: &'t u8) -> &'s u8 {
91 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
93 error: the following explicit lifetimes could be elided: 's
94 --> $DIR/needless_lifetimes.rs:160:5
96 LL | fn self_and_in_out_2<'s, 't>(&'s self, x: &'t u8) -> &'t u8 {
97 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
99 error: the following explicit lifetimes could be elided: 's, 't
100 --> $DIR/needless_lifetimes.rs:164:5
102 LL | fn distinct_self_and_in<'s, 't>(&'s self, _x: &'t u8) {}
103 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
105 error: the following explicit lifetimes could be elided: 'a
106 --> $DIR/needless_lifetimes.rs:183:1
108 LL | fn struct_with_lt<'a>(_foo: Foo<'a>) -> &'a str {
109 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
111 help: replace with `'_` in generic arguments such as here
112 --> $DIR/needless_lifetimes.rs:183:33
114 LL | fn struct_with_lt<'a>(_foo: Foo<'a>) -> &'a str {
117 error: the following explicit lifetimes could be elided: 'b
118 --> $DIR/needless_lifetimes.rs:201:1
120 LL | fn struct_with_lt4a<'a, 'b>(_foo: &'a Foo<'b>) -> &'a str {
121 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
123 help: replace with `'_` in generic arguments such as here
124 --> $DIR/needless_lifetimes.rs:201:43
126 LL | fn struct_with_lt4a<'a, 'b>(_foo: &'a Foo<'b>) -> &'a str {
129 error: the following explicit lifetimes could be elided: 'a
130 --> $DIR/needless_lifetimes.rs:209:1
132 LL | fn struct_with_lt4b<'a, 'b>(_foo: &'a Foo<'b>) -> &'b str {
133 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
135 error: the following explicit lifetimes could be elided: 'a
136 --> $DIR/needless_lifetimes.rs:224:1
138 LL | fn trait_obj_elided2<'a>(_arg: &'a dyn Drop) -> &'a str {
139 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
141 error: the following explicit lifetimes could be elided: 'a
142 --> $DIR/needless_lifetimes.rs:230:1
144 LL | fn alias_with_lt<'a>(_foo: FooAlias<'a>) -> &'a str {
145 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
147 help: replace with `'_` in generic arguments such as here
148 --> $DIR/needless_lifetimes.rs:230:37
150 LL | fn alias_with_lt<'a>(_foo: FooAlias<'a>) -> &'a str {
153 error: the following explicit lifetimes could be elided: 'b
154 --> $DIR/needless_lifetimes.rs:248:1
156 LL | fn alias_with_lt4a<'a, 'b>(_foo: &'a FooAlias<'b>) -> &'a str {
157 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
159 help: replace with `'_` in generic arguments such as here
160 --> $DIR/needless_lifetimes.rs:248:47
162 LL | fn alias_with_lt4a<'a, 'b>(_foo: &'a FooAlias<'b>) -> &'a str {
165 error: the following explicit lifetimes could be elided: 'a
166 --> $DIR/needless_lifetimes.rs:256:1
168 LL | fn alias_with_lt4b<'a, 'b>(_foo: &'a FooAlias<'b>) -> &'b str {
169 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
171 error: the following explicit lifetimes could be elided: 'a
172 --> $DIR/needless_lifetimes.rs:260:1
174 LL | fn named_input_elided_output<'a>(_arg: &'a str) -> &str {
175 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
177 error: the following explicit lifetimes could be elided: 'a
178 --> $DIR/needless_lifetimes.rs:268:1
180 LL | fn trait_bound_ok<'a, T: WithLifetime<'static>>(_: &'a u8, _: T) {
181 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
183 error: the following explicit lifetimes could be elided: 'a
184 --> $DIR/needless_lifetimes.rs:304:1
186 LL | fn out_return_type_lts<'a>(e: &'a str) -> Cow<'a> {
187 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
189 help: replace with `'_` in generic arguments such as here
190 --> $DIR/needless_lifetimes.rs:304:47
192 LL | fn out_return_type_lts<'a>(e: &'a str) -> Cow<'a> {
195 error: the following explicit lifetimes could be elided: 'a
196 --> $DIR/needless_lifetimes.rs:311:9
198 LL | fn needless_lt<'a>(x: &'a u8) {}
199 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
201 error: the following explicit lifetimes could be elided: 'a
202 --> $DIR/needless_lifetimes.rs:315:9
204 LL | fn needless_lt<'a>(_x: &'a u8) {}
205 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
207 error: the following explicit lifetimes could be elided: 'a
208 --> $DIR/needless_lifetimes.rs:328:9
210 LL | fn baz<'a>(&'a self) -> impl Foo + 'a {
211 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
213 error: the following explicit lifetimes could be elided: 'a
214 --> $DIR/needless_lifetimes.rs:360:5
216 LL | fn impl_trait_elidable_nested_anonymous_lifetimes<'a>(i: &'a i32, f: impl Fn(&i32) -> &i32) -> &'a i32 {
217 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
219 error: the following explicit lifetimes could be elided: 'a
220 --> $DIR/needless_lifetimes.rs:369:5
222 LL | fn generics_elidable<'a, T: Fn(&i32) -> &i32>(i: &'a i32, f: T) -> &'a i32 {
223 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
225 error: the following explicit lifetimes could be elided: 'a
226 --> $DIR/needless_lifetimes.rs:381:5
228 LL | fn where_clause_elidadable<'a, T>(i: &'a i32, f: T) -> &'a i32
229 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
231 error: the following explicit lifetimes could be elided: 'a
232 --> $DIR/needless_lifetimes.rs:396:5
234 LL | fn pointer_fn_elidable<'a>(i: &'a i32, f: fn(&i32) -> &i32) -> &'a i32 {
235 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
237 error: the following explicit lifetimes could be elided: 'a
238 --> $DIR/needless_lifetimes.rs:409:5
240 LL | fn nested_fn_pointer_3<'a>(_: &'a i32) -> fn(fn(&i32) -> &i32) -> i32 {
241 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
243 error: the following explicit lifetimes could be elided: 'a
244 --> $DIR/needless_lifetimes.rs:412:5
246 LL | fn nested_fn_pointer_4<'a>(_: &'a i32) -> impl Fn(fn(&i32)) {
247 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
249 error: the following explicit lifetimes could be elided: 'a
250 --> $DIR/needless_lifetimes.rs:434:9
252 LL | fn implicit<'a>(&'a self) -> &'a () {
253 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
255 error: the following explicit lifetimes could be elided: 'a
256 --> $DIR/needless_lifetimes.rs:437:9
258 LL | fn implicit_mut<'a>(&'a mut self) -> &'a () {
259 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
261 error: the following explicit lifetimes could be elided: 'a
262 --> $DIR/needless_lifetimes.rs:448:9
264 LL | fn lifetime_elsewhere<'a>(self: Box<Self>, here: &'a ()) -> &'a () {
265 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
267 error: the following explicit lifetimes could be elided: 'a
268 --> $DIR/needless_lifetimes.rs:454:9
270 LL | fn implicit<'a>(&'a self) -> &'a ();
271 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
273 error: the following explicit lifetimes could be elided: 'a
274 --> $DIR/needless_lifetimes.rs:455:9
276 LL | fn implicit_provided<'a>(&'a self) -> &'a () {
277 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
279 error: the following explicit lifetimes could be elided: 'a
280 --> $DIR/needless_lifetimes.rs:464:9
282 LL | fn lifetime_elsewhere<'a>(self: Box<Self>, here: &'a ()) -> &'a ();
283 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
285 error: the following explicit lifetimes could be elided: 'a
286 --> $DIR/needless_lifetimes.rs:465:9
288 LL | fn lifetime_elsewhere_provided<'a>(self: Box<Self>, here: &'a ()) -> &'a () {
289 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
291 error: the following explicit lifetimes could be elided: 'a
292 --> $DIR/needless_lifetimes.rs:474:5
294 LL | fn foo<'a>(x: &'a u8, y: &'_ u8) {}
295 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
297 error: the following explicit lifetimes could be elided: 'a
298 --> $DIR/needless_lifetimes.rs:476:5
300 LL | fn bar<'a>(x: &'a u8, y: &'_ u8, z: &'_ u8) {}
301 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
303 error: the following explicit lifetimes could be elided: 'a
304 --> $DIR/needless_lifetimes.rs:483:5
306 LL | fn one_input<'a>(x: &'a u8) -> &'a u8 {
307 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
309 error: the following explicit lifetimes could be elided: 'a
310 --> $DIR/needless_lifetimes.rs:488:5
312 LL | fn multiple_inputs_output_not_elided<'a, 'b>(x: &'a u8, y: &'b u8, z: &'b u8) -> &'b u8 {
313 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
315 error: aborting due to 45 previous errors