1
Fork 0

Compute proc_macros in resolutions.

This commit is contained in:
Camille GILLOT 2021-07-16 22:22:08 +02:00
parent 635978041d
commit f8efe5d822
12 changed files with 52 additions and 54 deletions

View file

@ -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,
}
}

View file

@ -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> {