diff options
| author | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2019-08-11 03:00:05 +0300 |
|---|---|---|
| committer | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2019-08-15 20:39:27 +0300 |
| commit | 73dee258c19a6e9e8249a0d7ff1db54014d0c7a1 (patch) | |
| tree | c8d742151c2b460235059195250a8fb27ef170d0 /src/libsyntax/ext/base.rs | |
| parent | 6cb28b6617e25b74389f1cee2ec0335c2ccfb865 (diff) | |
| download | rust-73dee258c19a6e9e8249a0d7ff1db54014d0c7a1.tar.gz rust-73dee258c19a6e9e8249a0d7ff1db54014d0c7a1.zip | |
hygiene: Remove `Option`s from functions returning `ExpnInfo`
The expansion info is not optional and should always exist
Diffstat (limited to 'src/libsyntax/ext/base.rs')
| -rw-r--r-- | src/libsyntax/ext/base.rs | 21 |
1 files changed, 7 insertions, 14 deletions
diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index fd6b9138fde..8eacb96e3ff 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -756,10 +756,7 @@ impl<'a> ExtCtxt<'a> { pub fn parse_sess(&self) -> &'a parse::ParseSess { self.parse_sess } pub fn cfg(&self) -> &ast::CrateConfig { &self.parse_sess.config } pub fn call_site(&self) -> Span { - match self.current_expansion.id.expn_info() { - Some(expn_info) => expn_info.call_site, - None => DUMMY_SP, - } + self.current_expansion.id.expn_info().call_site } pub fn backtrace(&self) -> SyntaxContext { SyntaxContext::root().apply_mark(self.current_expansion.id) @@ -772,17 +769,13 @@ impl<'a> ExtCtxt<'a> { let mut ctxt = self.backtrace(); let mut last_macro = None; loop { - if ctxt.outer_expn_info().map_or(None, |info| { - if info.kind.descr() == sym::include { - // Stop going up the backtrace once include! is encountered - return None; - } - ctxt = info.call_site.ctxt(); - last_macro = Some(info.call_site); - Some(()) - }).is_none() { - break + let expn_info = ctxt.outer_expn_info(); + // Stop going up the backtrace once include! is encountered + if expn_info.is_root() || expn_info.kind.descr() == sym::include { + break; } + ctxt = expn_info.call_site.ctxt(); + last_macro = Some(expn_info.call_site); } last_macro } |
