Rollup merge of #145798 - compiler-errors:unnamed-lt-primary, r=lqd

Use unnamed lifetime spans as primary spans for `MISMATCHED_LIFETIME_SYNTAXES`

Fixes https://github.com/rust-lang/rust/issues/145772

This PR changes the primary span(s) of the `MISMATCHED_LIFETIME_SYNTAXES` to point to the *unnamed* lifetime spans in both the inputs and *outputs* of the function signature. As reported in rust-lang/rust#145772, this should make it so that IDEs highlight the spans of the actionable part of this lint, rather than just the (possibly named) input spans like they do today.

This could be tweaked further perhaps, for example for `fn foo(_: T<'_>) -> T`, we don't need to highlight the elided lifetime if the actionable part is to change only the return type to `T<'_>`, but I think it's improvement on what's here today, so I think that should be follow-up since I think the logic might get a bit hairy.

cc ```@shepmaster```
This commit is contained in:
Jacob Pratt 2025-08-23 23:58:37 -04:00 committed by GitHub
commit ccfe968cc3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 122 additions and 125 deletions

View file

@ -214,9 +214,9 @@ impl<T> LifetimeSyntaxCategories<Vec<T>> {
}
}
pub fn flatten(&self) -> impl Iterator<Item = &T> {
let Self { hidden, elided, named } = self;
[hidden.iter(), elided.iter(), named.iter()].into_iter().flatten()
pub fn iter_unnamed(&self) -> impl Iterator<Item = &T> {
let Self { hidden, elided, named: _ } = self;
[hidden.iter(), elided.iter()].into_iter().flatten()
}
}
@ -495,7 +495,7 @@ fn emit_mismatch_diagnostic<'tcx>(
cx.emit_span_lint(
MISMATCHED_LIFETIME_SYNTAXES,
inputs.flatten().copied().collect::<Vec<_>>(),
inputs.iter_unnamed().chain(outputs.iter_unnamed()).copied().collect::<Vec<_>>(),
lints::MismatchedLifetimeSyntaxes { inputs, outputs, suggestions },
);
}

View file

@ -268,10 +268,10 @@ LL | fn barbar(_x: &mut Vec<u32>, y: &mut String) {
| ^^^^^^^^^^^ help: change this to: `&mut str`
error: eliding a lifetime that's named elsewhere is confusing
--> tests/ui/ptr_arg.rs:314:36
--> tests/ui/ptr_arg.rs:314:56
|
LL | fn cow_good_ret_ty<'a>(input: &'a Cow<'a, str>) -> &str {
| ^^ ^^ ---- the same lifetime is elided here
| -- -- ^^^^ the same lifetime is elided here
| | |
| | the lifetime is named here
| the lifetime is named here

View file

@ -1,8 +1,8 @@
warning: hiding a lifetime that's named elsewhere is confusing
--> $DIR/issue-71348.rs:18:40
--> $DIR/issue-71348.rs:18:56
|
LL | fn ask<'a, const N: &'static str>(&'a self) -> &'a <Self as Get<N>>::Target
| ^^ -- ------------------------ the same lifetime is hidden here
| -- -- ^^^^^^^^^^^^^^^^^^^^^^^^ the same lifetime is hidden here
| | |
| | the same lifetime is named here
| the lifetime is named here

View file

@ -1,8 +1,8 @@
warning: eliding a lifetime that's named elsewhere is confusing
--> $DIR/rpit-assoc-pair-with-lifetime.rs:3:31
--> $DIR/rpit-assoc-pair-with-lifetime.rs:3:82
|
LL | pub fn iter<'a>(v: Vec<(u32, &'a u32)>) -> impl DoubleEndedIterator<Item = (u32, &u32)> {
| ^^ the lifetime is named here ---- the same lifetime is elided here
| -- the lifetime is named here ^^^^ the same lifetime is elided here
|
= help: the same lifetime is referred to in inconsistent ways, making the signature confusing
= note: `#[warn(mismatched_lifetime_syntaxes)]` on by default

View file

@ -1,8 +1,8 @@
error: eliding a lifetime that's named elsewhere is confusing
--> $DIR/example-from-issue48686.rs:6:21
--> $DIR/example-from-issue48686.rs:6:50
|
LL | pub fn get_mut(&'static self, x: &mut u8) -> &mut u8 {
| ^^^^^^^ ------- the same lifetime is elided here
| ------- ^^^^^^^ the same lifetime is elided here
| |
| the lifetime is named here
|

View file

@ -1,8 +1,8 @@
error: eliding a lifetime that's named elsewhere is confusing
--> $DIR/missing-lifetime-kind.rs:3:22
--> $DIR/missing-lifetime-kind.rs:3:32
|
LL | fn ampersand<'a>(x: &'a u8) -> &u8 {
| ^^ --- the same lifetime is elided here
| -- ^^^ the same lifetime is elided here
| |
| the lifetime is named here
|
@ -18,10 +18,10 @@ LL | fn ampersand<'a>(x: &'a u8) -> &'a u8 {
| ++
error: hiding a lifetime that's named elsewhere is confusing
--> $DIR/missing-lifetime-kind.rs:10:21
--> $DIR/missing-lifetime-kind.rs:10:31
|
LL | fn brackets<'a>(x: &'a u8) -> Brackets {
| ^^ -------- the same lifetime is hidden here
| -- ^^^^^^^^ the same lifetime is hidden here
| |
| the lifetime is named here
|
@ -32,10 +32,10 @@ LL | fn brackets<'a>(x: &'a u8) -> Brackets<'a> {
| ++++
error: hiding a lifetime that's named elsewhere is confusing
--> $DIR/missing-lifetime-kind.rs:17:18
--> $DIR/missing-lifetime-kind.rs:17:28
|
LL | fn comma<'a>(x: &'a u8) -> Comma<u8> {
| ^^ --------- the same lifetime is hidden here
| -- ^^^^^^^^^ the same lifetime is hidden here
| |
| the lifetime is named here
|
@ -46,10 +46,10 @@ LL | fn comma<'a>(x: &'a u8) -> Comma<'a, u8> {
| +++
error: eliding a lifetime that's named elsewhere is confusing
--> $DIR/missing-lifetime-kind.rs:22:23
--> $DIR/missing-lifetime-kind.rs:22:34
|
LL | fn underscore<'a>(x: &'a u8) -> &'_ u8 {
| ^^ -- the same lifetime is elided here
| -- ^^ the same lifetime is elided here
| |
| the lifetime is named here
|

View file

@ -1,8 +1,8 @@
warning: eliding a lifetime that's named elsewhere is confusing
--> $DIR/not-tied-to-crate.rs:8:16
--> $DIR/not-tied-to-crate.rs:8:31
|
LL | fn bar(x: &'static u8) -> &u8 {
| ^^^^^^^ --- the same lifetime is elided here
| ------- ^^^ the same lifetime is elided here
| |
| the lifetime is named here
|
@ -18,10 +18,10 @@ LL | fn bar(x: &'static u8) -> &'static u8 {
| +++++++
error: eliding a lifetime that's named elsewhere is confusing
--> $DIR/not-tied-to-crate.rs:14:16
--> $DIR/not-tied-to-crate.rs:14:31
|
LL | fn baz(x: &'static u8) -> &u8 {
| ^^^^^^^ --- the same lifetime is elided here
| ------- ^^^ the same lifetime is elided here
| |
| the lifetime is named here
|

View file

@ -1,8 +1,8 @@
error: eliding a lifetime that's named elsewhere is confusing
--> $DIR/static.rs:16:18
--> $DIR/static.rs:16:33
|
LL | fn ampersand(x: &'static u8) -> &u8 {
| ^^^^^^^ --- the same lifetime is elided here
| ------- ^^^ the same lifetime is elided here
| |
| the lifetime is named here
|
@ -18,10 +18,10 @@ LL | fn ampersand(x: &'static u8) -> &'static u8 {
| +++++++
error: hiding a lifetime that's named elsewhere is confusing
--> $DIR/static.rs:23:17
--> $DIR/static.rs:23:32
|
LL | fn brackets(x: &'static u8) -> Brackets {
| ^^^^^^^ -------- the same lifetime is hidden here
| ------- ^^^^^^^^ the same lifetime is hidden here
| |
| the lifetime is named here
|
@ -32,10 +32,10 @@ LL | fn brackets(x: &'static u8) -> Brackets<'static> {
| +++++++++
error: hiding a lifetime that's named elsewhere is confusing
--> $DIR/static.rs:30:14
--> $DIR/static.rs:30:29
|
LL | fn comma(x: &'static u8) -> Comma<u8> {
| ^^^^^^^ --------- the same lifetime is hidden here
| ------- ^^^^^^^^^ the same lifetime is hidden here
| |
| the lifetime is named here
|
@ -46,10 +46,10 @@ LL | fn comma(x: &'static u8) -> Comma<'static, u8> {
| ++++++++
error: eliding a lifetime that's named elsewhere is confusing
--> $DIR/static.rs:35:19
--> $DIR/static.rs:35:35
|
LL | fn underscore(x: &'static u8) -> &'_ u8 {
| ^^^^^^^ -- the same lifetime is elided here
| ------- ^^ the same lifetime is elided here
| |
| the lifetime is named here
|

View file

@ -36,8 +36,8 @@ fn explicit_bound_path_to_implicit_path<'a>(v: ContainsLifetime<'a>) -> Contains
fn explicit_bound_path_to_explicit_anonymous_path<'a>(
v: ContainsLifetime<'a>,
//~^ ERROR eliding a lifetime that's named elsewhere is confusing
) -> ContainsLifetime<'_> {
//~^ ERROR eliding a lifetime that's named elsewhere is confusing
v
}
@ -188,8 +188,8 @@ mod impl_trait {
fn explicit_bound_path_to_impl_trait_precise_capture<'a>(
v: ContainsLifetime<'a>,
//~^ ERROR eliding a lifetime that's named elsewhere is confusing
) -> impl FnOnce() + use<'_> {
//~^ ERROR eliding a lifetime that's named elsewhere is confusing
move || _ = v
}
}
@ -208,8 +208,8 @@ mod dyn_trait {
fn explicit_bound_path_to_dyn_trait_bound<'a>(
v: ContainsLifetime<'a>,
//~^ ERROR hiding a lifetime that's named elsewhere is confusing
) -> Box<dyn Iterator<Item = ContainsLifetime> + '_> {
//~^ ERROR hiding a lifetime that's named elsewhere is confusing
Box::new(iter::once(v))
}
}

View file

@ -1,8 +1,8 @@
error: eliding a lifetime that's named elsewhere is confusing
--> $DIR/mismatched-lifetime-syntaxes.rs:10:47
--> $DIR/mismatched-lifetime-syntaxes.rs:10:57
|
LL | fn explicit_bound_ref_to_implicit_ref<'a>(v: &'a u8) -> &u8 {
| ^^ --- the same lifetime is elided here
| -- ^^^ the same lifetime is elided here
| |
| the lifetime is named here
|
@ -18,10 +18,10 @@ LL | fn explicit_bound_ref_to_implicit_ref<'a>(v: &'a u8) -> &'a u8 {
| ++
error: eliding a lifetime that's named elsewhere is confusing
--> $DIR/mismatched-lifetime-syntaxes.rs:15:57
--> $DIR/mismatched-lifetime-syntaxes.rs:15:68
|
LL | fn explicit_bound_ref_to_explicit_anonymous_ref<'a>(v: &'a u8) -> &'_ u8 {
| ^^ -- the same lifetime is elided here
| -- ^^ the same lifetime is elided here
| |
| the lifetime is named here
|
@ -36,7 +36,7 @@ error: hiding a lifetime that's elided elsewhere is confusing
--> $DIR/mismatched-lifetime-syntaxes.rs:22:48
|
LL | fn implicit_path_to_explicit_anonymous_path(v: ContainsLifetime) -> ContainsLifetime<'_> {
| ^^^^^^^^^^^^^^^^ -- the same lifetime is elided here
| ^^^^^^^^^^^^^^^^ ^^ the same lifetime is elided here
| |
| the lifetime is hidden here
|
@ -50,7 +50,7 @@ error: hiding a lifetime that's elided elsewhere is confusing
--> $DIR/mismatched-lifetime-syntaxes.rs:27:65
|
LL | fn explicit_anonymous_path_to_implicit_path(v: ContainsLifetime<'_>) -> ContainsLifetime {
| ^^ ---------------- the same lifetime is hidden here
| ^^ ^^^^^^^^^^^^^^^^ the same lifetime is hidden here
| |
| the lifetime is elided here
|
@ -61,10 +61,10 @@ LL | fn explicit_anonymous_path_to_implicit_path(v: ContainsLifetime<'_>) -> Con
| ++++
error: hiding a lifetime that's named elsewhere is confusing
--> $DIR/mismatched-lifetime-syntaxes.rs:32:65
--> $DIR/mismatched-lifetime-syntaxes.rs:32:73
|
LL | fn explicit_bound_path_to_implicit_path<'a>(v: ContainsLifetime<'a>) -> ContainsLifetime {
| ^^ ---------------- the same lifetime is hidden here
| -- ^^^^^^^^^^^^^^^^ the same lifetime is hidden here
| |
| the lifetime is named here
|
@ -75,13 +75,12 @@ LL | fn explicit_bound_path_to_implicit_path<'a>(v: ContainsLifetime<'a>) -> Con
| ++++
error: eliding a lifetime that's named elsewhere is confusing
--> $DIR/mismatched-lifetime-syntaxes.rs:38:25
--> $DIR/mismatched-lifetime-syntaxes.rs:39:23
|
LL | v: ContainsLifetime<'a>,
| ^^ the lifetime is named here
LL |
| -- the lifetime is named here
LL | ) -> ContainsLifetime<'_> {
| -- the same lifetime is elided here
| ^^ the same lifetime is elided here
|
= help: the same lifetime is referred to in inconsistent ways, making the signature confusing
help: consistently use `'a`
@ -94,7 +93,7 @@ error: hiding a lifetime that's elided elsewhere is confusing
--> $DIR/mismatched-lifetime-syntaxes.rs:46:37
|
LL | fn implicit_ref_to_implicit_path(v: &u8) -> ContainsLifetime {
| ^^^ ---------------- the same lifetime is hidden here
| ^^^ ^^^^^^^^^^^^^^^^ the same lifetime is hidden here
| |
| the lifetime is elided here
|
@ -108,7 +107,7 @@ error: hiding a lifetime that's elided elsewhere is confusing
--> $DIR/mismatched-lifetime-syntaxes.rs:51:48
|
LL | fn explicit_anonymous_ref_to_implicit_path(v: &'_ u8) -> ContainsLifetime {
| ^^ ---------------- the same lifetime is hidden here
| ^^ ^^^^^^^^^^^^^^^^ the same lifetime is hidden here
| |
| the lifetime is elided here
|
@ -119,10 +118,10 @@ LL | fn explicit_anonymous_ref_to_implicit_path(v: &'_ u8) -> ContainsLifetime<'
| ++++
error: hiding a lifetime that's named elsewhere is confusing
--> $DIR/mismatched-lifetime-syntaxes.rs:56:48
--> $DIR/mismatched-lifetime-syntaxes.rs:56:58
|
LL | fn explicit_bound_ref_to_implicit_path<'a>(v: &'a u8) -> ContainsLifetime {
| ^^ ---------------- the same lifetime is hidden here
| -- ^^^^^^^^^^^^^^^^ the same lifetime is hidden here
| |
| the lifetime is named here
|
@ -133,10 +132,10 @@ LL | fn explicit_bound_ref_to_implicit_path<'a>(v: &'a u8) -> ContainsLifetime<'
| ++++
error: eliding a lifetime that's named elsewhere is confusing
--> $DIR/mismatched-lifetime-syntaxes.rs:61:58
--> $DIR/mismatched-lifetime-syntaxes.rs:61:85
|
LL | fn explicit_bound_ref_to_explicit_anonymous_path<'a>(v: &'a u8) -> ContainsLifetime<'_> {
| ^^ -- the same lifetime is elided here
| -- ^^ the same lifetime is elided here
| |
| the lifetime is named here
|
@ -151,7 +150,7 @@ error: hiding a lifetime that's elided elsewhere is confusing
--> $DIR/mismatched-lifetime-syntaxes.rs:68:37
|
LL | fn implicit_path_to_implicit_ref(v: ContainsLifetime) -> &u8 {
| ^^^^^^^^^^^^^^^^ --- the same lifetime is elided here
| ^^^^^^^^^^^^^^^^ ^^^ the same lifetime is elided here
| |
| the lifetime is hidden here
|
@ -165,7 +164,7 @@ error: hiding a lifetime that's elided elsewhere is confusing
--> $DIR/mismatched-lifetime-syntaxes.rs:73:47
|
LL | fn implicit_path_to_explicit_anonymous_ref(v: ContainsLifetime) -> &'_ u8 {
| ^^^^^^^^^^^^^^^^ -- the same lifetime is elided here
| ^^^^^^^^^^^^^^^^ ^^ the same lifetime is elided here
| |
| the lifetime is hidden here
|
@ -176,10 +175,10 @@ LL | fn implicit_path_to_explicit_anonymous_ref(v: ContainsLifetime<'_>) -> &'_
| ++++
error: eliding a lifetime that's named elsewhere is confusing
--> $DIR/mismatched-lifetime-syntaxes.rs:78:64
--> $DIR/mismatched-lifetime-syntaxes.rs:78:72
|
LL | fn explicit_bound_path_to_implicit_ref<'a>(v: ContainsLifetime<'a>) -> &u8 {
| ^^ --- the same lifetime is elided here
| -- ^^^ the same lifetime is elided here
| |
| the lifetime is named here
|
@ -190,10 +189,10 @@ LL | fn explicit_bound_path_to_implicit_ref<'a>(v: ContainsLifetime<'a>) -> &'a
| ++
error: eliding a lifetime that's named elsewhere is confusing
--> $DIR/mismatched-lifetime-syntaxes.rs:83:74
--> $DIR/mismatched-lifetime-syntaxes.rs:83:83
|
LL | fn explicit_bound_path_to_explicit_anonymous_ref<'a>(v: ContainsLifetime<'a>) -> &'_ u8 {
| ^^ -- the same lifetime is elided here
| -- ^^ the same lifetime is elided here
| |
| the lifetime is named here
|
@ -205,10 +204,10 @@ LL + fn explicit_bound_path_to_explicit_anonymous_ref<'a>(v: ContainsLifetime<'a
|
error: eliding a lifetime that's named elsewhere is confusing
--> $DIR/mismatched-lifetime-syntaxes.rs:89:55
--> $DIR/mismatched-lifetime-syntaxes.rs:89:67
|
LL | fn method_explicit_bound_ref_to_implicit_ref<'a>(&'a self) -> &u8 {
| ^^ --- the same lifetime is elided here
| -- ^^^ the same lifetime is elided here
| |
| the lifetime is named here
|
@ -219,10 +218,10 @@ LL | fn method_explicit_bound_ref_to_implicit_ref<'a>(&'a self) -> &'a u8 {
| ++
error: eliding a lifetime that's named elsewhere is confusing
--> $DIR/mismatched-lifetime-syntaxes.rs:94:65
--> $DIR/mismatched-lifetime-syntaxes.rs:94:78
|
LL | fn method_explicit_bound_ref_to_explicit_anonymous_ref<'a>(&'a self) -> &'_ u8 {
| ^^ -- the same lifetime is elided here
| -- ^^ the same lifetime is elided here
| |
| the lifetime is named here
|
@ -237,7 +236,7 @@ error: hiding a lifetime that's elided elsewhere is confusing
--> $DIR/mismatched-lifetime-syntaxes.rs:101:56
|
LL | fn method_explicit_anonymous_ref_to_implicit_path(&'_ self) -> ContainsLifetime {
| ^^ ---------------- the same lifetime is hidden here
| ^^ ^^^^^^^^^^^^^^^^ the same lifetime is hidden here
| |
| the lifetime is elided here
|
@ -248,10 +247,10 @@ LL | fn method_explicit_anonymous_ref_to_implicit_path(&'_ self) -> Contains
| ++++
error: hiding a lifetime that's named elsewhere is confusing
--> $DIR/mismatched-lifetime-syntaxes.rs:106:56
--> $DIR/mismatched-lifetime-syntaxes.rs:106:68
|
LL | fn method_explicit_bound_ref_to_implicit_path<'a>(&'a self) -> ContainsLifetime {
| ^^ ---------------- the same lifetime is hidden here
| -- ^^^^^^^^^^^^^^^^ the same lifetime is hidden here
| |
| the lifetime is named here
|
@ -262,10 +261,10 @@ LL | fn method_explicit_bound_ref_to_implicit_path<'a>(&'a self) -> Contains
| ++++
error: eliding a lifetime that's named elsewhere is confusing
--> $DIR/mismatched-lifetime-syntaxes.rs:111:66
--> $DIR/mismatched-lifetime-syntaxes.rs:111:95
|
LL | fn method_explicit_bound_ref_to_explicit_anonymous_path<'a>(&'a self) -> ContainsLifetime<'_> {
| ^^ -- the same lifetime is elided here
| -- ^^ the same lifetime is elided here
| |
| the lifetime is named here
|
@ -277,10 +276,10 @@ LL + fn method_explicit_bound_ref_to_explicit_anonymous_path<'a>(&'a self) -
|
error: eliding a lifetime that's named elsewhere is confusing
--> $DIR/mismatched-lifetime-syntaxes.rs:126:39
--> $DIR/mismatched-lifetime-syntaxes.rs:126:54
|
LL | fn static_ref_to_implicit_ref(v: &'static u8) -> &u8 {
| ^^^^^^^ --- the same lifetime is elided here
| ------- ^^^ the same lifetime is elided here
| |
| the lifetime is named here
|
@ -291,10 +290,10 @@ LL | fn static_ref_to_implicit_ref(v: &'static u8) -> &'static u8 {
| +++++++
error: eliding a lifetime that's named elsewhere is confusing
--> $DIR/mismatched-lifetime-syntaxes.rs:131:49
--> $DIR/mismatched-lifetime-syntaxes.rs:131:65
|
LL | fn static_ref_to_explicit_anonymous_ref(v: &'static u8) -> &'_ u8 {
| ^^^^^^^ -- the same lifetime is elided here
| ------- ^^ the same lifetime is elided here
| |
| the lifetime is named here
|
@ -306,10 +305,10 @@ LL + fn static_ref_to_explicit_anonymous_ref(v: &'static u8) -> &'static u8
|
error: hiding a lifetime that's named elsewhere is confusing
--> $DIR/mismatched-lifetime-syntaxes.rs:136:40
--> $DIR/mismatched-lifetime-syntaxes.rs:136:55
|
LL | fn static_ref_to_implicit_path(v: &'static u8) -> ContainsLifetime {
| ^^^^^^^ ---------------- the same lifetime is hidden here
| ------- ^^^^^^^^^^^^^^^^ the same lifetime is hidden here
| |
| the lifetime is named here
|
@ -320,10 +319,10 @@ LL | fn static_ref_to_implicit_path(v: &'static u8) -> ContainsLifetime<'sta
| +++++++++
error: eliding a lifetime that's named elsewhere is confusing
--> $DIR/mismatched-lifetime-syntaxes.rs:141:50
--> $DIR/mismatched-lifetime-syntaxes.rs:141:82
|
LL | fn static_ref_to_explicit_anonymous_path(v: &'static u8) -> ContainsLifetime<'_> {
| ^^^^^^^ -- the same lifetime is elided here
| ------- ^^ the same lifetime is elided here
| |
| the lifetime is named here
|
@ -335,10 +334,10 @@ LL + fn static_ref_to_explicit_anonymous_path(v: &'static u8) -> ContainsLif
|
error: eliding a lifetime that's named elsewhere is confusing
--> $DIR/mismatched-lifetime-syntaxes.rs:147:40
--> $DIR/mismatched-lifetime-syntaxes.rs:147:57
|
LL | fn static_ref_to_implicit_ref(&'static self) -> &u8 {
| ^^^^^^^ --- the same lifetime is elided here
| ------- ^^^ the same lifetime is elided here
| |
| the lifetime is named here
|
@ -349,10 +348,10 @@ LL | fn static_ref_to_implicit_ref(&'static self) -> &'static u8 {
| +++++++
error: eliding a lifetime that's named elsewhere is confusing
--> $DIR/mismatched-lifetime-syntaxes.rs:152:50
--> $DIR/mismatched-lifetime-syntaxes.rs:152:68
|
LL | fn static_ref_to_explicit_anonymous_ref(&'static self) -> &'_ u8 {
| ^^^^^^^ -- the same lifetime is elided here
| ------- ^^ the same lifetime is elided here
| |
| the lifetime is named here
|
@ -364,10 +363,10 @@ LL + fn static_ref_to_explicit_anonymous_ref(&'static self) -> &'static
|
error: hiding a lifetime that's named elsewhere is confusing
--> $DIR/mismatched-lifetime-syntaxes.rs:157:41
--> $DIR/mismatched-lifetime-syntaxes.rs:157:58
|
LL | fn static_ref_to_implicit_path(&'static self) -> ContainsLifetime {
| ^^^^^^^ ---------------- the same lifetime is hidden here
| ------- ^^^^^^^^^^^^^^^^ the same lifetime is hidden here
| |
| the lifetime is named here
|
@ -378,10 +377,10 @@ LL | fn static_ref_to_implicit_path(&'static self) -> ContainsLifetime<'
| +++++++++
error: eliding a lifetime that's named elsewhere is confusing
--> $DIR/mismatched-lifetime-syntaxes.rs:162:51
--> $DIR/mismatched-lifetime-syntaxes.rs:162:85
|
LL | fn static_ref_to_explicit_anonymous_path(&'static self) -> ContainsLifetime<'_> {
| ^^^^^^^ -- the same lifetime is elided here
| ------- ^^ the same lifetime is elided here
| |
| the lifetime is named here
|
@ -393,10 +392,10 @@ LL + fn static_ref_to_explicit_anonymous_path(&'static self) -> Contains
|
error: eliding a lifetime that's named elsewhere is confusing
--> $DIR/mismatched-lifetime-syntaxes.rs:174:55
--> $DIR/mismatched-lifetime-syntaxes.rs:174:81
|
LL | fn explicit_bound_ref_to_impl_trait_bound<'a>(v: &'a u8) -> impl FnOnce() + '_ {
| ^^ -- the same lifetime is elided here
| -- ^^ the same lifetime is elided here
| |
| the lifetime is named here
|
@ -408,10 +407,10 @@ LL + fn explicit_bound_ref_to_impl_trait_bound<'a>(v: &'a u8) -> impl FnOnce
|
error: eliding a lifetime that's named elsewhere is confusing
--> $DIR/mismatched-lifetime-syntaxes.rs:179:65
--> $DIR/mismatched-lifetime-syntaxes.rs:179:95
|
LL | fn explicit_bound_ref_to_impl_trait_precise_capture<'a>(v: &'a u8) -> impl FnOnce() + use<'_> {
| ^^ the lifetime is named here -- the same lifetime is elided here
| -- the lifetime is named here ^^ the same lifetime is elided here
|
= help: the same lifetime is referred to in inconsistent ways, making the signature confusing
help: consistently use `'a`
@ -421,10 +420,10 @@ LL + fn explicit_bound_ref_to_impl_trait_precise_capture<'a>(v: &'a u8) -> i
|
error: eliding a lifetime that's named elsewhere is confusing
--> $DIR/mismatched-lifetime-syntaxes.rs:184:72
--> $DIR/mismatched-lifetime-syntaxes.rs:184:96
|
LL | fn explicit_bound_path_to_impl_trait_bound<'a>(v: ContainsLifetime<'a>) -> impl FnOnce() + '_ {
| ^^ -- the same lifetime is elided here
| -- ^^ the same lifetime is elided here
| |
| the lifetime is named here
|
@ -436,13 +435,12 @@ LL + fn explicit_bound_path_to_impl_trait_bound<'a>(v: ContainsLifetime<'a>)
|
error: eliding a lifetime that's named elsewhere is confusing
--> $DIR/mismatched-lifetime-syntaxes.rs:190:29
--> $DIR/mismatched-lifetime-syntaxes.rs:191:30
|
LL | v: ContainsLifetime<'a>,
| ^^ the lifetime is named here
LL |
| -- the lifetime is named here
LL | ) -> impl FnOnce() + use<'_> {
| -- the same lifetime is elided here
| ^^ the same lifetime is elided here
|
= help: the same lifetime is referred to in inconsistent ways, making the signature confusing
help: consistently use `'a`
@ -452,10 +450,10 @@ LL + ) -> impl FnOnce() + use<'a> {
|
error: eliding a lifetime that's named elsewhere is confusing
--> $DIR/mismatched-lifetime-syntaxes.rs:204:54
--> $DIR/mismatched-lifetime-syntaxes.rs:204:88
|
LL | fn explicit_bound_ref_to_dyn_trait_bound<'a>(v: &'a u8) -> Box<dyn Iterator<Item = &u8> + '_> {
| ^^ the lifetime is named here --- the same lifetime is elided here
| -- the lifetime is named here ^^^ the same lifetime is elided here
|
= help: the same lifetime is referred to in inconsistent ways, making the signature confusing
help: consistently use `'a`
@ -464,13 +462,12 @@ LL | fn explicit_bound_ref_to_dyn_trait_bound<'a>(v: &'a u8) -> Box<dyn Iter
| ++
error: hiding a lifetime that's named elsewhere is confusing
--> $DIR/mismatched-lifetime-syntaxes.rs:210:29
--> $DIR/mismatched-lifetime-syntaxes.rs:211:34
|
LL | v: ContainsLifetime<'a>,
| ^^ the lifetime is named here
LL |
| -- the lifetime is named here
LL | ) -> Box<dyn Iterator<Item = ContainsLifetime> + '_> {
| ---------------- the same lifetime is hidden here
| ^^^^^^^^^^^^^^^^ the same lifetime is hidden here
|
= help: the same lifetime is referred to in inconsistent ways, making the signature confusing
help: consistently use `'a`
@ -479,10 +476,10 @@ LL | ) -> Box<dyn Iterator<Item = ContainsLifetime<'a>> + '_> {
| ++++
error: eliding a lifetime that's named elsewhere is confusing
--> $DIR/mismatched-lifetime-syntaxes.rs:222:33
--> $DIR/mismatched-lifetime-syntaxes.rs:222:52
|
LL | fn multiple_inputs<'a>(v: (&'a u8, &'a u8)) -> &u8 {
| ^^ ^^ --- the same lifetime is elided here
| -- -- ^^^ the same lifetime is elided here
| | |
| | the lifetime is named here
| the lifetime is named here
@ -494,10 +491,10 @@ LL | fn multiple_inputs<'a>(v: (&'a u8, &'a u8)) -> &'a u8 {
| ++
error: eliding a lifetime that's named elsewhere is confusing
--> $DIR/mismatched-lifetime-syntaxes.rs:227:33
--> $DIR/mismatched-lifetime-syntaxes.rs:227:44
|
LL | fn multiple_outputs<'a>(v: &'a u8) -> (&u8, &u8) {
| ^^ --- --- the same lifetime is elided here
| -- ^^^ ^^^ the same lifetime is elided here
| | |
| | the same lifetime is elided here
| the lifetime is named here
@ -509,10 +506,10 @@ LL | fn multiple_outputs<'a>(v: &'a u8) -> (&'a u8, &'a u8) {
| ++ ++
error: hiding or eliding a lifetime that's named elsewhere is confusing
--> $DIR/mismatched-lifetime-syntaxes.rs:232:53
--> $DIR/mismatched-lifetime-syntaxes.rs:232:62
|
LL | fn all_three_categories<'a>(v: ContainsLifetime<'a>) -> (&u8, ContainsLifetime) {
| ^^ --- ---------------- the same lifetime is hidden here
| -- ^^^ ^^^^^^^^^^^^^^^^ the same lifetime is hidden here
| | |
| | the same lifetime is elided here
| the lifetime is named here
@ -524,10 +521,10 @@ LL | fn all_three_categories<'a>(v: ContainsLifetime<'a>) -> (&'a u8, Contai
| ++ ++++
error: eliding a lifetime that's named elsewhere is confusing
--> $DIR/mismatched-lifetime-syntaxes.rs:237:38
--> $DIR/mismatched-lifetime-syntaxes.rs:237:49
|
LL | fn explicit_bound_output<'a>(v: &'a u8) -> (&u8, &'a u8, ContainsLifetime<'a>) {
| ^^ --- -- -- the same lifetime is named here
| -- ^^^ -- -- the same lifetime is named here
| | | |
| | | the same lifetime is named here
| | the same lifetime is elided here
@ -543,7 +540,7 @@ error: hiding a lifetime that's elided elsewhere is confusing
--> $DIR/mismatched-lifetime-syntaxes.rs:250:45
|
LL | fn implicit_ref_to_implicit_path(v: &u8) -> ContainsLifetime;
| ^^^ ---------------- the same lifetime is hidden here
| ^^^ ^^^^^^^^^^^^^^^^ the same lifetime is hidden here
| |
| the lifetime is elided here
|
@ -557,7 +554,7 @@ error: hiding a lifetime that's elided elsewhere is confusing
--> $DIR/mismatched-lifetime-syntaxes.rs:253:49
|
LL | fn method_implicit_ref_to_implicit_path(&self) -> ContainsLifetime;
| ^^^^^ ---------------- the same lifetime is hidden here
| ^^^^^ ^^^^^^^^^^^^^^^^ the same lifetime is hidden here
| |
| the lifetime is elided here
|
@ -571,7 +568,7 @@ error: hiding a lifetime that's elided elsewhere is confusing
--> $DIR/mismatched-lifetime-syntaxes.rs:258:45
|
LL | fn implicit_ref_to_implicit_path(v: &u8) -> ContainsLifetime {
| ^^^ ---------------- the same lifetime is hidden here
| ^^^ ^^^^^^^^^^^^^^^^ the same lifetime is hidden here
| |
| the lifetime is elided here
|
@ -585,7 +582,7 @@ error: hiding a lifetime that's elided elsewhere is confusing
--> $DIR/mismatched-lifetime-syntaxes.rs:263:49
|
LL | fn method_implicit_ref_to_implicit_path(&self) -> ContainsLifetime {
| ^^^^^ ---------------- the same lifetime is hidden here
| ^^^^^ ^^^^^^^^^^^^^^^^ the same lifetime is hidden here
| |
| the lifetime is elided here
|
@ -599,7 +596,7 @@ error: hiding a lifetime that's elided elsewhere is confusing
--> $DIR/mismatched-lifetime-syntaxes.rs:277:45
|
LL | fn implicit_ref_to_implicit_path(v: &u8) -> ContainsLifetime;
| ^^^ ---------------- the same lifetime is hidden here
| ^^^ ^^^^^^^^^^^^^^^^ the same lifetime is hidden here
| |
| the lifetime is elided here
|

View file

@ -1,8 +1,8 @@
warning: eliding a lifetime that's named elsewhere is confusing
--> $DIR/ignore-non-reference-lifetimes.rs:6:30
--> $DIR/ignore-non-reference-lifetimes.rs:6:41
|
LL | fn a<'a>(self: Self, a: &'a str) -> &str {
| ^^ ---- the same lifetime is elided here
| -- ^^^^ the same lifetime is elided here
| |
| the lifetime is named here
|
@ -14,10 +14,10 @@ LL | fn a<'a>(self: Self, a: &'a str) -> &'a str {
| ++
warning: eliding a lifetime that's named elsewhere is confusing
--> $DIR/ignore-non-reference-lifetimes.rs:10:33
--> $DIR/ignore-non-reference-lifetimes.rs:10:44
|
LL | fn b<'a>(self: Foo<'b>, a: &'a str) -> &str {
| ^^ ---- the same lifetime is elided here
| -- ^^^^ the same lifetime is elided here
| |
| the lifetime is named here
|

View file

@ -1,8 +1,8 @@
warning: eliding a lifetime that's named elsewhere is confusing
--> $DIR/self_lifetime-async.rs:6:29
--> $DIR/self_lifetime-async.rs:6:44
|
LL | async fn foo<'b>(self: &'b Foo<'a>) -> &() { self.0 }
| ^^ --- the same lifetime is elided here
| -- ^^^ the same lifetime is elided here
| |
| the lifetime is named here
|
@ -14,10 +14,10 @@ LL | async fn foo<'b>(self: &'b Foo<'a>) -> &'b () { self.0 }
| ++
warning: eliding a lifetime that's named elsewhere is confusing
--> $DIR/self_lifetime-async.rs:12:42
--> $DIR/self_lifetime-async.rs:12:52
|
LL | async fn bar<'a>(self: &Alias, arg: &'a ()) -> &() { arg }
| ^^ --- the same lifetime is elided here
| -- ^^^ the same lifetime is elided here
| |
| the lifetime is named here
|

View file

@ -1,8 +1,8 @@
warning: eliding a lifetime that's named elsewhere is confusing
--> $DIR/self_lifetime.rs:7:23
--> $DIR/self_lifetime.rs:7:38
|
LL | fn foo<'b>(self: &'b Foo<'a>) -> &() { self.0 }
| ^^ --- the same lifetime is elided here
| -- ^^^ the same lifetime is elided here
| |
| the lifetime is named here
|
@ -14,10 +14,10 @@ LL | fn foo<'b>(self: &'b Foo<'a>) -> &'b () { self.0 }
| ++
warning: eliding a lifetime that's named elsewhere is confusing
--> $DIR/self_lifetime.rs:13:36
--> $DIR/self_lifetime.rs:13:46
|
LL | fn bar<'a>(self: &Alias, arg: &'a ()) -> &() { arg }
| ^^ --- the same lifetime is elided here
| -- ^^^ the same lifetime is elided here
| |
| the lifetime is named here
|