Do not suggest borrowing when the span comes from a macro
This commit is contained in:
parent
4c27fb19ba
commit
0acb7867c2
2 changed files with 5 additions and 7 deletions
|
|
@ -10,7 +10,7 @@ use rustc::hir::Node;
|
|||
use rustc::hir::{Item, ItemKind, print};
|
||||
use rustc::ty::{self, Ty, AssociatedItem};
|
||||
use rustc::ty::adjustment::AllowTwoPhase;
|
||||
use errors::{Applicability, DiagnosticBuilder, SourceMapper};
|
||||
use errors::{Applicability, DiagnosticBuilder};
|
||||
|
||||
use super::method::probe;
|
||||
|
||||
|
|
@ -271,9 +271,10 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
|||
expected: Ty<'tcx>)
|
||||
-> Option<(Span, &'static str, String)> {
|
||||
let cm = self.sess().source_map();
|
||||
// Use the callsite's span if this is a macro call. #41858
|
||||
let sp = cm.call_span_if_macro(expr.span);
|
||||
let sp = expr.span;
|
||||
if !cm.span_to_filename(sp).is_real() {
|
||||
// Ignore if span is from within a macro #41858, #58298. We previously used the macro
|
||||
// call span, but that breaks down when the type error comes from multiple calls down.
|
||||
return None;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -50,10 +50,7 @@ error[E0308]: mismatched types
|
|||
--> $DIR/coerce-suggestions.rs:21:9
|
||||
|
|
||||
LL | s = format!("foo");
|
||||
| ^^^^^^^^^^^^^^
|
||||
| |
|
||||
| expected mutable reference, found struct `std::string::String`
|
||||
| help: consider mutably borrowing here: `&mut format!("foo")`
|
||||
| ^^^^^^^^^^^^^^ expected mutable reference, found struct `std::string::String`
|
||||
|
|
||||
= note: expected type `&mut std::string::String`
|
||||
found type `std::string::String`
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue