1
Fork 0

Strip prefix instead of replacing it with empty string

This commit is contained in:
LingMan 2020-12-08 14:46:19 +01:00
parent 3d6705aa5a
commit 06aa7a7601

View file

@ -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,
));
}