From 3162c37b59009f17d92aeb8affc64d33c2d34acb Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Mon, 28 Jun 2021 19:29:55 +0200 Subject: Store macro parent module in ExpnData. --- compiler/rustc_span/src/hygiene.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'compiler/rustc_span/src') diff --git a/compiler/rustc_span/src/hygiene.rs b/compiler/rustc_span/src/hygiene.rs index 23efaf6f4f3..913aeeca78b 100644 --- a/compiler/rustc_span/src/hygiene.rs +++ b/compiler/rustc_span/src/hygiene.rs @@ -181,6 +181,7 @@ impl HygieneData { DUMMY_SP, edition, Some(DefId::local(CRATE_DEF_INDEX)), + None, ); root_data.orig_id = Some(0); @@ -687,7 +688,7 @@ impl Span { ) -> Span { self.fresh_expansion(ExpnData { allow_internal_unstable, - ..ExpnData::default(ExpnKind::Desugaring(reason), self, edition, None) + ..ExpnData::default(ExpnKind::Desugaring(reason), self, edition, None, None) }) } } @@ -734,6 +735,8 @@ pub struct ExpnData { /// The `DefId` of the macro being invoked, /// if this `ExpnData` corresponds to a macro invocation pub macro_def_id: Option, + /// The normal module (`mod`) in which the expanded macro was defined. + pub parent_module: Option, /// The crate that originally created this `ExpnData`. During /// metadata serialization, we only encode `ExpnData`s that were /// created locally - when our serialized metadata is decoded, @@ -777,6 +780,7 @@ impl ExpnData { local_inner_macros: bool, edition: Edition, macro_def_id: Option, + parent_module: Option, ) -> ExpnData { ExpnData { kind, @@ -788,6 +792,7 @@ impl ExpnData { local_inner_macros, edition, macro_def_id, + parent_module, krate: LOCAL_CRATE, orig_id: None, disambiguator: 0, @@ -800,6 +805,7 @@ impl ExpnData { call_site: Span, edition: Edition, macro_def_id: Option, + parent_module: Option, ) -> ExpnData { ExpnData { kind, @@ -811,6 +817,7 @@ impl ExpnData { local_inner_macros: false, edition, macro_def_id, + parent_module, krate: LOCAL_CRATE, orig_id: None, disambiguator: 0, @@ -823,10 +830,11 @@ impl ExpnData { edition: Edition, allow_internal_unstable: Lrc<[Symbol]>, macro_def_id: Option, + parent_module: Option, ) -> ExpnData { ExpnData { allow_internal_unstable: Some(allow_internal_unstable), - ..ExpnData::default(kind, call_site, edition, macro_def_id) + ..ExpnData::default(kind, call_site, edition, macro_def_id, parent_module) } } -- cgit 1.4.1-3-g733a5