Auto merge of #61253 - nnethercote:avoid-hygiene_data-lookups, r=petrochenkov

Avoid `hygiene_data` lookups

These commits mostly introduce compound operations that allow two close adjacent `hygiene_data` lookups to be combined.

r? @petrochenkov
This commit is contained in:
bors 2019-05-30 16:54:13 +00:00
commit 0bfbaa6e8d
21 changed files with 100 additions and 62 deletions

View file

@ -30,8 +30,8 @@ use errors::SourceMapper;
/// otherwise return the call site span up to the `enclosing_sp` by
/// following the `expn_info` chain.
pub fn original_sp(sp: Span, enclosing_sp: Span) -> Span {
let call_site1 = sp.ctxt().outer().expn_info().map(|ei| ei.call_site);
let call_site2 = enclosing_sp.ctxt().outer().expn_info().map(|ei| ei.call_site);
let call_site1 = sp.ctxt().outer_expn_info().map(|ei| ei.call_site);
let call_site2 = enclosing_sp.ctxt().outer_expn_info().map(|ei| ei.call_site);
match (call_site1, call_site2) {
(None, _) => sp,
(Some(call_site1), Some(call_site2)) if call_site1 == call_site2 => sp,