Compute proc_macros in resolutions.
This commit is contained in:
parent
635978041d
commit
f8efe5d822
12 changed files with 52 additions and 54 deletions
|
@ -502,13 +502,6 @@ pub struct Crate {
|
|||
pub attrs: Vec<Attribute>,
|
||||
pub items: Vec<P<Item>>,
|
||||
pub span: Span,
|
||||
/// The order of items in the HIR is unrelated to the order of
|
||||
/// items in the AST. However, we generate proc macro harnesses
|
||||
/// based on the AST order, and later refer to these harnesses
|
||||
/// from the HIR. This field keeps track of the order in which
|
||||
/// we generated proc macros harnesses, so that we can map
|
||||
/// HIR proc macros items back to their harness items.
|
||||
pub proc_macros: Vec<NodeId>,
|
||||
}
|
||||
|
||||
/// Possible values inside of compile-time attribute lists.
|
||||
|
|
|
@ -1059,7 +1059,7 @@ pub fn noop_visit_fn_header<T: MutVisitor>(header: &mut FnHeader, vis: &mut T) {
|
|||
// FIXME: Avoid visiting the crate as a `Mod` item, flat map only the inner items if possible,
|
||||
// or make crate visiting first class if necessary.
|
||||
pub fn noop_visit_crate<T: MutVisitor>(krate: &mut Crate, vis: &mut T) {
|
||||
visit_clobber(krate, |Crate { attrs, items, span, proc_macros }| {
|
||||
visit_clobber(krate, |Crate { attrs, items, span }| {
|
||||
let item_vis =
|
||||
Visibility { kind: VisibilityKind::Public, span: span.shrink_to_lo(), tokens: None };
|
||||
let item = P(Item {
|
||||
|
@ -1075,13 +1075,11 @@ pub fn noop_visit_crate<T: MutVisitor>(krate: &mut Crate, vis: &mut T) {
|
|||
|
||||
let len = items.len();
|
||||
if len == 0 {
|
||||
Crate { attrs: vec![], items: vec![], span, proc_macros }
|
||||
Crate { attrs: vec![], items: vec![], span }
|
||||
} else if len == 1 {
|
||||
let Item { attrs, span, kind, .. } = items.into_iter().next().unwrap().into_inner();
|
||||
match kind {
|
||||
ItemKind::Mod(_, ModKind::Loaded(items, ..)) => {
|
||||
Crate { attrs, items, span, proc_macros }
|
||||
}
|
||||
ItemKind::Mod(_, ModKind::Loaded(items, ..)) => Crate { attrs, items, span },
|
||||
_ => panic!("visitor converted a module to not a module"),
|
||||
}
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue