diff options
| author | Nicholas Nethercote <nnethercote@mozilla.com> | 2019-05-27 13:52:11 +1000 |
|---|---|---|
| committer | Nicholas Nethercote <nnethercote@mozilla.com> | 2019-05-29 09:32:56 +1000 |
| commit | caea42f6c8ba8f5cc5ed04557ec5d072b107e7b4 (patch) | |
| tree | 9ddcc6be16ffaabb4d5dfbd86340c043c2e08f3a /src/librustc_lint | |
| parent | 828f6fdbe57a7b0e6b7bf7194ee9a2079b2779cd (diff) | |
| download | rust-caea42f6c8ba8f5cc5ed04557ec5d072b107e7b4.tar.gz rust-caea42f6c8ba8f5cc5ed04557ec5d072b107e7b4.zip | |
Introduce and use `SyntaxContext::outer_expn_info()`.
It reduces two `hygiene_data` accesses to one on some hot paths.
Diffstat (limited to 'src/librustc_lint')
| -rw-r--r-- | src/librustc_lint/builtin.rs | 4 | ||||
| -rw-r--r-- | src/librustc_lint/unused.rs | 5 |
2 files changed, 4 insertions, 5 deletions
diff --git a/src/librustc_lint/builtin.rs b/src/librustc_lint/builtin.rs index d184c671bba..44b727c6925 100644 --- a/src/librustc_lint/builtin.rs +++ b/src/librustc_lint/builtin.rs @@ -158,7 +158,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonShorthandFieldPatterns { if fieldpat.node.is_shorthand { continue; } - if fieldpat.span.ctxt().outer().expn_info().is_some() { + if fieldpat.span.ctxt().outer_expn_info().is_some() { // Don't lint if this is a macro expansion: macro authors // shouldn't have to worry about this kind of style issue // (Issue #49588) @@ -1003,7 +1003,7 @@ impl UnreachablePub { let mut applicability = Applicability::MachineApplicable; match vis.node { hir::VisibilityKind::Public if !cx.access_levels.is_reachable(id) => { - if span.ctxt().outer().expn_info().is_some() { + if span.ctxt().outer_expn_info().is_some() { applicability = Applicability::MaybeIncorrect; } let def_span = cx.tcx.sess.source_map().def_span(span); diff --git a/src/librustc_lint/unused.rs b/src/librustc_lint/unused.rs index 34f7e04c164..036820c6d7f 100644 --- a/src/librustc_lint/unused.rs +++ b/src/librustc_lint/unused.rs @@ -391,9 +391,8 @@ impl EarlyLintPass for UnusedParens { // trigger in situations that macro authors shouldn't have to care about, e.g., // when a parenthesized token tree matched in one macro expansion is matched as // an expression in another and used as a fn/method argument (Issue #47775) - if e.span.ctxt().outer().expn_info() - .map_or(false, |info| info.call_site.ctxt().outer() - .expn_info().is_some()) { + if e.span.ctxt().outer_expn_info() + .map_or(false, |info| info.call_site.ctxt().outer_expn_info().is_some()) { return; } let msg = format!("{} argument", call_kind); |
