chore: Remove legacy SyntaxContextId re-export

This commit is contained in:
Lukas Wirth 2025-03-15 16:07:52 +01:00
parent 60cd01864a
commit 02a793bd59
38 changed files with 164 additions and 228 deletions

View file

@ -8,7 +8,7 @@ use intern::{sym, Interned, Symbol};
use mbe::{DelimiterKind, Punct};
use smallvec::{smallvec, SmallVec};
use span::{Span, SyntaxContextId};
use span::{Span, SyntaxContext};
use syntax::unescape;
use syntax::{ast, match_ast, AstNode, AstToken, SyntaxNode};
use syntax_bridge::{desugar_doc_comment_text, syntax_node_to_token_tree, DocCommentDesugarMode};
@ -210,7 +210,7 @@ pub struct Attr {
pub id: AttrId,
pub path: Interned<ModPath>,
pub input: Option<Box<AttrInput>>,
pub ctxt: SyntaxContextId,
pub ctxt: SyntaxContext,
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]

View file

@ -4,7 +4,7 @@ use intern::sym;
use itertools::{izip, Itertools};
use parser::SyntaxKind;
use rustc_hash::FxHashSet;
use span::{Edition, MacroCallId, Span, SyntaxContextId};
use span::{Edition, MacroCallId, Span, SyntaxContext};
use stdx::never;
use syntax_bridge::DocCommentDesugarMode;
use tracing::debug;
@ -237,7 +237,7 @@ fn parse_adt(
fn parse_adt_from_syntax(
adt: &ast::Adt,
tm: &span::SpanMap<SyntaxContextId>,
tm: &span::SpanMap<SyntaxContext>,
call_site: Span,
) -> Result<BasicAdtInfo, ExpandError> {
let (name, generic_param_list, where_clause, shape) = match &adt {
@ -389,7 +389,7 @@ fn to_adt_syntax(
db: &dyn ExpandDatabase,
tt: &tt::TopSubtree,
call_site: Span,
) -> Result<(ast::Adt, span::SpanMap<SyntaxContextId>), ExpandError> {
) -> Result<(ast::Adt, span::SpanMap<SyntaxContext>), ExpandError> {
let (parsed, tm) = crate::db::token_tree_to_syntax_node(
db,
tt,

View file

@ -226,7 +226,7 @@ mod tests {
use ::tt::IdentIsRaw;
use expect_test::expect;
use intern::Symbol;
use span::{Edition, SpanAnchor, SyntaxContextId, ROOT_ERASED_FILE_AST_ID};
use span::{Edition, SpanAnchor, SyntaxContext, ROOT_ERASED_FILE_AST_ID};
use syntax::{TextRange, TextSize};
use super::quote;
@ -240,7 +240,7 @@ mod tests {
),
ast_id: ROOT_ERASED_FILE_AST_ID,
},
ctx: SyntaxContextId::root(Edition::CURRENT),
ctx: SyntaxContext::root(Edition::CURRENT),
};
#[test]

View file

@ -7,7 +7,7 @@ use rustc_hash::FxHashSet;
use salsa::plumbing::AsId;
use span::{
AstIdMap, Edition, EditionedFileId, HirFileId, HirFileIdRepr, MacroCallId, MacroFileId, Span,
SyntaxContextId,
SyntaxContext,
};
use syntax::{ast, AstNode, Parse, SyntaxElement, SyntaxError, SyntaxNode, SyntaxToken, T};
use syntax_bridge::{syntax_node_to_token_tree, DocCommentDesugarMode};
@ -96,10 +96,6 @@ pub trait ExpandDatabase: RootQueryDb {
#[salsa::transparent]
fn lookup_intern_macro_call(&self, macro_call: MacroCallId) -> MacroCallLoc;
#[salsa::transparent]
#[salsa::invoke(crate::hygiene::dump_syntax_contexts)]
fn dump_syntax_contexts(&self) -> String;
/// Lowers syntactic macro call to a token tree representation. That's a firewall
/// query, only typing in the macro call itself changes the returned
/// subtree.
@ -148,7 +144,7 @@ pub trait ExpandDatabase: RootQueryDb {
) -> Option<Arc<ExpandResult<Arc<[SyntaxError]>>>>;
#[salsa::transparent]
fn syntax_context(&self, file: HirFileId, edition: Edition) -> SyntaxContextId;
fn syntax_context(&self, file: HirFileId, edition: Edition) -> SyntaxContext;
}
#[salsa::interned(no_lifetime, id = span::MacroCallId)]
@ -164,14 +160,14 @@ fn lookup_intern_macro_call(db: &dyn ExpandDatabase, macro_call: MacroCallId) ->
MacroCallWrapper::ingredient(db).data(db.as_dyn_database(), macro_call.as_id()).0.clone()
}
#[salsa::interned(no_lifetime, id = span::SyntaxContextId)]
#[salsa::interned(no_lifetime, id = span::SyntaxContext)]
pub struct SyntaxContextWrapper {
pub data: SyntaxContextId,
pub data: SyntaxContext,
}
fn syntax_context(db: &dyn ExpandDatabase, file: HirFileId, edition: Edition) -> SyntaxContextId {
fn syntax_context(db: &dyn ExpandDatabase, file: HirFileId, edition: Edition) -> SyntaxContext {
match file.repr() {
HirFileIdRepr::FileId(_) => SyntaxContextId::root(edition),
HirFileIdRepr::FileId(_) => SyntaxContext::root(edition),
HirFileIdRepr::MacroFile(m) => {
let kind = db.lookup_intern_macro_call(m.macro_call_id).kind;
db.macro_arg_considering_derives(m.macro_call_id, &kind).2.ctx

View file

@ -2,7 +2,7 @@
use base_db::Crate;
use intern::sym;
use span::{Edition, HirFileIdRepr, MacroCallId, Span, SyntaxContextId};
use span::{Edition, HirFileIdRepr, MacroCallId, Span, SyntaxContext};
use stdx::TupleExt;
use syntax::{ast, AstNode};
use syntax_bridge::DocCommentDesugarMode;
@ -100,7 +100,7 @@ impl DeclarativeMacroExpander {
_ => None,
}
};
let ctx_edition = |ctx: SyntaxContextId| {
let ctx_edition = |ctx: SyntaxContext| {
if ctx.is_root() {
def_crate.data(db).edition
} else {
@ -161,7 +161,7 @@ impl DeclarativeMacroExpander {
};
let edition = ctx_edition(match id.file_id.repr() {
HirFileIdRepr::MacroFile(macro_file) => macro_file.macro_call_id.lookup(db).ctxt,
HirFileIdRepr::FileId(file) => SyntaxContextId::root(file.edition()),
HirFileIdRepr::FileId(file) => SyntaxContext::root(file.edition()),
});
Arc::new(DeclarativeMacroExpander { mac, transparency, edition })
}

View file

@ -19,7 +19,7 @@
//!
//! See the full discussion : <https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/Eager.20expansion.20of.20built-in.20macros>
use base_db::Crate;
use span::SyntaxContextId;
use span::SyntaxContext;
use syntax::{ted, Parse, SyntaxElement, SyntaxNode, TextSize, WalkEvent};
use syntax_bridge::DocCommentDesugarMode;
use triomphe::Arc;
@ -38,7 +38,7 @@ pub fn expand_eager_macro_input(
macro_call: &ast::MacroCall,
ast_id: AstId<ast::MacroCall>,
def: MacroDefId,
call_site: SyntaxContextId,
call_site: SyntaxContext,
resolver: &dyn Fn(&ModPath) -> Option<MacroDefId>,
) -> ExpandResult<Option<MacroCallId>> {
let expand_to = ExpandTo::from_call_site(macro_call);
@ -116,7 +116,7 @@ fn lazy_expand(
macro_call: &ast::MacroCall,
ast_id: AstId<ast::MacroCall>,
krate: Crate,
call_site: SyntaxContextId,
call_site: SyntaxContext,
) -> ExpandResult<(InFile<Parse<SyntaxNode>>, Arc<ExpansionSpanMap>)> {
let expand_to = ExpandTo::from_call_site(macro_call);
let id = def.make_call(
@ -138,7 +138,7 @@ fn eager_macro_recur(
mut offset: TextSize,
curr: InFile<SyntaxNode>,
krate: Crate,
call_site: SyntaxContextId,
call_site: SyntaxContext,
macro_resolver: &dyn Fn(&ModPath) -> Option<MacroDefId>,
) -> ExpandResult<Option<(SyntaxNode, TextSize)>> {
let original = curr.value.clone_for_update();

View file

@ -4,7 +4,7 @@ use std::borrow::Borrow;
use either::Either;
use span::{
AstIdNode, EditionedFileId, ErasedFileAstId, FileAstId, HirFileId, HirFileIdRepr, MacroFileId,
SyntaxContextId,
SyntaxContext,
};
use syntax::{AstNode, AstPtr, SyntaxNode, SyntaxNodePtr, SyntaxToken, TextRange, TextSize};
@ -311,7 +311,7 @@ impl InFile<&SyntaxNode> {
pub fn original_file_range_opt(
self,
db: &dyn db::ExpandDatabase,
) -> Option<(FileRange, SyntaxContextId)> {
) -> Option<(FileRange, SyntaxContext)> {
self.borrow().map(SyntaxNode::text_range).original_node_file_range_opt(db)
}
}
@ -376,7 +376,7 @@ impl InFile<SyntaxToken> {
}
impl InMacroFile<TextSize> {
pub fn original_file_range(self, db: &dyn db::ExpandDatabase) -> (FileRange, SyntaxContextId) {
pub fn original_file_range(self, db: &dyn db::ExpandDatabase) -> (FileRange, SyntaxContext) {
span_for_offset(db, &db.expansion_span_map(self.file_id), self.value)
}
}
@ -385,17 +385,17 @@ impl InFile<TextRange> {
pub fn original_node_file_range(
self,
db: &dyn db::ExpandDatabase,
) -> (FileRange, SyntaxContextId) {
) -> (FileRange, SyntaxContext) {
match self.file_id.repr() {
HirFileIdRepr::FileId(file_id) => {
(FileRange { file_id, range: self.value }, SyntaxContextId::root(file_id.edition()))
(FileRange { file_id, range: self.value }, SyntaxContext::root(file_id.edition()))
}
HirFileIdRepr::MacroFile(mac_file) => {
match map_node_range_up(db, &db.expansion_span_map(mac_file), self.value) {
Some(it) => it,
None => {
let loc = db.lookup_intern_macro_call(mac_file.macro_call_id);
(loc.kind.original_call_range(db), SyntaxContextId::root(loc.def.edition))
(loc.kind.original_call_range(db), SyntaxContext::root(loc.def.edition))
}
}
}
@ -438,11 +438,11 @@ impl InFile<TextRange> {
pub fn original_node_file_range_opt(
self,
db: &dyn db::ExpandDatabase,
) -> Option<(FileRange, SyntaxContextId)> {
) -> Option<(FileRange, SyntaxContext)> {
match self.file_id.repr() {
HirFileIdRepr::FileId(file_id) => Some((
FileRange { file_id, range: self.value },
SyntaxContextId::root(file_id.edition()),
SyntaxContext::root(file_id.edition()),
)),
HirFileIdRepr::MacroFile(mac_file) => {
map_node_range_up(db, &db.expansion_span_map(mac_file), self.value)

View file

@ -4,7 +4,7 @@
use intern::sym;
use rustc_hash::{FxHashMap, FxHashSet};
use span::{
ErasedFileAstId, Span, SpanAnchor, SyntaxContextId, FIXUP_ERASED_FILE_AST_ID_MARKER,
ErasedFileAstId, Span, SpanAnchor, SyntaxContext, FIXUP_ERASED_FILE_AST_ID_MARKER,
ROOT_ERASED_FILE_AST_ID,
};
use stdx::never;
@ -353,7 +353,7 @@ pub(crate) fn reverse_fixups(tt: &mut TopSubtree, undo_info: &SyntaxFixupUndoInf
let span = |file_id| Span {
range: TextRange::empty(TextSize::new(0)),
anchor: SpanAnchor { file_id, ast_id: ROOT_ERASED_FILE_AST_ID },
ctx: SyntaxContextId::root(span::Edition::Edition2015),
ctx: SyntaxContext::root(span::Edition::Edition2015),
};
delimiter.open = span(delimiter.open.anchor.file_id);
delimiter.close = span(delimiter.close.anchor.file_id);

View file

@ -24,9 +24,9 @@
use std::{convert::identity, iter};
use span::{Edition, MacroCallId, Span, SyntaxContextId};
use span::{Edition, MacroCallId, Span, SyntaxContext};
use crate::db::{ExpandDatabase, MacroCallWrapper};
use crate::db::ExpandDatabase;
pub use span::Transparency;
@ -65,18 +65,18 @@ fn span_with_ctxt_from_mark(
edition: Edition,
) -> Span {
Span {
ctx: apply_mark(db, SyntaxContextId::root(edition), expn_id, transparency, edition),
ctx: apply_mark(db, SyntaxContext::root(edition), expn_id, transparency, edition),
..span
}
}
pub(super) fn apply_mark(
db: &dyn ExpandDatabase,
ctxt: span::SyntaxContextId,
ctxt: span::SyntaxContext,
call_id: span::MacroCallId,
transparency: Transparency,
edition: Edition,
) -> SyntaxContextId {
) -> SyntaxContext {
if transparency == Transparency::Opaque {
return apply_mark_internal(db, ctxt, call_id, transparency, edition);
}
@ -109,11 +109,11 @@ pub(super) fn apply_mark(
fn apply_mark_internal(
db: &dyn ExpandDatabase,
ctxt: SyntaxContextId,
ctxt: SyntaxContext,
call_id: MacroCallId,
transparency: Transparency,
edition: Edition,
) -> SyntaxContextId {
) -> SyntaxContext {
let call_id = Some(call_id);
let mut opaque = ctxt.opaque(db);
@ -121,18 +121,17 @@ fn apply_mark_internal(
if transparency >= Transparency::Opaque {
let parent = opaque;
opaque =
SyntaxContextId::new(db, call_id, transparency, edition, parent, identity, identity);
opaque = SyntaxContext::new(db, call_id, transparency, edition, parent, identity, identity);
}
if transparency >= Transparency::SemiTransparent {
let parent = opaque_and_semitransparent;
opaque_and_semitransparent =
SyntaxContextId::new(db, call_id, transparency, edition, parent, |_| opaque, identity);
SyntaxContext::new(db, call_id, transparency, edition, parent, |_| opaque, identity);
}
let parent = ctxt;
SyntaxContextId::new(
SyntaxContext::new(
db,
call_id,
transparency,
@ -144,9 +143,9 @@ fn apply_mark_internal(
}
pub trait SyntaxContextExt {
fn normalize_to_macro_rules(self, db: &dyn ExpandDatabase) -> span::SyntaxContextId;
fn normalize_to_macros_2_0(self, db: &dyn ExpandDatabase) -> span::SyntaxContextId;
fn parent_ctxt(self, db: &dyn ExpandDatabase) -> span::SyntaxContextId;
fn normalize_to_macro_rules(self, db: &dyn ExpandDatabase) -> span::SyntaxContext;
fn normalize_to_macros_2_0(self, db: &dyn ExpandDatabase) -> span::SyntaxContext;
fn parent_ctxt(self, db: &dyn ExpandDatabase) -> span::SyntaxContext;
fn remove_mark(&mut self, db: &dyn ExpandDatabase)
-> (Option<span::MacroCallId>, Transparency);
fn outer_mark(self, db: &dyn ExpandDatabase) -> (Option<span::MacroCallId>, Transparency);
@ -154,14 +153,14 @@ pub trait SyntaxContextExt {
fn is_opaque(self, db: &dyn ExpandDatabase) -> bool;
}
impl SyntaxContextExt for SyntaxContextId {
fn normalize_to_macro_rules(self, db: &dyn ExpandDatabase) -> span::SyntaxContextId {
impl SyntaxContextExt for SyntaxContext {
fn normalize_to_macro_rules(self, db: &dyn ExpandDatabase) -> span::SyntaxContext {
self.opaque_and_semitransparent(db)
}
fn normalize_to_macros_2_0(self, db: &dyn ExpandDatabase) -> span::SyntaxContextId {
fn normalize_to_macros_2_0(self, db: &dyn ExpandDatabase) -> span::SyntaxContext {
self.opaque(db)
}
fn parent_ctxt(self, db: &dyn ExpandDatabase) -> span::SyntaxContextId {
fn parent_ctxt(self, db: &dyn ExpandDatabase) -> span::SyntaxContext {
self.parent(db)
}
fn outer_mark(self, db: &dyn ExpandDatabase) -> (Option<span::MacroCallId>, Transparency) {
@ -188,7 +187,7 @@ impl SyntaxContextExt for SyntaxContextId {
// FIXME: Make this a SyntaxContextExt method once we have RPIT
pub fn marks_rev(
ctxt: SyntaxContextId,
ctxt: SyntaxContext,
db: &dyn ExpandDatabase,
) -> impl Iterator<Item = (span::MacroCallId, Transparency)> + '_ {
iter::successors(Some(ctxt), move |&mark| Some(mark.parent_ctxt(db)))
@ -200,53 +199,3 @@ pub fn marks_rev(
(mark.0.unwrap(), mark.1)
})
}
pub(crate) fn dump_syntax_contexts(db: &dyn ExpandDatabase) -> String {
let mut s = String::from("Expansions:");
let entries =
MacroCallWrapper::ingredient(db).entries(db.as_dyn_database()).collect::<Vec<_>>();
for loc in entries {
let expn_data = &loc.fields().0;
s.push_str(&format!(
"parent: {:?}, call_site_ctxt: {:?}, kind: {:?}",
expn_data.kind.file_id(),
expn_data.ctxt,
expn_data.kind.descr(),
));
}
s.push_str("\n\nSyntaxContexts:\n");
let entries = SyntaxContextId::ingredient(db).entries(db.as_dyn_database()).collect::<Vec<_>>();
for e in entries {
struct SyntaxContextDebug<'a>(
&'a dyn ExpandDatabase,
&'a span::SyntaxContextUnderlyingData,
);
impl std::fmt::Debug for SyntaxContextDebug<'_> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
fancy_debug(self.1, self.0, f)
}
}
fn fancy_debug(
this: &span::SyntaxContextUnderlyingData,
db: &dyn ExpandDatabase,
f: &mut std::fmt::Formatter<'_>,
) -> std::fmt::Result {
write!(f, "parent: #{}, outer_mark: (", this.parent)?;
match this.outer_expn {
Some(id) => {
write!(f, "{:?}::{{{{expn{:?}}}}}", db.lookup_intern_macro_call(id).krate, id)?
}
None => write!(f, "root")?,
}
write!(f, ", {:?})", this.outer_transparency)
}
let dbg = SyntaxContextDebug(db, e.fields());
stdx::format_to!(s, "{:?}\n", dbg);
}
s
}

View file

@ -37,7 +37,7 @@ use base_db::Crate;
use either::Either;
use span::{
Edition, EditionedFileId, ErasedFileAstId, FileAstId, HirFileIdRepr, Span, SpanAnchor,
SyntaxContextId,
SyntaxContext,
};
use syntax::{
ast::{self, AstNode},
@ -252,7 +252,7 @@ pub struct MacroCallLoc {
pub def: MacroDefId,
pub krate: Crate,
pub kind: MacroCallKind,
pub ctxt: SyntaxContextId,
pub ctxt: SyntaxContext,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
@ -527,7 +527,7 @@ impl MacroDefId {
db: &dyn ExpandDatabase,
krate: Crate,
kind: MacroCallKind,
ctxt: SyntaxContextId,
ctxt: SyntaxContext,
) -> MacroCallId {
db.intern_macro_call(MacroCallLoc { def: self, krate, kind, ctxt })
}
@ -683,7 +683,7 @@ impl MacroCallLoc {
}
impl MacroCallKind {
fn descr(&self) -> &'static str {
pub fn descr(&self) -> &'static str {
match self {
MacroCallKind::FnLike { .. } => "macro call",
MacroCallKind::Derive { .. } => "derive macro",
@ -831,7 +831,7 @@ impl ExpansionInfo {
pub fn map_range_down_exact(
&self,
span: Span,
) -> Option<InMacroFile<impl Iterator<Item = (SyntaxToken, SyntaxContextId)> + '_>> {
) -> Option<InMacroFile<impl Iterator<Item = (SyntaxToken, SyntaxContext)> + '_>> {
let tokens = self.exp_map.ranges_with_span_exact(span).flat_map(move |(range, ctx)| {
self.expanded.value.covering_element(range).into_token().zip(Some(ctx))
});
@ -846,7 +846,7 @@ impl ExpansionInfo {
pub fn map_range_down(
&self,
span: Span,
) -> Option<InMacroFile<impl Iterator<Item = (SyntaxToken, SyntaxContextId)> + '_>> {
) -> Option<InMacroFile<impl Iterator<Item = (SyntaxToken, SyntaxContext)> + '_>> {
let tokens = self.exp_map.ranges_with_span(span).flat_map(move |(range, ctx)| {
self.expanded.value.covering_element(range).into_token().zip(Some(ctx))
});
@ -859,7 +859,7 @@ impl ExpansionInfo {
&self,
db: &dyn ExpandDatabase,
offset: TextSize,
) -> (FileRange, SyntaxContextId) {
) -> (FileRange, SyntaxContext) {
debug_assert!(self.expanded.value.text_range().contains(offset));
span_for_offset(db, &self.exp_map, offset)
}
@ -869,7 +869,7 @@ impl ExpansionInfo {
&self,
db: &dyn ExpandDatabase,
range: TextRange,
) -> Option<(FileRange, SyntaxContextId)> {
) -> Option<(FileRange, SyntaxContext)> {
debug_assert!(self.expanded.value.text_range().contains_range(range));
map_node_range_up(db, &self.exp_map, range)
}
@ -953,7 +953,7 @@ pub fn map_node_range_up(
db: &dyn ExpandDatabase,
exp_map: &ExpansionSpanMap,
range: TextRange,
) -> Option<(FileRange, SyntaxContextId)> {
) -> Option<(FileRange, SyntaxContext)> {
let mut spans = exp_map.spans_for_range(range);
let Span { range, anchor, ctx } = spans.next()?;
let mut start = range.start();
@ -980,7 +980,7 @@ pub fn map_node_range_up_aggregated(
db: &dyn ExpandDatabase,
exp_map: &ExpansionSpanMap,
range: TextRange,
) -> FxHashMap<(SpanAnchor, SyntaxContextId), TextRange> {
) -> FxHashMap<(SpanAnchor, SyntaxContext), TextRange> {
let mut map = FxHashMap::default();
for span in exp_map.spans_for_range(range) {
let range = map.entry((span.anchor, span.ctx)).or_insert_with(|| span.range);
@ -1002,7 +1002,7 @@ pub fn span_for_offset(
db: &dyn ExpandDatabase,
exp_map: &ExpansionSpanMap,
offset: TextSize,
) -> (FileRange, SyntaxContextId) {
) -> (FileRange, SyntaxContext) {
let span = exp_map.span_at(offset);
let anchor_offset = db
.ast_id_map(span.anchor.file_id.into())

View file

@ -14,7 +14,7 @@ use crate::{
use base_db::Crate;
use intern::sym;
use smallvec::SmallVec;
use span::{Edition, SyntaxContextId};
use span::{Edition, SyntaxContext};
use syntax::{ast, AstNode};
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
@ -44,7 +44,7 @@ impl ModPath {
pub fn from_src(
db: &dyn ExpandDatabase,
path: ast::Path,
span_for_range: &mut dyn FnMut(::tt::TextRange) -> SyntaxContextId,
span_for_range: &mut dyn FnMut(::tt::TextRange) -> SyntaxContext,
) -> Option<ModPath> {
convert_path(db, path, span_for_range)
}
@ -209,7 +209,7 @@ fn display_fmt_path(
fn convert_path(
db: &dyn ExpandDatabase,
path: ast::Path,
span_for_range: &mut dyn FnMut(::tt::TextRange) -> SyntaxContextId,
span_for_range: &mut dyn FnMut(::tt::TextRange) -> SyntaxContext,
) -> Option<ModPath> {
let mut segments = path.segments();
@ -333,7 +333,7 @@ fn convert_path_tt(db: &dyn ExpandDatabase, tt: tt::TokenTreesView<'_>) -> Optio
Some(ModPath { kind, segments })
}
pub fn resolve_crate_root(db: &dyn ExpandDatabase, mut ctxt: SyntaxContextId) -> Option<Crate> {
pub fn resolve_crate_root(db: &dyn ExpandDatabase, mut ctxt: SyntaxContext) -> Option<Crate> {
// When resolving `$crate` from a `macro_rules!` invoked in a `macro`,
// we don't want to pretend that the `macro_rules!` definition is in the `macro`
// as described in `SyntaxContextId::apply_mark`, so we ignore prepended opaque marks.

View file

@ -3,7 +3,7 @@
use std::fmt;
use intern::{sym, Symbol};
use span::{Edition, SyntaxContextId};
use span::{Edition, SyntaxContext};
use syntax::utils::is_raw_identifier;
use syntax::{ast, format_smolstr};
@ -74,7 +74,7 @@ impl Name {
Name { symbol: Symbol::intern(text), ctx: () }
}
pub fn new(text: &str, mut ctx: SyntaxContextId) -> Name {
pub fn new(text: &str, mut ctx: SyntaxContext) -> Name {
// For comparisons etc. we remove the edition, because sometimes we search for some `Name`
// and we don't know which edition it came from.
// Can't do that for all `SyntaxContextId`s because it breaks Salsa.
@ -88,7 +88,7 @@ impl Name {
pub fn new_root(text: &str) -> Name {
// The edition doesn't matter for hygiene.
Self::new(text, SyntaxContextId::root(Edition::Edition2015))
Self::new(text, SyntaxContext::root(Edition::Edition2015))
}
pub fn new_tuple_field(idx: usize) -> Name {
@ -122,7 +122,7 @@ impl Name {
}
}
pub fn new_symbol(symbol: Symbol, ctx: SyntaxContextId) -> Self {
pub fn new_symbol(symbol: Symbol, ctx: SyntaxContext) -> Self {
debug_assert!(!symbol.as_str().starts_with("r#"));
_ = ctx;
Self { symbol, ctx: () }
@ -130,7 +130,7 @@ impl Name {
// FIXME: This needs to go once we have hygiene
pub fn new_symbol_root(sym: Symbol) -> Self {
Self::new_symbol(sym, SyntaxContextId::root(Edition::Edition2015))
Self::new_symbol(sym, SyntaxContext::root(Edition::Edition2015))
}
/// A fake name for things missing in the source code.

View file

@ -154,7 +154,7 @@ impl CrateProcMacros {
/// Fetch the [`CustomProcMacroExpander`]s and their corresponding names for the given crate.
pub fn list(
&self,
def_site_ctx: span::SyntaxContextId,
def_site_ctx: span::SyntaxContext,
) -> Option<Box<[(crate::name::Name, CustomProcMacroExpander, bool)]>> {
match &self.0 {
Ok(proc_macros) => Some(

View file

@ -1,6 +1,6 @@
//! Span maps for real files and macro expansions.
use span::{EditionedFileId, HirFileId, HirFileIdRepr, MacroFileId, Span, SyntaxContextId};
use span::{EditionedFileId, HirFileId, HirFileIdRepr, MacroFileId, Span, SyntaxContext};
use stdx::TupleExt;
use syntax::{ast, AstNode, TextRange};
use triomphe::Arc;
@ -9,7 +9,7 @@ pub use span::RealSpanMap;
use crate::{attrs::collect_attrs, db::ExpandDatabase};
pub type ExpansionSpanMap = span::SpanMap<SyntaxContextId>;
pub type ExpansionSpanMap = span::SpanMap<SyntaxContext>;
/// Spanmap for a macro file or a real file
#[derive(Clone, Debug, PartialEq, Eq)]