Skip to content

Commit ba3b44c

Browse files
committed
Account for '_ in suggestions
1 parent 2100b31 commit ba3b44c

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/librustc_resolve/diagnostics.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1521,6 +1521,9 @@ crate fn add_missing_lifetime_specifiers_label(
15211521
if snippet.starts_with("&") && !snippet.starts_with("&'") {
15221522
introduce_suggestion
15231523
.push((param.span, format!("&'a {}", &snippet[1..])));
1524+
} else if snippet.starts_with("&'_ ") {
1525+
introduce_suggestion
1526+
.push((param.span, format!("&'a {}", &snippet[4..])));
15241527
}
15251528
}
15261529
}

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

Lines changed: 2 additions & 2 deletions
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)