Skip to content

Commit

Permalink
Rollup merge of #129207 - GrigorenkoPV:elided-is-named, r=cjgillot
Browse files Browse the repository at this point in the history
Lint that warns when an elided lifetime ends up being a named lifetime

As suggested in #48686 (comment)

Fixes #48686
  • Loading branch information
matthiaskrgr authored Sep 1, 2024
2 parents 5bbb0d4 + 9957101 commit 663f200
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
13 changes: 12 additions & 1 deletion tests/ui/needless_lifetimes.stderr
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
error: elided lifetime has a name
--> tests/ui/needless_lifetimes.rs:266:52
|
LL | fn named_input_elided_output<'a>(_arg: &'a str) -> &str {
| -- ^ this elided lifetime gets resolved as `'a`
| |
| lifetime `'a` declared here
|
= note: `-D elided-named-lifetimes` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(elided_named_lifetimes)]`

error: the following explicit lifetimes could be elided: 'a, 'b
--> tests/ui/needless_lifetimes.rs:17:23
|
Expand Down Expand Up @@ -553,5 +564,5 @@ LL - fn one_input<'a>(x: &'a u8) -> &'a u8 {
LL + fn one_input(x: &u8) -> &u8 {
|

error: aborting due to 46 previous errors
error: aborting due to 47 previous errors

11 changes: 10 additions & 1 deletion tests/ui/ptr_arg.stderr
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
error: elided lifetime has a name
--> tests/ui/ptr_arg.rs:295:56
|
LL | fn cow_good_ret_ty<'a>(input: &'a Cow<'a, str>) -> &str {
| -- lifetime `'a` declared here ^ this elided lifetime gets resolved as `'a`
|
= note: `-D elided-named-lifetimes` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(elided_named_lifetimes)]`

error: writing `&Vec` instead of `&[_]` involves a new object where a slice will do
--> tests/ui/ptr_arg.rs:13:14
|
Expand Down Expand Up @@ -212,5 +221,5 @@ error: using a reference to `Cow` is not recommended
LL | fn cow_bad_ret_ty_2<'a, 'b>(input: &'a Cow<'a, str>) -> &'b str {
| ^^^^^^^^^^^^^^^^ help: change this to: `&str`

error: aborting due to 24 previous errors
error: aborting due to 25 previous errors

0 comments on commit 663f200

Please sign in to comment.