Skip to content

Commit 136db22

Browse files
committed
hygiene: ExpnInfo -> ExpnData
For naming consistency with everything else in this area
1 parent 650f19a commit 136db22

File tree

25 files changed

+168
-168
lines changed

25 files changed

+168
-168
lines changed

src/librustc/hir/lowering.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ use syntax::errors;
6767
use syntax::ext::base::SpecialDerives;
6868
use syntax::ext::hygiene::ExpnId;
6969
use syntax::print::pprust;
70-
use syntax::source_map::{respan, ExpnInfo, ExpnKind, DesugaringKind, Spanned};
70+
use syntax::source_map::{respan, ExpnData, ExpnKind, DesugaringKind, Spanned};
7171
use syntax::symbol::{kw, sym, Symbol};
7272
use syntax::tokenstream::{TokenStream, TokenTree};
7373
use syntax::parse::token::{self, Token};
@@ -704,9 +704,9 @@ impl<'a> LoweringContext<'a> {
704704
span: Span,
705705
allow_internal_unstable: Option<Lrc<[Symbol]>>,
706706
) -> Span {
707-
span.fresh_expansion(ExpnInfo {
707+
span.fresh_expansion(ExpnData {
708708
allow_internal_unstable,
709-
..ExpnInfo::default(ExpnKind::Desugaring(reason), span, self.sess.edition())
709+
..ExpnData::default(ExpnKind::Desugaring(reason), span, self.sess.edition())
710710
})
711711
}
712712

src/librustc/ich/hcx.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ impl<'a> HashStable<StableHashingContext<'a>> for Span {
370370
}
371371

372372
let mut hasher = StableHasher::new();
373-
expn_id.expn_info().hash_stable(hcx, &mut hasher);
373+
expn_id.expn_data().hash_stable(hcx, &mut hasher);
374374
let sub_hash: Fingerprint = hasher.finish();
375375
let sub_hash = sub_hash.to_smaller_hash();
376376
cache.borrow_mut().insert(expn_id, sub_hash);

src/librustc/ich/impls_syntax.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ impl_stable_hash_for!(enum ::syntax_pos::hygiene::Transparency {
397397
Opaque,
398398
});
399399

400-
impl_stable_hash_for!(struct ::syntax_pos::hygiene::ExpnInfo {
400+
impl_stable_hash_for!(struct ::syntax_pos::hygiene::ExpnData {
401401
kind,
402402
parent -> _,
403403
call_site,

src/librustc/lint/internal.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -227,10 +227,10 @@ impl EarlyLintPass for LintPassImpl {
227227
if let ItemKind::Impl(_, _, _, _, Some(lint_pass), _, _) = &item.node {
228228
if let Some(last) = lint_pass.path.segments.last() {
229229
if last.ident.name == sym::LintPass {
230-
let expn_info = lint_pass.path.span.ctxt().outer_expn_info();
231-
let call_site = expn_info.call_site;
232-
if expn_info.kind.descr() != sym::impl_lint_pass &&
233-
call_site.ctxt().outer_expn_info().kind.descr() != sym::declare_lint_pass {
230+
let expn_data = lint_pass.path.span.ctxt().outer_expn_data();
231+
let call_site = expn_data.call_site;
232+
if expn_data.kind.descr() != sym::impl_lint_pass &&
233+
call_site.ctxt().outer_expn_data().kind.descr() != sym::declare_lint_pass {
234234
cx.struct_span_lint(
235235
LINT_PASS_IMPL_WITHOUT_MACRO,
236236
lint_pass.path.span,

src/librustc/lint/mod.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -885,16 +885,16 @@ pub fn provide(providers: &mut Providers<'_>) {
885885
/// This is used to test whether a lint should not even begin to figure out whether it should
886886
/// be reported on the current node.
887887
pub fn in_external_macro(sess: &Session, span: Span) -> bool {
888-
let expn_info = span.ctxt().outer_expn_info();
889-
match expn_info.kind {
888+
let expn_data = span.ctxt().outer_expn_data();
889+
match expn_data.kind {
890890
ExpnKind::Root | ExpnKind::Desugaring(DesugaringKind::ForLoop) => false,
891891
ExpnKind::Desugaring(_) => true, // well, it's "external"
892892
ExpnKind::Macro(MacroKind::Bang, _) => {
893-
if expn_info.def_site.is_dummy() {
893+
if expn_data.def_site.is_dummy() {
894894
// dummy span for the def_site means it's an external macro
895895
return true;
896896
}
897-
match sess.source_map().span_to_snippet(expn_info.def_site) {
897+
match sess.source_map().span_to_snippet(expn_data.def_site) {
898898
Ok(code) => !code.starts_with("macro_rules"),
899899
// no snippet = external macro or compiler-builtin expansion
900900
Err(_) => true,
@@ -906,7 +906,7 @@ pub fn in_external_macro(sess: &Session, span: Span) -> bool {
906906

907907
/// Returns whether `span` originates in a derive macro's expansion
908908
pub fn in_derive_expansion(span: Span) -> bool {
909-
if let ExpnKind::Macro(MacroKind::Derive, _) = span.ctxt().outer_expn_info().kind {
909+
if let ExpnKind::Macro(MacroKind::Derive, _) = span.ctxt().outer_expn_data().kind {
910910
return true;
911911
}
912912
false

src/librustc/traits/error_reporting.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
6161
// We want to ignore desugarings here: spans are equivalent even
6262
// if one is the result of a desugaring and the other is not.
6363
let mut span = error.obligation.cause.span;
64-
let expn_info = span.ctxt().outer_expn_info();
65-
if let ExpnKind::Desugaring(_) = expn_info.kind {
66-
span = expn_info.call_site;
64+
let expn_data = span.ctxt().outer_expn_data();
65+
if let ExpnKind::Desugaring(_) = expn_data.kind {
66+
span = expn_data.call_site;
6767
}
6868

6969
error_map.entry(span).or_default().push(

src/librustc/ty/query/on_disk_cache.rs

+34-34
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,16 @@ use std::mem;
2323
use syntax::ast::NodeId;
2424
use syntax::source_map::{SourceMap, StableSourceFileId};
2525
use syntax_pos::{BytePos, Span, DUMMY_SP, SourceFile};
26-
use syntax_pos::hygiene::{ExpnId, SyntaxContext, ExpnInfo};
26+
use syntax_pos::hygiene::{ExpnId, SyntaxContext, ExpnData};
2727

2828
const TAG_FILE_FOOTER: u128 = 0xC0FFEE_C0FFEE_C0FFEE_C0FFEE_C0FFEE;
2929

3030
const TAG_CLEAR_CROSS_CRATE_CLEAR: u8 = 0;
3131
const TAG_CLEAR_CROSS_CRATE_SET: u8 = 1;
3232

33-
const TAG_NO_EXPANSION_INFO: u8 = 0;
34-
const TAG_EXPANSION_INFO_SHORTHAND: u8 = 1;
35-
const TAG_EXPANSION_INFO_INLINE: u8 = 2;
33+
const TAG_NO_EXPN_DATA: u8 = 0;
34+
const TAG_EXPN_DATA_SHORTHAND: u8 = 1;
35+
const TAG_EXPN_DATA_INLINE: u8 = 2;
3636

3737
const TAG_VALID_SPAN: u8 = 0;
3838
const TAG_INVALID_SPAN: u8 = 1;
@@ -58,7 +58,7 @@ pub struct OnDiskCache<'sess> {
5858

5959
// These two fields caches that are populated lazily during decoding.
6060
file_index_to_file: Lock<FxHashMap<SourceFileIndex, Lrc<SourceFile>>>,
61-
synthetic_expansion_infos: Lock<FxHashMap<AbsoluteBytePos, SyntaxContext>>,
61+
synthetic_syntax_contexts: Lock<FxHashMap<AbsoluteBytePos, SyntaxContext>>,
6262

6363
// A map from dep-node to the position of the cached query result in
6464
// `serialized_data`.
@@ -135,7 +135,7 @@ impl<'sess> OnDiskCache<'sess> {
135135
current_diagnostics: Default::default(),
136136
query_result_index: footer.query_result_index.into_iter().collect(),
137137
prev_diagnostics_index: footer.diagnostics_index.into_iter().collect(),
138-
synthetic_expansion_infos: Default::default(),
138+
synthetic_syntax_contexts: Default::default(),
139139
alloc_decoding_state: AllocDecodingState::new(footer.interpret_alloc_index),
140140
}
141141
}
@@ -151,7 +151,7 @@ impl<'sess> OnDiskCache<'sess> {
151151
current_diagnostics: Default::default(),
152152
query_result_index: Default::default(),
153153
prev_diagnostics_index: Default::default(),
154-
synthetic_expansion_infos: Default::default(),
154+
synthetic_syntax_contexts: Default::default(),
155155
alloc_decoding_state: AllocDecodingState::new(Vec::new()),
156156
}
157157
}
@@ -185,7 +185,7 @@ impl<'sess> OnDiskCache<'sess> {
185185
encoder,
186186
type_shorthands: Default::default(),
187187
predicate_shorthands: Default::default(),
188-
expn_info_shorthands: Default::default(),
188+
expn_data_shorthands: Default::default(),
189189
interpret_allocs: Default::default(),
190190
interpret_allocs_inverse: Vec::new(),
191191
source_map: CachingSourceMapView::new(tcx.sess.source_map()),
@@ -383,7 +383,7 @@ impl<'sess> OnDiskCache<'sess> {
383383
cnum_map: self.cnum_map.get(),
384384
file_index_to_file: &self.file_index_to_file,
385385
file_index_to_stable_id: &self.file_index_to_stable_id,
386-
synthetic_expansion_infos: &self.synthetic_expansion_infos,
386+
synthetic_syntax_contexts: &self.synthetic_syntax_contexts,
387387
alloc_decoding_session: self.alloc_decoding_state.new_decoding_session(),
388388
};
389389

@@ -440,7 +440,7 @@ struct CacheDecoder<'a, 'tcx> {
440440
opaque: opaque::Decoder<'a>,
441441
source_map: &'a SourceMap,
442442
cnum_map: &'a IndexVec<CrateNum, Option<CrateNum>>,
443-
synthetic_expansion_infos: &'a Lock<FxHashMap<AbsoluteBytePos, SyntaxContext>>,
443+
synthetic_syntax_contexts: &'a Lock<FxHashMap<AbsoluteBytePos, SyntaxContext>>,
444444
file_index_to_file: &'a Lock<FxHashMap<SourceFileIndex, Lrc<SourceFile>>>,
445445
file_index_to_stable_id: &'a FxHashMap<SourceFileIndex, StableSourceFileId>,
446446
alloc_decoding_session: AllocDecodingSession<'a>,
@@ -586,37 +586,37 @@ impl<'a, 'tcx> SpecializedDecoder<Span> for CacheDecoder<'a, 'tcx> {
586586
let lo = file_lo.lines[line_lo - 1] + col_lo;
587587
let hi = lo + len;
588588

589-
let expn_info_tag = u8::decode(self)?;
589+
let expn_data_tag = u8::decode(self)?;
590590

591-
// FIXME(mw): This method does not restore `ExpnInfo::parent` or
591+
// FIXME(mw): This method does not restore `ExpnData::parent` or
592592
// `SyntaxContextData::prev_ctxt` or `SyntaxContextData::opaque`. These things
593593
// don't seem to be used after HIR lowering, so everything should be fine
594594
// as long as incremental compilation does not kick in before that.
595595
let location = || Span::with_root_ctxt(lo, hi);
596-
let recover_from_expn_info = |this: &Self, expn_info, pos| {
597-
let span = location().fresh_expansion(expn_info);
598-
this.synthetic_expansion_infos.borrow_mut().insert(pos, span.ctxt());
596+
let recover_from_expn_data = |this: &Self, expn_data, pos| {
597+
let span = location().fresh_expansion(expn_data);
598+
this.synthetic_syntax_contexts.borrow_mut().insert(pos, span.ctxt());
599599
span
600600
};
601-
Ok(match expn_info_tag {
602-
TAG_NO_EXPANSION_INFO => {
601+
Ok(match expn_data_tag {
602+
TAG_NO_EXPN_DATA => {
603603
location()
604604
}
605-
TAG_EXPANSION_INFO_INLINE => {
606-
let expn_info = Decodable::decode(self)?;
607-
recover_from_expn_info(
608-
self, expn_info, AbsoluteBytePos::new(self.opaque.position())
605+
TAG_EXPN_DATA_INLINE => {
606+
let expn_data = Decodable::decode(self)?;
607+
recover_from_expn_data(
608+
self, expn_data, AbsoluteBytePos::new(self.opaque.position())
609609
)
610610
}
611-
TAG_EXPANSION_INFO_SHORTHAND => {
611+
TAG_EXPN_DATA_SHORTHAND => {
612612
let pos = AbsoluteBytePos::decode(self)?;
613-
let cached_ctxt = self.synthetic_expansion_infos.borrow().get(&pos).cloned();
613+
let cached_ctxt = self.synthetic_syntax_contexts.borrow().get(&pos).cloned();
614614
if let Some(ctxt) = cached_ctxt {
615615
Span::new(lo, hi, ctxt)
616616
} else {
617-
let expn_info =
618-
self.with_position(pos.to_usize(), |this| ExpnInfo::decode(this))?;
619-
recover_from_expn_info(self, expn_info, pos)
617+
let expn_data =
618+
self.with_position(pos.to_usize(), |this| ExpnData::decode(this))?;
619+
recover_from_expn_data(self, expn_data, pos)
620620
}
621621
}
622622
_ => {
@@ -725,7 +725,7 @@ struct CacheEncoder<'a, 'tcx, E: ty_codec::TyEncoder> {
725725
encoder: &'a mut E,
726726
type_shorthands: FxHashMap<Ty<'tcx>, usize>,
727727
predicate_shorthands: FxHashMap<ty::Predicate<'tcx>, usize>,
728-
expn_info_shorthands: FxHashMap<ExpnId, AbsoluteBytePos>,
728+
expn_data_shorthands: FxHashMap<ExpnId, AbsoluteBytePos>,
729729
interpret_allocs: FxHashMap<interpret::AllocId, usize>,
730730
interpret_allocs_inverse: Vec<interpret::AllocId>,
731731
source_map: CachingSourceMapView<'tcx>,
@@ -817,17 +817,17 @@ where
817817
len.encode(self)?;
818818

819819
if span_data.ctxt == SyntaxContext::root() {
820-
TAG_NO_EXPANSION_INFO.encode(self)
820+
TAG_NO_EXPN_DATA.encode(self)
821821
} else {
822-
let (expn_id, expn_info) = span_data.ctxt.outer_expn_with_info();
823-
if let Some(pos) = self.expn_info_shorthands.get(&expn_id).cloned() {
824-
TAG_EXPANSION_INFO_SHORTHAND.encode(self)?;
822+
let (expn_id, expn_data) = span_data.ctxt.outer_expn_with_data();
823+
if let Some(pos) = self.expn_data_shorthands.get(&expn_id).cloned() {
824+
TAG_EXPN_DATA_SHORTHAND.encode(self)?;
825825
pos.encode(self)
826826
} else {
827-
TAG_EXPANSION_INFO_INLINE.encode(self)?;
827+
TAG_EXPN_DATA_INLINE.encode(self)?;
828828
let pos = AbsoluteBytePos::new(self.position());
829-
self.expn_info_shorthands.insert(expn_id, pos);
830-
expn_info.encode(self)
829+
self.expn_data_shorthands.insert(expn_id, pos);
830+
expn_data.encode(self)
831831
}
832832
}
833833
}

src/librustc_codegen_ssa/back/write.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1775,7 +1775,7 @@ impl SharedEmitterMain {
17751775
}
17761776
}
17771777
Ok(SharedEmitterMessage::InlineAsmError(cookie, msg)) => {
1778-
sess.span_err(ExpnId::from_u32(cookie).expn_info().call_site, &msg)
1778+
sess.span_err(ExpnId::from_u32(cookie).expn_data().call_site, &msg)
17791779
}
17801780
Ok(SharedEmitterMessage::AbortIfErrors) => {
17811781
sess.abort_if_errors();

src/librustc_lint/unused.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ impl EarlyLintPass for UnusedParens {
517517
// trigger in situations that macro authors shouldn't have to care about, e.g.,
518518
// when a parenthesized token tree matched in one macro expansion is matched as
519519
// an expression in another and used as a fn/method argument (Issue #47775)
520-
if e.span.ctxt().outer_expn_info().call_site.from_expansion() {
520+
if e.span.ctxt().outer_expn_data().call_site.from_expansion() {
521521
return;
522522
}
523523
let msg = format!("{} argument", call_kind);

src/librustc_resolve/macros.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use syntax::edition::Edition;
1717
use syntax::ext::base::{self, Indeterminate, SpecialDerives};
1818
use syntax::ext::base::{MacroKind, SyntaxExtension};
1919
use syntax::ext::expand::{AstFragment, Invocation, InvocationKind};
20-
use syntax::ext::hygiene::{self, ExpnId, ExpnInfo, ExpnKind};
20+
use syntax::ext::hygiene::{self, ExpnId, ExpnData, ExpnKind};
2121
use syntax::ext::tt::macro_rules;
2222
use syntax::feature_gate::{emit_feature_err, is_builtin_attr_name};
2323
use syntax::feature_gate::GateIssue;
@@ -97,7 +97,7 @@ impl<'a> base::Resolver for Resolver<'a> {
9797
}
9898

9999
fn get_module_scope(&mut self, id: ast::NodeId) -> ExpnId {
100-
let expn_id = ExpnId::fresh(Some(ExpnInfo::default(
100+
let expn_id = ExpnId::fresh(Some(ExpnData::default(
101101
ExpnKind::Macro(MacroKind::Attr, sym::test_case), DUMMY_SP, self.session.edition()
102102
)));
103103
let module = self.module_map[&self.definitions.local_def_id(id)];
@@ -185,8 +185,8 @@ impl<'a> base::Resolver for Resolver<'a> {
185185
let (ext, res) = self.smart_resolve_macro_path(path, kind, parent_scope, force)?;
186186

187187
let span = invoc.span();
188-
invoc.expansion_data.id.set_expn_info(
189-
ext.expn_info(parent_scope.expansion, span, fast_print_path(path))
188+
invoc.expansion_data.id.set_expn_data(
189+
ext.expn_data(parent_scope.expansion, span, fast_print_path(path))
190190
);
191191

192192
if let Res::Def(_, def_id) = res {
@@ -302,7 +302,7 @@ impl<'a> Resolver<'a> {
302302

303303
// Possibly apply the macro helper hack
304304
if kind == Some(MacroKind::Bang) && path.len() == 1 &&
305-
path[0].ident.span.ctxt().outer_expn_info().local_inner_macros {
305+
path[0].ident.span.ctxt().outer_expn_data().local_inner_macros {
306306
let root = Ident::new(kw::DollarCrate, path[0].ident.span);
307307
path.insert(0, Segment::from_ident(root));
308308
}

src/libsyntax/ext/base.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use crate::tokenstream::{self, TokenStream, TokenTree};
1515
use errors::{DiagnosticBuilder, DiagnosticId};
1616
use smallvec::{smallvec, SmallVec};
1717
use syntax_pos::{FileName, Span, MultiSpan, DUMMY_SP};
18-
use syntax_pos::hygiene::{ExpnInfo, ExpnKind};
18+
use syntax_pos::hygiene::{ExpnData, ExpnKind};
1919

2020
use rustc_data_structures::fx::FxHashMap;
2121
use rustc_data_structures::sync::{self, Lrc};
@@ -640,8 +640,8 @@ impl SyntaxExtension {
640640
SyntaxExtension::default(SyntaxExtensionKind::NonMacroAttr { mark_used }, edition)
641641
}
642642

643-
pub fn expn_info(&self, parent: ExpnId, call_site: Span, descr: Symbol) -> ExpnInfo {
644-
ExpnInfo {
643+
pub fn expn_data(&self, parent: ExpnId, call_site: Span, descr: Symbol) -> ExpnData {
644+
ExpnData {
645645
kind: ExpnKind::Macro(self.macro_kind(), descr),
646646
parent,
647647
call_site,
@@ -708,7 +708,7 @@ pub struct ExpansionData {
708708

709709
/// One of these is made during expansion and incrementally updated as we go;
710710
/// when a macro expansion occurs, the resulting nodes have the `backtrace()
711-
/// -> expn_info` of their expansion context stored into their span.
711+
/// -> expn_data` of their expansion context stored into their span.
712712
pub struct ExtCtxt<'a> {
713713
pub parse_sess: &'a parse::ParseSess,
714714
pub ecfg: expand::ExpansionConfig<'a>,
@@ -757,7 +757,7 @@ impl<'a> ExtCtxt<'a> {
757757
pub fn parse_sess(&self) -> &'a parse::ParseSess { self.parse_sess }
758758
pub fn cfg(&self) -> &ast::CrateConfig { &self.parse_sess.config }
759759
pub fn call_site(&self) -> Span {
760-
self.current_expansion.id.expn_info().call_site
760+
self.current_expansion.id.expn_data().call_site
761761
}
762762
pub fn backtrace(&self) -> SyntaxContext {
763763
SyntaxContext::root().apply_mark(self.current_expansion.id)
@@ -770,13 +770,13 @@ impl<'a> ExtCtxt<'a> {
770770
let mut ctxt = self.backtrace();
771771
let mut last_macro = None;
772772
loop {
773-
let expn_info = ctxt.outer_expn_info();
773+
let expn_data = ctxt.outer_expn_data();
774774
// Stop going up the backtrace once include! is encountered
775-
if expn_info.is_root() || expn_info.kind.descr() == sym::include {
775+
if expn_data.is_root() || expn_data.kind.descr() == sym::include {
776776
break;
777777
}
778-
ctxt = expn_info.call_site.ctxt();
779-
last_macro = Some(expn_info.call_site);
778+
ctxt = expn_data.call_site.ctxt();
779+
last_macro = Some(expn_data.call_site);
780780
}
781781
last_macro
782782
}

0 commit comments

Comments
 (0)