From 51a16e574aa1b20dbaa94436065ce80f3ba725d1 Mon Sep 17 00:00:00 2001 From: Aaron Hill Date: Mon, 3 Feb 2020 18:34:36 -0500 Subject: Record proc macro harness order for use during metadata deserialization Fixes #68690 When we generate the proc macro harness, we now explicitly recorder the order in which we generate entries. We then use this ordering data to deserialize the correct proc-macro-data from the crate metadata. --- src/libsyntax/ast.rs | 1 + src/libsyntax/mut_visit.rs | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'src/libsyntax') diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 72430fa9c17..1973733288b 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -429,6 +429,7 @@ pub struct Crate { pub module: Mod, pub attrs: Vec, pub span: Span, + pub proc_macros: Vec, } /// Possible values inside of compile-time attribute lists. diff --git a/src/libsyntax/mut_visit.rs b/src/libsyntax/mut_visit.rs index e0180d45193..f130b0a2ee4 100644 --- a/src/libsyntax/mut_visit.rs +++ b/src/libsyntax/mut_visit.rs @@ -989,7 +989,7 @@ pub fn noop_visit_mod(Mod { inner, items, inline: _ }: &mut Mod, } pub fn noop_visit_crate(krate: &mut Crate, vis: &mut T) { - visit_clobber(krate, |Crate { module, attrs, span }| { + visit_clobber(krate, |Crate { module, attrs, span, proc_macros }| { let item = P(Item { ident: Ident::invalid(), attrs, @@ -1004,11 +1004,11 @@ pub fn noop_visit_crate(krate: &mut Crate, vis: &mut T) { let len = items.len(); if len == 0 { let module = Mod { inner: span, items: vec![], inline: true }; - Crate { module, attrs: vec![], span } + Crate { module, attrs: vec![], span, proc_macros } } else if len == 1 { let Item { attrs, span, kind, .. } = items.into_iter().next().unwrap().into_inner(); match kind { - ItemKind::Mod(module) => Crate { module, attrs, span }, + ItemKind::Mod(module) => Crate { module, attrs, span, proc_macros }, _ => panic!("visitor converted a module to not a module"), } } else { -- cgit 1.4.1-3-g733a5