diff options
| author | Esteban Küber <esteban@kuber.com.ar> | 2017-05-31 23:48:19 -0700 |
|---|---|---|
| committer | Esteban Küber <esteban@kuber.com.ar> | 2017-05-31 23:48:19 -0700 |
| commit | 4142d7bb890b631bae5d7872dce3e1c1a6816e9f (patch) | |
| tree | f72b559e7103bc886e7a036bb4a1806f2611aaf8 /src/librustc_errors | |
| parent | 4ed2edaafe82fb8d44e81e00ca3e4f7659855ba2 (diff) | |
| download | rust-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.rs | 8 | ||||
| -rw-r--r-- | src/librustc_errors/lib.rs | 1 |
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 { |
