diff options
| author | Camille GILLOT <gillot.camille@gmail.com> | 2021-06-28 19:29:55 +0200 |
|---|---|---|
| committer | Camille GILLOT <gillot.camille@gmail.com> | 2021-07-06 08:07:06 +0200 |
| commit | 3162c37b59009f17d92aeb8affc64d33c2d34acb (patch) | |
| tree | 34336a113e2526cabd3780c9360afadde7cd1b55 /compiler/rustc_middle | |
| parent | 969a6c2481c41cea793708f7fdd2f96a3397143f (diff) | |
| download | rust-3162c37b59009f17d92aeb8affc64d33c2d34acb.tar.gz rust-3162c37b59009f17d92aeb8affc64d33c2d34acb.zip | |
Store macro parent module in ExpnData.
Diffstat (limited to 'compiler/rustc_middle')
| -rw-r--r-- | compiler/rustc_middle/src/ty/mod.rs | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/compiler/rustc_middle/src/ty/mod.rs b/compiler/rustc_middle/src/ty/mod.rs index f9dad42a4b7..156e860e1a3 100644 --- a/compiler/rustc_middle/src/ty/mod.rs +++ b/compiler/rustc_middle/src/ty/mod.rs @@ -1902,13 +1902,11 @@ impl<'tcx> TyCtxt<'tcx> { scope: DefId, block: hir::HirId, ) -> (Ident, DefId) { - let scope = - match ident.span.normalize_to_macros_2_0_and_adjust(self.expn_that_defined(scope)) { - Some(actual_expansion) => { - self.hir().definitions().parent_module_of_macro_def(actual_expansion) - } - None => self.parent_module(block).to_def_id(), - }; + let scope = ident + .span + .normalize_to_macros_2_0_and_adjust(self.expn_that_defined(scope)) + .and_then(|actual_expansion| actual_expansion.expn_data().parent_module) + .unwrap_or_else(|| self.parent_module(block).to_def_id()); (ident, scope) } |
