1
Fork 0

Make ExpnData fields krate and orig_id private

These fields are only used by hygiene serialized, and should not be
accessed by anything outside of `rustc_span`.
This commit is contained in:
Aaron Hill 2021-01-03 08:56:49 -05:00
parent 18cb4ad3b9
commit 21b8f2ecde
No known key found for this signature in database
GPG key ID: B4087E510E98B164
5 changed files with 63 additions and 27 deletions

View file

@ -12,7 +12,7 @@ use rustc_data_structures::sync::{self, Lrc};
use rustc_errors::{DiagnosticBuilder, ErrorReported};
use rustc_parse::{self, nt_to_tokenstream, parser, MACRO_ARGUMENTS};
use rustc_session::{parse::ParseSess, Limit, Session};
use rustc_span::def_id::{DefId, LOCAL_CRATE};
use rustc_span::def_id::DefId;
use rustc_span::edition::Edition;
use rustc_span::hygiene::{AstPass, ExpnData, ExpnId, ExpnKind};
use rustc_span::source_map::SourceMap;
@ -842,19 +842,17 @@ impl SyntaxExtension {
descr: Symbol,
macro_def_id: Option<DefId>,
) -> ExpnData {
ExpnData {
kind: ExpnKind::Macro(self.macro_kind(), descr),
ExpnData::new(
ExpnKind::Macro(self.macro_kind(), descr),
parent,
call_site,
def_site: self.span,
allow_internal_unstable: self.allow_internal_unstable.clone(),
allow_internal_unsafe: self.allow_internal_unsafe,
local_inner_macros: self.local_inner_macros,
edition: self.edition,
self.span,
self.allow_internal_unstable.clone(),
self.allow_internal_unsafe,
self.local_inner_macros,
self.edition,
macro_def_id,
krate: LOCAL_CRATE,
orig_id: None,
}
)
}
}

View file

@ -1020,15 +1020,16 @@ impl<'a, 'b> InvocationCollector<'a, 'b> {
// with exception of the derive container case which is not resolved and can get
// its expansion data immediately.
let expn_data = match &kind {
InvocationKind::DeriveContainer { item, .. } => Some(ExpnData {
parent: self.cx.current_expansion.id,
..ExpnData::default(
InvocationKind::DeriveContainer { item, .. } => {
let mut expn_data = ExpnData::default(
ExpnKind::Macro(MacroKind::Attr, sym::derive),
item.span(),
self.cx.sess.parse_sess.edition,
None,
)
}),
);
expn_data.parent = self.cx.current_expansion.id;
Some(expn_data)
}
_ => None,
};
let expn_id = ExpnId::fresh(expn_data);