expand: Unimplement MutVisitor on MacroExpander

Each call to `fully_expand_fragment` is something unique, interesting, and requiring attention.
It represents a "root" of expansion and its use means that something unusual is happening, like eager expansion or expansion performed outside of the primary expansion pass.
So, it shouldn't be hide under a generic visitor call.

Also, from all the implemented visitor methods only two were actually used.
This commit is contained in:
Vadim Petrochenkov 2019-08-14 02:30:09 +03:00
parent 0d29142aad
commit d416ebeb6e
4 changed files with 31 additions and 33 deletions

View file

@ -1,18 +1,17 @@
use std::mem;
use smallvec::smallvec;
use syntax::ast::{self, Ident};
use syntax::attr;
use syntax::source_map::{ExpnInfo, ExpnKind, respan};
use syntax::ext::base::{ExtCtxt, MacroKind};
use syntax::ext::expand::ExpansionConfig;
use syntax::ext::expand::{AstFragment, ExpansionConfig};
use syntax::ext::hygiene::ExpnId;
use syntax::ext::proc_macro::is_proc_macro_attr;
use syntax::mut_visit::MutVisitor;
use syntax::parse::ParseSess;
use syntax::ptr::P;
use syntax::symbol::{kw, sym};
use syntax::visit::{self, Visitor};
use syntax_pos::{Span, DUMMY_SP};
struct ProcMacroDerive {
@ -409,5 +408,7 @@ fn mk_decls(
i
});
cx.monotonic_expander().flat_map_item(module).pop().unwrap()
// Integrate the new module into existing module structures.
let module = AstFragment::Items(smallvec![module]);
cx.monotonic_expander().fully_expand_fragment(module).make_items().pop().unwrap()
}