Use callsite's span for macro calls on suggestion

When suggesting an appropriate mutability for a macro call, use the call
span instead of the expanded macro's span.
This commit is contained in:
Esteban Küber
2017-05-31 23:48:19 -07:00
parent 4ed2edaafe
commit 4142d7bb89
6 changed files with 36 additions and 7 deletions

View File

@@ -563,6 +563,15 @@ impl CodeMapper for CodeMap {
fn merge_spans(&self, sp_lhs: Span, sp_rhs: Span) -> Option<Span> {
self.merge_spans(sp_lhs, sp_rhs)
}
fn call_span_if_macro(&self, sp: Span) -> Span {
if self.span_to_filename(sp.clone()).contains("macros>") {
let v = sp.macro_backtrace();
if let Some(use_site) = v.last() {
return use_site.call_site;
}
}
sp
}
}
#[derive(Clone)]