Introduce and use SyntaxContext::outer_expn_info().

It reduces two `hygiene_data` accesses to one on some hot paths.
This commit is contained in:
Nicholas Nethercote 2019-05-27 13:52:11 +10:00
parent 828f6fdbe5
commit caea42f6c8
15 changed files with 39 additions and 30 deletions

View file

@ -762,7 +762,7 @@ impl<'tcx> Visitor<'tcx> for UsePlacementFinder {
ItemKind::Use(..) => {
// don't suggest placing a use before the prelude
// import or other generated ones
if item.span.ctxt().outer().expn_info().is_none() {
if item.span.ctxt().outer_expn_info().is_none() {
self.span = Some(item.span.shrink_to_lo());
self.found_use = true;
return;
@ -772,7 +772,7 @@ impl<'tcx> Visitor<'tcx> for UsePlacementFinder {
ItemKind::ExternCrate(_) => {}
// but place them before the first other item
_ => if self.span.map_or(true, |span| item.span < span ) {
if item.span.ctxt().outer().expn_info().is_none() {
if item.span.ctxt().outer_expn_info().is_none() {
// don't insert between attributes and an item
if item.attrs.is_empty() {
self.span = Some(item.span.shrink_to_lo());

View file

@ -413,7 +413,7 @@ impl<'a> Resolver<'a> {
// Possibly apply the macro helper hack
if kind == MacroKind::Bang && path.len() == 1 &&
path[0].ident.span.ctxt().outer().expn_info()
path[0].ident.span.ctxt().outer_expn_info()
.map_or(false, |info| info.local_inner_macros) {
let root = Ident::new(kw::DollarCrate, path[0].ident.span);
path.insert(0, Segment::from_ident(root));