Skip to content

Commit 9af8a38

Browse files
committed
Account for '_ in suggestions
1 parent 5453c03 commit 9af8a38

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/librustc_resolve/diagnostics.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1516,6 +1516,9 @@ crate fn add_missing_lifetime_specifiers_label(
15161516
if snippet.starts_with("&") && !snippet.starts_with("&'") {
15171517
introduce_suggestion
15181518
.push((param.span, format!("&'a {}", &snippet[1..])));
1519+
} else if snippet.starts_with("&'_ ") {
1520+
introduce_suggestion
1521+
.push((param.span, format!("&'a {}", &snippet[4..])));
15191522
}
15201523
}
15211524
}

src/test/ui/underscore-lifetime/underscore-lifetime-binders.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ LL | fn foo2(_: &'_ u8, y: &'_ u8) -> &'_ u8 { y }
3737
| ^^^^^^ ^^^^^^
3838
help: consider introducing a named lifetime parameter
3939
|
40-
LL | fn foo2<'a>(_: &'_ u8, y: &'_ u8) -> &'a u8 { y }
41-
| ^^^^ ^^
40+
LL | fn foo2<'a>(_: &'a u8, y: &'a u8) -> &'a u8 { y }
41+
| ^^^^ ^^^^^^ ^^^^^^ ^^
4242

4343
error: aborting due to 5 previous errors
4444

0 commit comments

Comments
 (0)