diff options
| author | bors <bors@rust-lang.org> | 2017-08-01 03:52:14 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2017-08-01 03:52:14 +0000 |
| commit | df90a546624c965fb2f859ed665049dbf824f40a (patch) | |
| tree | ad03779a87d7a44db1dadb6bcba7b4fdf700b015 /src/libsyntax_ext | |
| parent | ebf74d99b0bc25b5a4e35b0a2865580224ed0ef8 (diff) | |
| parent | 27b9182d5bc07d87a34c3a1ffda99d54ca2fec69 (diff) | |
| download | rust-df90a546624c965fb2f859ed665049dbf824f40a.tar.gz rust-df90a546624c965fb2f859ed665049dbf824f40a.zip | |
Auto merge of #43533 - nrc:macro-save, r=jseyfried,
Three small fixes for save-analysis
First commit does some naive deduplication of macro uses. We end up with lots of duplication here because of the weird way we get this data (we extract a use for every span generated by a macro use).
Second commit is basically a typo fix.
Third commit is a bit interesting, it partially reverts a change from #40939 where temporary variables in format! (and thus println!) got a span with the primary pointing at the value stored into the temporary (e.g., `x` in `println!("...", x)`). If `format!` had a definition it should point at the temporary in the macro def, but since it is built-in, that is not possible (for now), so `DUMMY_SP` is the best we can do (using the span in the callee really breaks save-analysis because it thinks `x` is a definition as well as a reference).
There aren't a test for this stuff because: the deduplication is filtered by any of the users of save-analysis, so it is purely an efficiency change. I couldn't actually find an example for the second commit that we have any machinery to test, and the third commit is tested by the RLS, so there will be a test once I update the RLS version and and uncomment the previously failing tests).
r? @jseyfried
Diffstat (limited to 'src/libsyntax_ext')
| -rw-r--r-- | src/libsyntax_ext/format.rs | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/libsyntax_ext/format.rs b/src/libsyntax_ext/format.rs index 7351377e771..9734bb867f1 100644 --- a/src/libsyntax_ext/format.rs +++ b/src/libsyntax_ext/format.rs @@ -20,7 +20,7 @@ use syntax::ext::build::AstBuilder; use syntax::parse::token; use syntax::ptr::P; use syntax::symbol::{Symbol, keywords}; -use syntax_pos::Span; +use syntax_pos::{Span, DUMMY_SP}; use syntax::tokenstream; use std::collections::{HashMap, HashSet}; @@ -558,8 +558,10 @@ impl<'a, 'b> Context<'a, 'b> { // passed to this function. for (i, e) in self.args.into_iter().enumerate() { let name = self.ecx.ident_of(&format!("__arg{}", i)); - let span = - Span { ctxt: e.span.ctxt.apply_mark(self.ecx.current_expansion.mark), ..e.span }; + let span = Span { + ctxt: e.span.ctxt.apply_mark(self.ecx.current_expansion.mark), + ..DUMMY_SP + }; pats.push(self.ecx.pat_ident(span, name)); for ref arg_ty in self.arg_unique_types[i].iter() { locals.push(Context::format_arg(self.ecx, self.macsp, e.span, arg_ty, name)); |
