Skip to content

Commit 31e10ae

Browse files
committed
libsyntax: Remove Mark into ExpnId
1 parent f9477a7 commit 31e10ae

File tree

23 files changed

+183
-182
lines changed

23 files changed

+183
-182
lines changed

src/librustc/hir/lowering.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ use syntax::attr;
6060
use syntax::ast;
6161
use syntax::ast::*;
6262
use syntax::errors;
63-
use syntax::ext::hygiene::Mark;
63+
use syntax::ext::hygiene::ExpnId;
6464
use syntax::print::pprust;
6565
use syntax::source_map::{respan, ExpnInfo, ExpnKind, DesugaringKind, Spanned};
6666
use syntax::std_inject;
@@ -437,7 +437,7 @@ impl<'a> LoweringContext<'a> {
437437
owner,
438438
id,
439439
DefPathData::Misc,
440-
Mark::root(),
440+
ExpnId::root(),
441441
tree.prefix.span,
442442
);
443443
self.lctx.allocate_hir_id_counter(id);
@@ -875,7 +875,7 @@ impl<'a> LoweringContext<'a> {
875875
span: Span,
876876
allow_internal_unstable: Option<Lrc<[Symbol]>>,
877877
) -> Span {
878-
span.fresh_expansion(Mark::root(), ExpnInfo {
878+
span.fresh_expansion(ExpnId::root(), ExpnInfo {
879879
def_site: span,
880880
allow_internal_unstable,
881881
..ExpnInfo::default(ExpnKind::Desugaring(reason), span, self.sess.edition())
@@ -968,7 +968,7 @@ impl<'a> LoweringContext<'a> {
968968
parent_index,
969969
node_id,
970970
DefPathData::LifetimeNs(str_name),
971-
Mark::root(),
971+
ExpnId::root(),
972972
span,
973973
);
974974

@@ -1462,7 +1462,7 @@ impl<'a> LoweringContext<'a> {
14621462
parent_def_index,
14631463
impl_trait_node_id,
14641464
DefPathData::ImplTrait,
1465-
Mark::root(),
1465+
ExpnId::root(),
14661466
DUMMY_SP
14671467
);
14681468

@@ -1921,7 +1921,7 @@ impl<'a> LoweringContext<'a> {
19211921
self.parent,
19221922
def_node_id,
19231923
DefPathData::LifetimeNs(name.ident().as_interned_str()),
1924-
Mark::root(),
1924+
ExpnId::root(),
19251925
lifetime.span);
19261926

19271927
let (name, kind) = match name {

src/librustc/hir/map/def_collector.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::hir::map::definitions::*;
22
use crate::hir::def_id::DefIndex;
33

44
use syntax::ast::*;
5-
use syntax::ext::hygiene::Mark;
5+
use syntax::ext::hygiene::ExpnId;
66
use syntax::visit;
77
use syntax::symbol::{kw, sym};
88
use syntax::parse::token::{self, Token};
@@ -12,11 +12,11 @@ use syntax_pos::Span;
1212
pub struct DefCollector<'a> {
1313
definitions: &'a mut Definitions,
1414
parent_def: DefIndex,
15-
expansion: Mark,
15+
expansion: ExpnId,
1616
}
1717

1818
impl<'a> DefCollector<'a> {
19-
pub fn new(definitions: &'a mut Definitions, expansion: Mark) -> Self {
19+
pub fn new(definitions: &'a mut Definitions, expansion: ExpnId) -> Self {
2020
let parent_def = definitions.invocation_parent(expansion);
2121
DefCollector { definitions, parent_def, expansion }
2222
}

src/librustc/hir/map/definitions.rs

+17-17
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use std::borrow::Borrow;
1515
use std::fmt::Write;
1616
use std::hash::Hash;
1717
use syntax::ast;
18-
use syntax::ext::hygiene::Mark;
18+
use syntax::ext::hygiene::ExpnId;
1919
use syntax::symbol::{Symbol, sym, InternedString};
2020
use syntax_pos::{Span, DUMMY_SP};
2121
use crate::util::nodemap::NodeMap;
@@ -93,16 +93,16 @@ pub struct Definitions {
9393
node_to_def_index: NodeMap<DefIndex>,
9494
def_index_to_node: Vec<ast::NodeId>,
9595
pub(super) node_to_hir_id: IndexVec<ast::NodeId, hir::HirId>,
96-
/// If `Mark` is an ID of some macro expansion,
96+
/// If `ExpnId` is an ID of some macro expansion,
9797
/// then `DefId` is the normal module (`mod`) in which the expanded macro was defined.
98-
parent_modules_of_macro_defs: FxHashMap<Mark, DefId>,
99-
/// Item with a given `DefIndex` was defined during macro expansion with ID `Mark`.
100-
expansions_that_defined: FxHashMap<DefIndex, Mark>,
98+
parent_modules_of_macro_defs: FxHashMap<ExpnId, DefId>,
99+
/// Item with a given `DefIndex` was defined during macro expansion with ID `ExpnId`.
100+
expansions_that_defined: FxHashMap<DefIndex, ExpnId>,
101101
next_disambiguator: FxHashMap<(DefIndex, DefPathData), u32>,
102102
def_index_to_span: FxHashMap<DefIndex, Span>,
103-
/// When collecting definitions from an AST fragment produced by a macro invocation `Mark`
103+
/// When collecting definitions from an AST fragment produced by a macro invocation `ExpnId`
104104
/// we know what parent node that fragment should be attached to thanks to this table.
105-
invocation_parents: FxHashMap<Mark, DefIndex>,
105+
invocation_parents: FxHashMap<ExpnId, DefIndex>,
106106
}
107107

108108
/// A unique identifier that we can use to lookup a definition
@@ -437,7 +437,7 @@ impl Definitions {
437437
assert!(self.def_index_to_node.is_empty());
438438
self.def_index_to_node.push(ast::CRATE_NODE_ID);
439439
self.node_to_def_index.insert(ast::CRATE_NODE_ID, root_index);
440-
self.set_invocation_parent(Mark::root(), root_index);
440+
self.set_invocation_parent(ExpnId::root(), root_index);
441441

442442
// Allocate some other DefIndices that always must exist.
443443
GlobalMetaDataKind::allocate_def_indices(self);
@@ -450,7 +450,7 @@ impl Definitions {
450450
parent: DefIndex,
451451
node_id: ast::NodeId,
452452
data: DefPathData,
453-
expansion: Mark,
453+
expansion: ExpnId,
454454
span: Span)
455455
-> DefIndex {
456456
debug!("create_def_with_parent(parent={:?}, node_id={:?}, data={:?})",
@@ -498,7 +498,7 @@ impl Definitions {
498498
self.node_to_def_index.insert(node_id, index);
499499
}
500500

501-
if expansion != Mark::root() {
501+
if expansion != ExpnId::root() {
502502
self.expansions_that_defined.insert(index, expansion);
503503
}
504504

@@ -519,23 +519,23 @@ impl Definitions {
519519
self.node_to_hir_id = mapping;
520520
}
521521

522-
pub fn expansion_that_defined(&self, index: DefIndex) -> Mark {
523-
self.expansions_that_defined.get(&index).cloned().unwrap_or(Mark::root())
522+
pub fn expansion_that_defined(&self, index: DefIndex) -> ExpnId {
523+
self.expansions_that_defined.get(&index).cloned().unwrap_or(ExpnId::root())
524524
}
525525

526-
pub fn parent_module_of_macro_def(&self, mark: Mark) -> DefId {
526+
pub fn parent_module_of_macro_def(&self, mark: ExpnId) -> DefId {
527527
self.parent_modules_of_macro_defs[&mark]
528528
}
529529

530-
pub fn add_parent_module_of_macro_def(&mut self, mark: Mark, module: DefId) {
530+
pub fn add_parent_module_of_macro_def(&mut self, mark: ExpnId, module: DefId) {
531531
self.parent_modules_of_macro_defs.insert(mark, module);
532532
}
533533

534-
pub fn invocation_parent(&self, invoc_id: Mark) -> DefIndex {
534+
pub fn invocation_parent(&self, invoc_id: ExpnId) -> DefIndex {
535535
self.invocation_parents[&invoc_id]
536536
}
537537

538-
pub fn set_invocation_parent(&mut self, invoc_id: Mark, parent: DefIndex) {
538+
pub fn set_invocation_parent(&mut self, invoc_id: ExpnId, parent: DefIndex) {
539539
let old_parent = self.invocation_parents.insert(invoc_id, parent);
540540
assert!(old_parent.is_none(), "parent def-index is reset for an invocation");
541541
}
@@ -624,7 +624,7 @@ macro_rules! define_global_metadata_kind {
624624
CRATE_DEF_INDEX,
625625
ast::DUMMY_NODE_ID,
626626
DefPathData::GlobalMetaData(instance.name().as_interned_str()),
627-
Mark::root(),
627+
ExpnId::root(),
628628
DUMMY_SP
629629
);
630630

src/librustc/ich/hcx.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ impl<'a> HashStable<StableHashingContext<'a>> for Span {
359359
// times, we cache a stable hash of it and hash that instead of
360360
// recursing every time.
361361
thread_local! {
362-
static CACHE: RefCell<FxHashMap<hygiene::Mark, u64>> = Default::default();
362+
static CACHE: RefCell<FxHashMap<hygiene::ExpnId, u64>> = Default::default();
363363
}
364364

365365
let sub_hash: u64 = CACHE.with(|cache| {

src/librustc/ty/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ use std::{mem, ptr};
4444
use std::ops::Range;
4545
use syntax::ast::{self, Name, Ident, NodeId};
4646
use syntax::attr;
47-
use syntax::ext::hygiene::Mark;
47+
use syntax::ext::hygiene::ExpnId;
4848
use syntax::symbol::{kw, sym, Symbol, LocalInternedString, InternedString};
4949
use syntax_pos::Span;
5050

@@ -3071,10 +3071,10 @@ impl<'tcx> TyCtxt<'tcx> {
30713071
self.expansion_that_defined(def_parent_def_id))
30723072
}
30733073

3074-
fn expansion_that_defined(self, scope: DefId) -> Mark {
3074+
fn expansion_that_defined(self, scope: DefId) -> ExpnId {
30753075
match scope.krate {
30763076
LOCAL_CRATE => self.hir().definitions().expansion_that_defined(scope.index),
3077-
_ => Mark::root(),
3077+
_ => ExpnId::root(),
30783078
}
30793079
}
30803080

src/librustc/ty/query/on_disk_cache.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ 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::{Mark, SyntaxContext, ExpnInfo};
26+
use syntax_pos::hygiene::{ExpnId, SyntaxContext, ExpnInfo};
2727

2828
const TAG_FILE_FOOTER: u128 = 0xC0FFEE_C0FFEE_C0FFEE_C0FFEE_C0FFEE;
2929

@@ -594,7 +594,7 @@ impl<'a, 'tcx> SpecializedDecoder<Span> for CacheDecoder<'a, 'tcx> {
594594
// as long as incremental compilation does not kick in before that.
595595
let location = || Span::new(lo, hi, SyntaxContext::empty());
596596
let recover_from_expn_info = |this: &Self, expn_info, pos| {
597-
let span = location().fresh_expansion(Mark::root(), expn_info);
597+
let span = location().fresh_expansion(ExpnId::root(), expn_info);
598598
this.synthetic_expansion_infos.borrow_mut().insert(pos, span.ctxt());
599599
span
600600
};
@@ -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<Mark, AbsoluteBytePos>,
728+
expn_info_shorthands: FxHashMap<ExpnId, AbsoluteBytePos>,
729729
interpret_allocs: FxHashMap<interpret::AllocId, usize>,
730730
interpret_allocs_inverse: Vec<interpret::AllocId>,
731731
source_map: CachingSourceMapView<'tcx>,

src/librustc_allocator/expand.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use syntax::{
1414
base::{ExtCtxt, MacroKind, Resolver},
1515
build::AstBuilder,
1616
expand::ExpansionConfig,
17-
hygiene::Mark,
17+
hygiene::ExpnId,
1818
},
1919
mut_visit::{self, MutVisitor},
2020
parse::ParseSess,
@@ -85,7 +85,7 @@ impl MutVisitor for ExpandAllocatorDirectives<'_> {
8585
self.found = true;
8686

8787
// Create a new expansion for the generated allocator code.
88-
let span = item.span.fresh_expansion(Mark::root(), ExpnInfo::allow_unstable(
88+
let span = item.span.fresh_expansion(ExpnId::root(), ExpnInfo::allow_unstable(
8989
ExpnKind::Macro(MacroKind::Attr, sym::global_allocator), item.span, self.sess.edition,
9090
[sym::rustc_attrs][..].into(),
9191
));

src/librustc_codegen_ssa/back/write.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use rustc_errors::{Handler, Level, DiagnosticBuilder, FatalError, DiagnosticId};
2626
use rustc_errors::emitter::{Emitter};
2727
use rustc_target::spec::MergeFunctions;
2828
use syntax::attr;
29-
use syntax::ext::hygiene::Mark;
29+
use syntax::ext::hygiene::ExpnId;
3030
use syntax_pos::MultiSpan;
3131
use syntax_pos::symbol::{Symbol, sym};
3232
use jobserver::{Client, Acquired};
@@ -1775,7 +1775,7 @@ impl SharedEmitterMain {
17751775
}
17761776
}
17771777
Ok(SharedEmitterMessage::InlineAsmError(cookie, msg)) => {
1778-
match Mark::from_u32(cookie).expn_info() {
1778+
match ExpnId::from_u32(cookie).expn_info() {
17791779
Some(ei) => sess.span_err(ei.call_site, &msg),
17801780
None => sess.err(&msg),
17811781
}

src/librustc_metadata/decoder.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ use syntax::ast::{self, Ident};
3131
use syntax::source_map;
3232
use syntax::symbol::{Symbol, sym};
3333
use syntax::ext::base::{MacroKind, SyntaxExtension};
34-
use syntax::ext::hygiene::Mark;
34+
use syntax::ext::hygiene::ExpnId;
3535
use syntax_pos::{self, Span, BytePos, Pos, DUMMY_SP, NO_EXPANSION};
3636
use log::debug;
3737

@@ -458,7 +458,7 @@ crate fn proc_macro_def_path_table(crate_root: &CrateRoot<'_>,
458458
crate_root,
459459
ast::DUMMY_NODE_ID,
460460
DefPathData::MacroNs(name.as_interned_str()),
461-
Mark::root(),
461+
ExpnId::root(),
462462
DUMMY_SP);
463463
debug!("definition for {:?} is {:?}", name, def_index);
464464
assert_eq!(def_index, DefIndex::from_proc_macro_index(index));

0 commit comments

Comments
 (0)