about summary refs log tree commit diff
path: root/src/librustc_errors
diff options
context:
space:
mode:
authorEsteban Küber <esteban@kuber.com.ar>2017-05-31 23:48:19 -0700
committerEsteban Küber <esteban@kuber.com.ar>2017-05-31 23:48:19 -0700
commit4142d7bb890b631bae5d7872dce3e1c1a6816e9f (patch)
treef72b559e7103bc886e7a036bb4a1806f2611aaf8 /src/librustc_errors
parent4ed2edaafe82fb8d44e81e00ca3e4f7659855ba2 (diff)
downloadrust-4142d7bb890b631bae5d7872dce3e1c1a6816e9f.tar.gz
rust-4142d7bb890b631bae5d7872dce3e1c1a6816e9f.zip
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.
Diffstat (limited to 'src/librustc_errors')
-rw-r--r--src/librustc_errors/emitter.rs8
-rw-r--r--src/librustc_errors/lib.rs1
2 files changed, 4 insertions, 5 deletions
diff --git a/src/librustc_errors/emitter.rs b/src/librustc_errors/emitter.rs
index a9645f9ab7b..f820ea4c5e1 100644
--- a/src/librustc_errors/emitter.rs
+++ b/src/librustc_errors/emitter.rs
@@ -705,11 +705,9 @@ impl EmitterWriter {
                 if *sp == DUMMY_SP {
                     continue;
                 }
-                if cm.span_to_filename(sp.clone()).contains("macros>") {
-                    let v = sp.macro_backtrace();
-                    if let Some(use_site) = v.last() {
-                        before_after.push((sp.clone(), use_site.call_site.clone()));
-                    }
+                let call_sp = cm.call_span_if_macro(*sp);
+                if call_sp != *sp {
+                    before_after.push((sp.clone(), call_sp));
                 }
                 for trace in sp.macro_backtrace().iter().rev() {
                     // Only show macro locations that are local
diff --git a/src/librustc_errors/lib.rs b/src/librustc_errors/lib.rs
index d1aaaf4ba7b..8d5e9e776ed 100644
--- a/src/librustc_errors/lib.rs
+++ b/src/librustc_errors/lib.rs
@@ -102,6 +102,7 @@ pub trait CodeMapper {
     fn span_to_string(&self, sp: Span) -> String;
     fn span_to_filename(&self, sp: Span) -> FileName;
     fn merge_spans(&self, sp_lhs: Span, sp_rhs: Span) -> Option<Span>;
+    fn call_span_if_macro(&self, sp: Span) -> Span;
 }
 
 impl CodeSuggestion {