diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2019-08-16 08:26:36 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-08-16 08:26:36 +0200 |
| commit | 6e9e6ea39bbc2c9e58cdc854c55dfc1487a77ae1 (patch) | |
| tree | 3f954fcac1528b39e95ca78bc3ebad58a30613e0 /src/libsyntax/source_map.rs | |
| parent | 32c10056525d427292fdb5e7db7497e2bbe9551b (diff) | |
| parent | c76277340e3e5e8d6aca9c926c45cac3484eb5f8 (diff) | |
| download | rust-6e9e6ea39bbc2c9e58cdc854c55dfc1487a77ae1.tar.gz rust-6e9e6ea39bbc2c9e58cdc854c55dfc1487a77ae1.zip | |
Rollup merge of #63535 - petrochenkov:expndata, r=matthewjasper
Continue refactoring resolve and hygiene The general goal is addressing FIXMEs from the previous PRs. Merging similar data structures (+ prerequisites for such merging), accounting for the fact that all `ExpnId`s have associated data in `HygieneData` now (less `Option`s). Also, some renaming. This should be the last renaming session in this area, I think. r? @matthewjasper
Diffstat (limited to 'src/libsyntax/source_map.rs')
| -rw-r--r-- | src/libsyntax/source_map.rs | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/libsyntax/source_map.rs b/src/libsyntax/source_map.rs index 74cab00d3c1..940687cb5d4 100644 --- a/src/libsyntax/source_map.rs +++ b/src/libsyntax/source_map.rs @@ -8,7 +8,7 @@ //! information, source code snippets, etc. pub use syntax_pos::*; -pub use syntax_pos::hygiene::{ExpnKind, ExpnInfo}; +pub use syntax_pos::hygiene::{ExpnKind, ExpnData}; use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::stable_hasher::StableHasher; @@ -29,14 +29,15 @@ mod tests; /// Returns the span itself if it doesn't come from a macro expansion, /// otherwise return the call site span up to the `enclosing_sp` by -/// following the `expn_info` chain. +/// following the `expn_data` 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); - match (call_site1, call_site2) { - (None, _) => sp, - (Some(call_site1), Some(call_site2)) if call_site1 == call_site2 => sp, - (Some(call_site1), _) => original_sp(call_site1, enclosing_sp), + let expn_data1 = sp.ctxt().outer_expn_data(); + let expn_data2 = enclosing_sp.ctxt().outer_expn_data(); + if expn_data1.is_root() || + !expn_data2.is_root() && expn_data1.call_site == expn_data2.call_site { + sp + } else { + original_sp(expn_data1.call_site, enclosing_sp) } } |
