about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEsteban Küber <esteban@kuber.com.ar>2020-01-27 14:35:20 -0800
committerEsteban Küber <esteban@kuber.com.ar>2020-02-05 10:32:01 -0800
commitba3b44c508b133829f7b6a57f3e62c0735a7d110 (patch)
treefa473505b37f4f3fb20ed03546f6a5030a5c0bd7
parent2100b31535a2a6a51876c024591b9e5679692a9c (diff)
downloadrust-ba3b44c508b133829f7b6a57f3e62c0735a7d110.tar.gz
rust-ba3b44c508b133829f7b6a57f3e62c0735a7d110.zip
Account for `'_` in suggestions
-rw-r--r--src/librustc_resolve/diagnostics.rs3
-rw-r--r--src/test/ui/underscore-lifetime/underscore-lifetime-binders.stderr4
2 files changed, 5 insertions, 2 deletions
diff --git a/src/librustc_resolve/diagnostics.rs b/src/librustc_resolve/diagnostics.rs
index b62c9f4747c..3b689f03b43 100644
--- a/src/librustc_resolve/diagnostics.rs
+++ b/src/librustc_resolve/diagnostics.rs
@@ -1521,6 +1521,9 @@ crate fn add_missing_lifetime_specifiers_label(
                         if snippet.starts_with("&") && !snippet.starts_with("&'") {
                             introduce_suggestion
                                 .push((param.span, format!("&'a {}", &snippet[1..])));
+                        } else if snippet.starts_with("&'_ ") {
+                            introduce_suggestion
+                                .push((param.span, format!("&'a {}", &snippet[4..])));
                         }
                     }
                 }
diff --git a/src/test/ui/underscore-lifetime/underscore-lifetime-binders.stderr b/src/test/ui/underscore-lifetime/underscore-lifetime-binders.stderr
index f2eab86ae57..d0eda1b6153 100644
--- a/src/test/ui/underscore-lifetime/underscore-lifetime-binders.stderr
+++ b/src/test/ui/underscore-lifetime/underscore-lifetime-binders.stderr
@@ -37,8 +37,8 @@ LL | fn foo2(_: &'_ u8, y: &'_ u8) -> &'_ u8 { y }
    |            ^^^^^^     ^^^^^^
 help: consider introducing a named lifetime parameter
    |
-LL | fn foo2<'a>(_: &'_ u8, y: &'_ u8) -> &'a u8 { y }
-   |        ^^^^                           ^^
+LL | fn foo2<'a>(_: &'a u8, y: &'a u8) -> &'a u8 { y }
+   |        ^^^^    ^^^^^^     ^^^^^^      ^^
 
 error: aborting due to 5 previous errors