Skip to content

Commit 220d913

Browse files
authored
Merge pull request #19366 from Veykril/push-mkunlxkysssr
chore: Remove legacy `SyntaxContextId` re-export
2 parents bc05a94 + 02a793b commit 220d913

38 files changed

+164
-228
lines changed

crates/hir-def/src/expander.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use hir_expand::{
99
attrs::RawAttrs, mod_path::ModPath, span_map::SpanMap, ExpandError, ExpandErrorKind,
1010
ExpandResult, HirFileId, InFile, Lookup, MacroCallId,
1111
};
12-
use span::{Edition, SyntaxContextId};
12+
use span::{Edition, SyntaxContext};
1313
use syntax::{ast, Parse};
1414
use triomphe::Arc;
1515

@@ -57,9 +57,9 @@ impl Expander {
5757
self.module.krate
5858
}
5959

60-
pub fn syntax_context(&self) -> SyntaxContextId {
60+
pub fn syntax_context(&self) -> SyntaxContext {
6161
// FIXME:
62-
SyntaxContextId::root(Edition::CURRENT)
62+
SyntaxContext::root(Edition::CURRENT)
6363
}
6464

6565
pub fn enter_expand<T: ast::AstNode>(

crates/hir-def/src/expr_store.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,13 @@ pub use self::body::{Body, BodySourceMap};
3737

3838
/// A wrapper around [`span::SyntaxContextId`] that is intended only for comparisons.
3939
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
40-
pub struct HygieneId(span::SyntaxContextId);
40+
pub struct HygieneId(span::SyntaxContext);
4141

4242
impl HygieneId {
4343
// The edition doesn't matter here, we only use this for comparisons and to lookup the macro.
44-
pub const ROOT: Self = Self(span::SyntaxContextId::root(Edition::Edition2015));
44+
pub const ROOT: Self = Self(span::SyntaxContext::root(Edition::Edition2015));
4545

46-
pub fn new(mut ctx: span::SyntaxContextId) -> Self {
46+
pub fn new(mut ctx: span::SyntaxContext) -> Self {
4747
// See `Name` for why we're doing that.
4848
ctx.remove_root_edition();
4949
Self(ctx)

crates/hir-def/src/hir/format_args.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use either::Either;
44
use hir_expand::name::Name;
55
use intern::Symbol;
66
use rustc_parse_format as parse;
7-
use span::SyntaxContextId;
7+
use span::SyntaxContext;
88
use stdx::TupleExt;
99
use syntax::{
1010
ast::{self, IsString},
@@ -176,7 +176,7 @@ pub(crate) fn parse(
176176
is_direct_literal: bool,
177177
mut synth: impl FnMut(Name, Option<TextRange>) -> ExprId,
178178
mut record_usage: impl FnMut(Name, Option<TextRange>),
179-
call_ctx: SyntaxContextId,
179+
call_ctx: SyntaxContext,
180180
) -> FormatArgs {
181181
let Ok(text) = s.value() else {
182182
return FormatArgs {

crates/hir-def/src/item_tree.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ use intern::{Interned, Symbol};
5151
use la_arena::{Arena, Idx, RawIdx};
5252
use rustc_hash::FxHashMap;
5353
use smallvec::SmallVec;
54-
use span::{AstIdNode, Edition, FileAstId, SyntaxContextId};
54+
use span::{AstIdNode, Edition, FileAstId, SyntaxContext};
5555
use stdx::never;
5656
use syntax::{ast, match_ast, SyntaxKind};
5757
use triomphe::Arc;
@@ -1098,7 +1098,7 @@ pub struct MacroCall {
10981098
pub path: Interned<ModPath>,
10991099
pub ast_id: FileAstId<ast::MacroCall>,
11001100
pub expand_to: ExpandTo,
1101-
pub ctxt: SyntaxContextId,
1101+
pub ctxt: SyntaxContext,
11021102
}
11031103

11041104
#[derive(Debug, Clone, Eq, PartialEq)]

crates/hir-def/src/item_tree/lower.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use hir_expand::{
1111
use intern::{sym, Symbol};
1212
use la_arena::Arena;
1313
use rustc_hash::FxHashMap;
14-
use span::{AstIdMap, SyntaxContextId};
14+
use span::{AstIdMap, SyntaxContext};
1515
use stdx::thin_vec::ThinVec;
1616
use syntax::{
1717
ast::{self, HasModuleItem, HasName, HasTypeBounds, IsString},
@@ -968,7 +968,7 @@ impl UseTreeLowering<'_> {
968968
fn lower_use_tree(
969969
&mut self,
970970
tree: ast::UseTree,
971-
span_for_range: &mut dyn FnMut(::tt::TextRange) -> SyntaxContextId,
971+
span_for_range: &mut dyn FnMut(::tt::TextRange) -> SyntaxContext,
972972
) -> Option<UseTree> {
973973
if let Some(use_tree_list) = tree.use_tree_list() {
974974
let prefix = match tree.path() {
@@ -1035,7 +1035,7 @@ impl UseTreeLowering<'_> {
10351035
pub(crate) fn lower_use_tree(
10361036
db: &dyn DefDatabase,
10371037
tree: ast::UseTree,
1038-
span_for_range: &mut dyn FnMut(::tt::TextRange) -> SyntaxContextId,
1038+
span_for_range: &mut dyn FnMut(::tt::TextRange) -> SyntaxContext,
10391039
) -> Option<(UseTree, Arena<ast::UseTree>)> {
10401040
let mut lowering = UseTreeLowering { db, mapping: Arena::new() };
10411041
let tree = lowering.lower_use_tree(tree, span_for_range)?;

crates/hir-def/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ use hir_expand::{
8585
use item_tree::ExternBlock;
8686
use la_arena::Idx;
8787
use nameres::DefMap;
88-
use span::{AstIdNode, Edition, FileAstId, SyntaxContextId};
88+
use span::{AstIdNode, Edition, FileAstId, SyntaxContext};
8989
use stdx::impl_from;
9090
use syntax::{ast, AstNode};
9191

@@ -1451,7 +1451,7 @@ impl<T: AstIdNode> AstIdWithPath<T> {
14511451
fn macro_call_as_call_id(
14521452
db: &dyn ExpandDatabase,
14531453
call: &AstIdWithPath<ast::MacroCall>,
1454-
call_site: SyntaxContextId,
1454+
call_site: SyntaxContext,
14551455
expand_to: ExpandTo,
14561456
krate: Crate,
14571457
resolver: impl Fn(&path::ModPath) -> Option<MacroDefId> + Copy,
@@ -1473,7 +1473,7 @@ fn macro_call_as_call_id_with_eager(
14731473
db: &dyn ExpandDatabase,
14741474
ast_id: AstId<ast::MacroCall>,
14751475
path: &path::ModPath,
1476-
call_site: SyntaxContextId,
1476+
call_site: SyntaxContext,
14771477
expand_to: ExpandTo,
14781478
krate: Crate,
14791479
resolver: impl FnOnce(&path::ModPath) -> Option<MacroDefId>,

crates/hir-def/src/nameres/attr_resolution.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use hir_expand::{
66
inert_attr_macro::find_builtin_attr_idx,
77
MacroCallId, MacroCallKind, MacroDefId,
88
};
9-
use span::SyntaxContextId;
9+
use span::SyntaxContext;
1010
use syntax::ast;
1111
use triomphe::Arc;
1212

@@ -137,7 +137,7 @@ pub(super) fn derive_macro_as_call_id(
137137
item_attr: &AstIdWithPath<ast::Adt>,
138138
derive_attr_index: AttrId,
139139
derive_pos: u32,
140-
call_site: SyntaxContextId,
140+
call_site: SyntaxContext,
141141
krate: Crate,
142142
resolver: impl Fn(&path::ModPath) -> Option<(MacroId, MacroDefId)>,
143143
derive_macro_id: MacroCallId,

crates/hir-def/src/nameres/collector.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use intern::{sym, Interned};
2020
use itertools::{izip, Itertools};
2121
use la_arena::Idx;
2222
use rustc_hash::{FxHashMap, FxHashSet};
23-
use span::{Edition, EditionedFileId, FileAstId, SyntaxContextId};
23+
use span::{Edition, EditionedFileId, FileAstId, SyntaxContext};
2424
use syntax::ast;
2525
use triomphe::Arc;
2626

@@ -192,13 +192,13 @@ enum MacroDirectiveKind {
192192
FnLike {
193193
ast_id: AstIdWithPath<ast::MacroCall>,
194194
expand_to: ExpandTo,
195-
ctxt: SyntaxContextId,
195+
ctxt: SyntaxContext,
196196
},
197197
Derive {
198198
ast_id: AstIdWithPath<ast::Adt>,
199199
derive_attr: AttrId,
200200
derive_pos: usize,
201-
ctxt: SyntaxContextId,
201+
ctxt: SyntaxContext,
202202
/// The "parent" macro it is resolved to.
203203
derive_macro_id: MacroCallId,
204204
},

crates/hir-def/src/resolver.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use intern::{sym, Symbol};
77
use itertools::Itertools as _;
88
use rustc_hash::FxHashSet;
99
use smallvec::{smallvec, SmallVec};
10-
use span::SyntaxContextId;
10+
use span::SyntaxContext;
1111
use triomphe::Arc;
1212

1313
use crate::{
@@ -903,7 +903,7 @@ impl Resolver {
903903
fn handle_macro_def_scope(
904904
db: &dyn DefDatabase,
905905
hygiene_id: &mut HygieneId,
906-
hygiene_info: &mut Option<(SyntaxContextId, MacroDefId)>,
906+
hygiene_info: &mut Option<(SyntaxContext, MacroDefId)>,
907907
macro_id: &MacroDefId,
908908
) {
909909
if let Some((parent_ctx, label_macro_id)) = hygiene_info {
@@ -924,7 +924,7 @@ fn handle_macro_def_scope(
924924
fn hygiene_info(
925925
db: &dyn DefDatabase,
926926
hygiene_id: HygieneId,
927-
) -> Option<(SyntaxContextId, MacroDefId)> {
927+
) -> Option<(SyntaxContext, MacroDefId)> {
928928
if !hygiene_id.is_root() {
929929
let ctx = hygiene_id.lookup();
930930
ctx.outer_expn(db).map(|expansion| {

crates/hir-def/src/visibility.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use std::iter;
44

55
use intern::Interned;
66
use la_arena::ArenaMap;
7-
use span::SyntaxContextId;
7+
use span::SyntaxContext;
88
use syntax::ast;
99
use triomphe::Arc;
1010

@@ -37,7 +37,7 @@ impl RawVisibility {
3737
pub(crate) fn from_ast(
3838
db: &dyn DefDatabase,
3939
node: Option<ast::Visibility>,
40-
span_for_range: &mut dyn FnMut(::tt::TextRange) -> SyntaxContextId,
40+
span_for_range: &mut dyn FnMut(::tt::TextRange) -> SyntaxContext,
4141
) -> RawVisibility {
4242
let node = match node {
4343
None => return RawVisibility::private(),
@@ -49,7 +49,7 @@ impl RawVisibility {
4949
fn from_ast_with_span_map(
5050
db: &dyn DefDatabase,
5151
node: ast::Visibility,
52-
span_for_range: &mut dyn FnMut(::tt::TextRange) -> SyntaxContextId,
52+
span_for_range: &mut dyn FnMut(::tt::TextRange) -> SyntaxContext,
5353
) -> RawVisibility {
5454
let path = match node.kind() {
5555
ast::VisibilityKind::In(path) => {

crates/hir-expand/src/attrs.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use intern::{sym, Interned, Symbol};
88

99
use mbe::{DelimiterKind, Punct};
1010
use smallvec::{smallvec, SmallVec};
11-
use span::{Span, SyntaxContextId};
11+
use span::{Span, SyntaxContext};
1212
use syntax::unescape;
1313
use syntax::{ast, match_ast, AstNode, AstToken, SyntaxNode};
1414
use syntax_bridge::{desugar_doc_comment_text, syntax_node_to_token_tree, DocCommentDesugarMode};
@@ -210,7 +210,7 @@ pub struct Attr {
210210
pub id: AttrId,
211211
pub path: Interned<ModPath>,
212212
pub input: Option<Box<AttrInput>>,
213-
pub ctxt: SyntaxContextId,
213+
pub ctxt: SyntaxContext,
214214
}
215215

216216
#[derive(Debug, Clone, PartialEq, Eq, Hash)]

crates/hir-expand/src/builtin/derive_macro.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use intern::sym;
44
use itertools::{izip, Itertools};
55
use parser::SyntaxKind;
66
use rustc_hash::FxHashSet;
7-
use span::{Edition, MacroCallId, Span, SyntaxContextId};
7+
use span::{Edition, MacroCallId, Span, SyntaxContext};
88
use stdx::never;
99
use syntax_bridge::DocCommentDesugarMode;
1010
use tracing::debug;
@@ -237,7 +237,7 @@ fn parse_adt(
237237

238238
fn parse_adt_from_syntax(
239239
adt: &ast::Adt,
240-
tm: &span::SpanMap<SyntaxContextId>,
240+
tm: &span::SpanMap<SyntaxContext>,
241241
call_site: Span,
242242
) -> Result<BasicAdtInfo, ExpandError> {
243243
let (name, generic_param_list, where_clause, shape) = match &adt {
@@ -389,7 +389,7 @@ fn to_adt_syntax(
389389
db: &dyn ExpandDatabase,
390390
tt: &tt::TopSubtree,
391391
call_site: Span,
392-
) -> Result<(ast::Adt, span::SpanMap<SyntaxContextId>), ExpandError> {
392+
) -> Result<(ast::Adt, span::SpanMap<SyntaxContext>), ExpandError> {
393393
let (parsed, tm) = crate::db::token_tree_to_syntax_node(
394394
db,
395395
tt,

crates/hir-expand/src/builtin/quote.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ mod tests {
226226
use ::tt::IdentIsRaw;
227227
use expect_test::expect;
228228
use intern::Symbol;
229-
use span::{Edition, SpanAnchor, SyntaxContextId, ROOT_ERASED_FILE_AST_ID};
229+
use span::{Edition, SpanAnchor, SyntaxContext, ROOT_ERASED_FILE_AST_ID};
230230
use syntax::{TextRange, TextSize};
231231

232232
use super::quote;
@@ -240,7 +240,7 @@ mod tests {
240240
),
241241
ast_id: ROOT_ERASED_FILE_AST_ID,
242242
},
243-
ctx: SyntaxContextId::root(Edition::CURRENT),
243+
ctx: SyntaxContext::root(Edition::CURRENT),
244244
};
245245

246246
#[test]

crates/hir-expand/src/db.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use rustc_hash::FxHashSet;
77
use salsa::plumbing::AsId;
88
use span::{
99
AstIdMap, Edition, EditionedFileId, HirFileId, HirFileIdRepr, MacroCallId, MacroFileId, Span,
10-
SyntaxContextId,
10+
SyntaxContext,
1111
};
1212
use syntax::{ast, AstNode, Parse, SyntaxElement, SyntaxError, SyntaxNode, SyntaxToken, T};
1313
use syntax_bridge::{syntax_node_to_token_tree, DocCommentDesugarMode};
@@ -97,10 +97,6 @@ pub trait ExpandDatabase: RootQueryDb {
9797
#[salsa::transparent]
9898
fn lookup_intern_macro_call(&self, macro_call: MacroCallId) -> MacroCallLoc;
9999

100-
#[salsa::transparent]
101-
#[salsa::invoke(crate::hygiene::dump_syntax_contexts)]
102-
fn dump_syntax_contexts(&self) -> String;
103-
104100
/// Lowers syntactic macro call to a token tree representation. That's a firewall
105101
/// query, only typing in the macro call itself changes the returned
106102
/// subtree.
@@ -149,7 +145,7 @@ pub trait ExpandDatabase: RootQueryDb {
149145
) -> Option<Arc<ExpandResult<Arc<[SyntaxError]>>>>;
150146

151147
#[salsa::transparent]
152-
fn syntax_context(&self, file: HirFileId, edition: Edition) -> SyntaxContextId;
148+
fn syntax_context(&self, file: HirFileId, edition: Edition) -> SyntaxContext;
153149
}
154150

155151
#[salsa::interned(no_lifetime, id = span::MacroCallId)]
@@ -165,14 +161,14 @@ fn lookup_intern_macro_call(db: &dyn ExpandDatabase, macro_call: MacroCallId) ->
165161
MacroCallWrapper::ingredient(db).data(db.as_dyn_database(), macro_call.as_id()).0.clone()
166162
}
167163

168-
#[salsa::interned(no_lifetime, id = span::SyntaxContextId)]
164+
#[salsa::interned(no_lifetime, id = span::SyntaxContext)]
169165
pub struct SyntaxContextWrapper {
170-
pub data: SyntaxContextId,
166+
pub data: SyntaxContext,
171167
}
172168

173-
fn syntax_context(db: &dyn ExpandDatabase, file: HirFileId, edition: Edition) -> SyntaxContextId {
169+
fn syntax_context(db: &dyn ExpandDatabase, file: HirFileId, edition: Edition) -> SyntaxContext {
174170
match file.repr() {
175-
HirFileIdRepr::FileId(_) => SyntaxContextId::root(edition),
171+
HirFileIdRepr::FileId(_) => SyntaxContext::root(edition),
176172
HirFileIdRepr::MacroFile(m) => {
177173
let kind = db.lookup_intern_macro_call(m.macro_call_id).kind;
178174
db.macro_arg_considering_derives(m.macro_call_id, &kind).2.ctx

crates/hir-expand/src/declarative.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
use base_db::Crate;
44
use intern::sym;
5-
use span::{Edition, HirFileIdRepr, MacroCallId, Span, SyntaxContextId};
5+
use span::{Edition, HirFileIdRepr, MacroCallId, Span, SyntaxContext};
66
use stdx::TupleExt;
77
use syntax::{ast, AstNode};
88
use syntax_bridge::DocCommentDesugarMode;
@@ -100,7 +100,7 @@ impl DeclarativeMacroExpander {
100100
_ => None,
101101
}
102102
};
103-
let ctx_edition = |ctx: SyntaxContextId| {
103+
let ctx_edition = |ctx: SyntaxContext| {
104104
if ctx.is_root() {
105105
def_crate.data(db).edition
106106
} else {
@@ -161,7 +161,7 @@ impl DeclarativeMacroExpander {
161161
};
162162
let edition = ctx_edition(match id.file_id.repr() {
163163
HirFileIdRepr::MacroFile(macro_file) => macro_file.macro_call_id.lookup(db).ctxt,
164-
HirFileIdRepr::FileId(file) => SyntaxContextId::root(file.edition()),
164+
HirFileIdRepr::FileId(file) => SyntaxContext::root(file.edition()),
165165
});
166166
Arc::new(DeclarativeMacroExpander { mac, transparency, edition })
167167
}

crates/hir-expand/src/eager.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
//!
2020
//! See the full discussion : <https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/Eager.20expansion.20of.20built-in.20macros>
2121
use base_db::Crate;
22-
use span::SyntaxContextId;
22+
use span::SyntaxContext;
2323
use syntax::{ted, Parse, SyntaxElement, SyntaxNode, TextSize, WalkEvent};
2424
use syntax_bridge::DocCommentDesugarMode;
2525
use triomphe::Arc;
@@ -38,7 +38,7 @@ pub fn expand_eager_macro_input(
3838
macro_call: &ast::MacroCall,
3939
ast_id: AstId<ast::MacroCall>,
4040
def: MacroDefId,
41-
call_site: SyntaxContextId,
41+
call_site: SyntaxContext,
4242
resolver: &dyn Fn(&ModPath) -> Option<MacroDefId>,
4343
) -> ExpandResult<Option<MacroCallId>> {
4444
let expand_to = ExpandTo::from_call_site(macro_call);
@@ -116,7 +116,7 @@ fn lazy_expand(
116116
macro_call: &ast::MacroCall,
117117
ast_id: AstId<ast::MacroCall>,
118118
krate: Crate,
119-
call_site: SyntaxContextId,
119+
call_site: SyntaxContext,
120120
) -> ExpandResult<(InFile<Parse<SyntaxNode>>, Arc<ExpansionSpanMap>)> {
121121
let expand_to = ExpandTo::from_call_site(macro_call);
122122
let id = def.make_call(
@@ -138,7 +138,7 @@ fn eager_macro_recur(
138138
mut offset: TextSize,
139139
curr: InFile<SyntaxNode>,
140140
krate: Crate,
141-
call_site: SyntaxContextId,
141+
call_site: SyntaxContext,
142142
macro_resolver: &dyn Fn(&ModPath) -> Option<MacroDefId>,
143143
) -> ExpandResult<Option<(SyntaxNode, TextSize)>> {
144144
let original = curr.value.clone_for_update();

0 commit comments

Comments
 (0)