Skip to content

Commit

Permalink
Rollup merge of #79824 - LingMan:no_replace, r=lcnr
Browse files Browse the repository at this point in the history
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
  • Loading branch information
tmandry authored Dec 9, 2020
2 parents 3b49a46 + 06aa7a7 commit 666d1a8
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 @@ -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,
));
}
Expand Down

0 comments on commit 666d1a8

Please sign in to comment.