diff options
| author | Camille GILLOT <gillot.camille@gmail.com> | 2021-07-16 22:22:08 +0200 |
|---|---|---|
| committer | Camille GILLOT <gillot.camille@gmail.com> | 2021-09-01 20:13:16 +0200 |
| commit | f8efe5d8222db70964f46b6523be81d6e7c38e65 (patch) | |
| tree | 7d00e473f9c3e54adf3f0b386423ee999814f0d8 /compiler/rustc_resolve/src | |
| parent | 635978041d3b65cd89cc109a83fc761221b4f1d0 (diff) | |
| download | rust-f8efe5d8222db70964f46b6523be81d6e7c38e65.tar.gz rust-f8efe5d8222db70964f46b6523be81d6e7c38e65.zip | |
Compute proc_macros in resolutions.
Diffstat (limited to 'compiler/rustc_resolve/src')
| -rw-r--r-- | compiler/rustc_resolve/src/lib.rs | 8 | ||||
| -rw-r--r-- | compiler/rustc_resolve/src/macros.rs | 4 |
2 files changed, 12 insertions, 0 deletions
diff --git a/compiler/rustc_resolve/src/lib.rs b/compiler/rustc_resolve/src/lib.rs index 51e0ee0a57f..152d34fd635 100644 --- a/compiler/rustc_resolve/src/lib.rs +++ b/compiler/rustc_resolve/src/lib.rs @@ -1035,6 +1035,9 @@ pub struct Resolver<'a> { main_def: Option<MainDefinition>, trait_impls: BTreeMap<DefId, Vec<LocalDefId>>, + /// A list of proc macro LocalDefIds, written out in the order in which + /// they are declared in the static array generated by proc_macro_harness. + proc_macros: Vec<NodeId>, } /// Nothing really interesting here; it just provides memory for the rest of the crate. @@ -1400,6 +1403,7 @@ impl<'a> Resolver<'a> { item_generics_num_lifetimes: Default::default(), main_def: Default::default(), trait_impls: Default::default(), + proc_macros: Default::default(), }; let root_parent_scope = ParentScope::module(graph_root, &resolver); @@ -1434,6 +1438,7 @@ impl<'a> Resolver<'a> { } pub fn into_outputs(self) -> ResolverOutputs { + let proc_macros = self.proc_macros.iter().map(|id| self.local_def_id(*id)).collect(); let definitions = self.definitions; let visibilities = self.visibilities; let extern_crate_map = self.extern_crate_map; @@ -1458,10 +1463,12 @@ impl<'a> Resolver<'a> { .collect(), main_def, trait_impls: self.trait_impls, + proc_macros, } } pub fn clone_outputs(&self) -> ResolverOutputs { + let proc_macros = self.proc_macros.iter().map(|id| self.local_def_id(*id)).collect(); ResolverOutputs { definitions: self.definitions.clone(), cstore: Box::new(self.cstore().clone()), @@ -1478,6 +1485,7 @@ impl<'a> Resolver<'a> { .collect(), main_def: self.main_def.clone(), trait_impls: self.trait_impls.clone(), + proc_macros, } } diff --git a/compiler/rustc_resolve/src/macros.rs b/compiler/rustc_resolve/src/macros.rs index 7f86f891c44..6dc3aa0888a 100644 --- a/compiler/rustc_resolve/src/macros.rs +++ b/compiler/rustc_resolve/src/macros.rs @@ -466,6 +466,10 @@ impl<'a> ResolverExpand for Resolver<'a> { fn get_proc_macro_quoted_span(&self, krate: CrateNum, id: usize) -> Span { self.crate_loader.cstore().get_proc_macro_quoted_span_untracked(krate, id, self.session) } + + fn declare_proc_macro(&mut self, id: NodeId) { + self.proc_macros.push(id) + } } impl<'a> Resolver<'a> { |
