about summary refs log tree commit diff
diff options
context:
space:
mode:
authorTyler Mandry <tmandry@gmail.com>2020-12-09 13:38:31 -0800
committerGitHub <noreply@github.com>2020-12-09 13:38:31 -0800
commit666d1a8951093a5cc6e3e83bdc2cff9d7cd83045 (patch)
treedb004a9d7363448061e0c4836615abb6602b5eec
parent3b49a46c6b6bb2731d28ec1e7011fba13d002a42 (diff)
parent06aa7a7601fe53bb095543bd633da3e165df2738 (diff)
downloadrust-666d1a8951093a5cc6e3e83bdc2cff9d7cd83045.tar.gz
rust-666d1a8951093a5cc6e3e83bdc2cff9d7cd83045.zip
Rollup merge of #79824 - LingMan:no_replace, r=lcnr
Strip prefix instead of replacing it with empty string

r? `@lcnr,` since you reviewed my other PR in the area.
`@rustbot` modify labels +C-cleanup +T-compiler
-rw-r--r--compiler/rustc_typeck/src/check/demand.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/compiler/rustc_typeck/src/check/demand.rs b/compiler/rustc_typeck/src/check/demand.rs
index 763e4d651a2..aa4d57f7e1d 100644
--- a/compiler/rustc_typeck/src/check/demand.rs
+++ b/compiler/rustc_typeck/src/check/demand.rs
@@ -548,11 +548,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
                 // we may want to suggest removing a `&`.
                 if sm.is_imported(expr.span) {
                     if let Ok(src) = sm.span_to_snippet(sp) {
-                        if let Some(src) = self.replace_prefix(&src, "&", "") {
+                        if let Some(src) = src.strip_prefix('&') {
                             return Some((
                                 sp,
                                 "consider removing the borrow",
-                                src,
+                                src.to_string(),
                                 Applicability::MachineApplicable,
                             ));
                         }