diff options
| author | Nicholas Nethercote <nnethercote@mozilla.com> | 2019-06-03 09:21:27 +1000 |
|---|---|---|
| committer | Nicholas Nethercote <nnethercote@mozilla.com> | 2019-06-05 07:43:15 +1000 |
| commit | f9209fcd634fd5fc1fc83387af3b16b7cab62b74 (patch) | |
| tree | 50e862392411e828b796b0d962dba3dad21055d4 /src/libsyntax_pos | |
| parent | e19857c4dbbde65803d619011af4415fbdda8c01 (diff) | |
| download | rust-f9209fcd634fd5fc1fc83387af3b16b7cab62b74.tar.gz rust-f9209fcd634fd5fc1fc83387af3b16b7cab62b74.zip | |
Add and use `SyntaxContext::outer_and_expn_info`.
This combines two `HygieneData::with` calls into one on a hot path.
Diffstat (limited to 'src/libsyntax_pos')
| -rw-r--r-- | src/libsyntax_pos/hygiene.rs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/libsyntax_pos/hygiene.rs b/src/libsyntax_pos/hygiene.rs index e50b9da62e7..5691258152a 100644 --- a/src/libsyntax_pos/hygiene.rs +++ b/src/libsyntax_pos/hygiene.rs @@ -565,6 +565,16 @@ impl SyntaxContext { HygieneData::with(|data| data.expn_info(data.outer(self))) } + /// `ctxt.outer_and_expn_info()` is equivalent to but faster than + /// `{ let outer = ctxt.outer(); (outer, outer.expn_info()) }`. + #[inline] + pub fn outer_and_expn_info(self) -> (Mark, Option<ExpnInfo>) { + HygieneData::with(|data| { + let outer = data.outer(self); + (outer, data.expn_info(outer)) + }) + } + pub fn dollar_crate_name(self) -> Symbol { HygieneData::with(|data| data.syntax_contexts[self.0 as usize].dollar_crate_name) } |
