about summary refs log tree commit diff
path: root/compiler
diff options
context:
space:
mode:
authorAaron Hill <aa1ronham@gmail.com>2021-10-03 16:29:34 -0500
committerAaron Hill <aa1ronham@gmail.com>2021-10-03 21:53:48 -0500
commitfdd8a0dde53e09b2f0ec869088fcb1d882031bd6 (patch)
tree420e364a1ec92fecd01019cb00090650d1d8b8d6 /compiler
parent08759c691e2e9799a3c6780ffdf910240ebd4a6b (diff)
downloadrust-fdd8a0dde53e09b2f0ec869088fcb1d882031bd6.tar.gz
rust-fdd8a0dde53e09b2f0ec869088fcb1d882031bd6.zip
Don't suggest replacing region with 'static in NLL
Fixes #73159

This is similar to #69350 - if the user didn't initially
write out a 'static lifetime, adding 'static in response to
a lifetime error is usually the wrong thing to do.
Diffstat (limited to 'compiler')
-rw-r--r--compiler/rustc_borrowck/src/diagnostics/outlives_suggestion.rs4
1 files changed, 1 insertions, 3 deletions
diff --git a/compiler/rustc_borrowck/src/diagnostics/outlives_suggestion.rs b/compiler/rustc_borrowck/src/diagnostics/outlives_suggestion.rs
index 9de0c62f186..b15e55cd667 100644
--- a/compiler/rustc_borrowck/src/diagnostics/outlives_suggestion.rs
+++ b/compiler/rustc_borrowck/src/diagnostics/outlives_suggestion.rs
@@ -171,9 +171,7 @@ impl OutlivesSuggestionBuilder {
         let outlived_fr_name = self.region_vid_to_name(mbcx, errci.outlived_fr);
 
         if let (Some(fr_name), Some(outlived_fr_name)) = (fr_name, outlived_fr_name) {
-            if let RegionNameSource::Static = outlived_fr_name.source {
-                diag.help(&format!("consider replacing `{}` with `'static`", fr_name));
-            } else {
+            if !matches!(outlived_fr_name.source, RegionNameSource::Static) {
                 diag.help(&format!(
                     "consider adding the following bound: `{}: {}`",
                     fr_name, outlived_fr_name