Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions compiler/rustc_lint/src/lifetime_syntax.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}

Expand Down Expand Up @@ -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 },
);
}
Expand Down
4 changes: 2 additions & 2 deletions src/tools/clippy/tests/ui/ptr_arg.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions tests/ui/impl-trait/rpit-assoc-pair-with-lifetime.stderr
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
|
Expand Down
Original file line number Diff line number Diff line change
@@ -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
|
Expand All @@ -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
|
Expand All @@ -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
|
Expand All @@ -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
|
Expand Down
Original file line number Diff line number Diff line change
@@ -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
|
Expand All @@ -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
|
Expand Down
Original file line number Diff line number Diff line change
@@ -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
|
Expand All @@ -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
|
Expand All @@ -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
|
Expand All @@ -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
|
Expand Down
6 changes: 3 additions & 3 deletions tests/ui/lifetimes/mismatched-lifetime-syntaxes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -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
}
}
Expand All @@ -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))
}
}
Expand Down
Loading
Loading