about summary refs log tree commit diff
path: root/compiler/rustc_resolve/src
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2020-09-17 10:13:16 +0200
committerMatthias Krüger <matthias.krueger@famsik.de>2020-09-17 10:13:16 +0200
commit012974da7ad3737b296af4a401dfed2e8dcc22df (patch)
treed125772c1968f2e2aaadd26f6750e47bb07a108e /compiler/rustc_resolve/src
parent95386b656e91168bf53e2ab63c6b992cae591fe7 (diff)
downloadrust-012974da7ad3737b296af4a401dfed2e8dcc22df.tar.gz
rust-012974da7ad3737b296af4a401dfed2e8dcc22df.zip
use strip_prefix over starts_with and manual slicing based on pattern length (clippy::manual_strip)
Diffstat (limited to 'compiler/rustc_resolve/src')
-rw-r--r--compiler/rustc_resolve/src/late/diagnostics.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/compiler/rustc_resolve/src/late/diagnostics.rs b/compiler/rustc_resolve/src/late/diagnostics.rs
index 2cc87dc6375..ced272e474d 100644
--- a/compiler/rustc_resolve/src/late/diagnostics.rs
+++ b/compiler/rustc_resolve/src/late/diagnostics.rs
@@ -1418,9 +1418,9 @@ impl<'tcx> LifetimeContext<'_, 'tcx> {
                         if snippet.starts_with('&') && !snippet.starts_with("&'") {
                             introduce_suggestion
                                 .push((param.span, format!("&{} {}", lt_name, &snippet[1..])));
-                        } else if snippet.starts_with("&'_ ") {
+                        } else if let Some(stripped) = snippet.strip_prefix("&'_ ") {
                             introduce_suggestion
-                                .push((param.span, format!("&{} {}", lt_name, &snippet[4..])));
+                                .push((param.span, format!("&{} {}", lt_name, stripped)));
                         }
                     }
                 }