Skip to content

Commit

Permalink
Strip prefix instead of replacing it with empty string
Browse files Browse the repository at this point in the history
  • Loading branch information
LingMan committed Dec 8, 2020
1 parent 3d6705a commit 06aa7a7
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions compiler/rustc_typeck/src/check/demand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
));
}
Expand Down

0 comments on commit 06aa7a7

Please sign in to comment.