diff options
| author | LingMan <LingMan@users.noreply.github.com> | 2020-12-08 14:46:19 +0100 |
|---|---|---|
| committer | LingMan <LingMan@users.noreply.github.com> | 2020-12-08 14:46:19 +0100 |
| commit | 06aa7a7601fe53bb095543bd633da3e165df2738 (patch) | |
| tree | d34c97e27d7d05e49509b355b8e79f13411dc252 /compiler | |
| parent | 3d6705aa5abffe94c83bf09af8c3ba3c599845fc (diff) | |
| download | rust-06aa7a7601fe53bb095543bd633da3e165df2738.tar.gz rust-06aa7a7601fe53bb095543bd633da3e165df2738.zip | |
Strip prefix instead of replacing it with empty string
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_typeck/src/check/demand.rs | 4 |
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 d12d2cb59a5..e1ff1925a14 100644 --- a/compiler/rustc_typeck/src/check/demand.rs +++ b/compiler/rustc_typeck/src/check/demand.rs @@ -552,11 +552,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, )); } |
