Skip to content

Commit 663f200

Browse files
authored
Rollup merge of rust-lang#129207 - GrigorenkoPV:elided-is-named, r=cjgillot
Lint that warns when an elided lifetime ends up being a named lifetime As suggested in rust-lang#48686 (comment) Fixes rust-lang#48686
2 parents 5bbb0d4 + 9957101 commit 663f200

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

tests/ui/needless_lifetimes.stderr

+12-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
error: elided lifetime has a name
2+
--> tests/ui/needless_lifetimes.rs:266:52
3+
|
4+
LL | fn named_input_elided_output<'a>(_arg: &'a str) -> &str {
5+
| -- ^ this elided lifetime gets resolved as `'a`
6+
| |
7+
| lifetime `'a` declared here
8+
|
9+
= note: `-D elided-named-lifetimes` implied by `-D warnings`
10+
= help: to override `-D warnings` add `#[allow(elided_named_lifetimes)]`
11+
112
error: the following explicit lifetimes could be elided: 'a, 'b
213
--> tests/ui/needless_lifetimes.rs:17:23
314
|
@@ -553,5 +564,5 @@ LL - fn one_input<'a>(x: &'a u8) -> &'a u8 {
553564
LL + fn one_input(x: &u8) -> &u8 {
554565
|
555566

556-
error: aborting due to 46 previous errors
567+
error: aborting due to 47 previous errors
557568

tests/ui/ptr_arg.stderr

+10-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
error: elided lifetime has a name
2+
--> tests/ui/ptr_arg.rs:295:56
3+
|
4+
LL | fn cow_good_ret_ty<'a>(input: &'a Cow<'a, str>) -> &str {
5+
| -- lifetime `'a` declared here ^ this elided lifetime gets resolved as `'a`
6+
|
7+
= note: `-D elided-named-lifetimes` implied by `-D warnings`
8+
= help: to override `-D warnings` add `#[allow(elided_named_lifetimes)]`
9+
110
error: writing `&Vec` instead of `&[_]` involves a new object where a slice will do
211
--> tests/ui/ptr_arg.rs:13:14
312
|
@@ -212,5 +221,5 @@ error: using a reference to `Cow` is not recommended
212221
LL | fn cow_bad_ret_ty_2<'a, 'b>(input: &'a Cow<'a, str>) -> &'b str {
213222
| ^^^^^^^^^^^^^^^^ help: change this to: `&str`
214223

215-
error: aborting due to 24 previous errors
224+
error: aborting due to 25 previous errors
216225

0 commit comments

Comments
 (0)