Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit f211a40

Browse files
committed
Remove SyntaxContext trait
1 parent 7b80455 commit f211a40

File tree

3 files changed

+10
-40
lines changed

3 files changed

+10
-40
lines changed

crates/mbe/src/syntax_bridge.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use syntax::{
1111
};
1212
use tt::{
1313
buffer::{Cursor, TokenBuffer},
14-
Span, SyntaxContext,
14+
Span,
1515
};
1616

1717
use crate::{to_parser_input::to_parser_input, tt_iter::TtIter};
@@ -37,7 +37,6 @@ impl<S: Span, SM: SpanMapper<S>> SpanMapper<S> for &SM {
3737

3838
/// Dummy things for testing where spans don't matter.
3939
pub(crate) mod dummy_test_span_utils {
40-
use tt::SyntaxContext;
4140

4241
use super::*;
4342

@@ -53,9 +52,6 @@ pub(crate) mod dummy_test_span_utils {
5352

5453
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
5554
pub struct DummyTestSyntaxContext;
56-
impl SyntaxContext for DummyTestSyntaxContext {
57-
const DUMMY: Self = DummyTestSyntaxContext;
58-
}
5955

6056
pub struct DummyTestSpanMap;
6157

@@ -82,7 +78,7 @@ pub fn syntax_node_to_token_tree<Ctx, SpanMap>(
8278
) -> tt::Subtree<SpanData<Ctx>>
8379
where
8480
SpanData<Ctx>: Span,
85-
Ctx: SyntaxContext,
81+
Ctx: Copy,
8682
SpanMap: SpanMapper<SpanData<Ctx>>,
8783
{
8884
let mut c = Converter::new(node, map, Default::default(), Default::default(), span);
@@ -102,7 +98,7 @@ pub fn syntax_node_to_token_tree_modified<Ctx, SpanMap>(
10298
where
10399
SpanMap: SpanMapper<SpanData<Ctx>>,
104100
SpanData<Ctx>: Span,
105-
Ctx: SyntaxContext,
101+
Ctx: Copy,
106102
{
107103
let mut c = Converter::new(node, map, append, remove, call_site);
108104
convert_tokens(&mut c)
@@ -128,7 +124,7 @@ pub fn token_tree_to_syntax_node<Ctx>(
128124
) -> (Parse<SyntaxNode>, SpanMap<SpanData<Ctx>>)
129125
where
130126
SpanData<Ctx>: Span,
131-
Ctx: SyntaxContext,
127+
Ctx: Copy,
132128
{
133129
let buffer = match tt {
134130
tt::Subtree {
@@ -165,7 +161,7 @@ pub fn parse_to_token_tree<Ctx>(
165161
) -> Option<tt::Subtree<SpanData<Ctx>>>
166162
where
167163
SpanData<Ctx>: Span,
168-
Ctx: SyntaxContext,
164+
Ctx: Copy,
169165
{
170166
let lexed = parser::LexedStr::new(text);
171167
if lexed.errors().next().is_some() {
@@ -531,7 +527,7 @@ impl<S: Span> SrcToken<StaticRawConverter<'_, S>, S> for usize {
531527
}
532528
}
533529

534-
impl<Ctx: SyntaxContext> TokenConverter<SpanData<Ctx>> for RawConverter<'_, Ctx>
530+
impl<Ctx: Copy> TokenConverter<SpanData<Ctx>> for RawConverter<'_, Ctx>
535531
where
536532
SpanData<Ctx>: Span,
537533
{

crates/proc-macro-api/src/msg/flat.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,7 @@ impl std::fmt::Debug for TokenId {
5454
}
5555
}
5656

57-
impl tt::Span for TokenId {
58-
const DUMMY: Self = TokenId(!0);
59-
}
57+
impl tt::Span for TokenId {}
6058

6159
#[derive(Serialize, Deserialize, Debug)]
6260
pub struct FlatTree {

crates/tt/src/lib.rs

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -11,34 +11,10 @@ use stdx::impl_from;
1111
pub use smol_str::SmolStr;
1212
pub use text_size::{TextRange, TextSize};
1313

14-
pub trait Span: std::fmt::Debug + Copy + Sized + Eq {
15-
// FIXME: Should not exist. Dummy spans will always be wrong if they leak somewhere. Instead,
16-
// the call site or def site spans should be used in relevant places, its just that we don't
17-
// expose those everywhere in the yet.
18-
#[deprecated = "dummy spans will panic if surfaced incorrectly, as such they should be replaced appropriately"]
19-
const DUMMY: Self;
20-
}
21-
22-
pub trait SyntaxContext: std::fmt::Debug + Copy + Sized + Eq {
23-
#[deprecated = "dummy spans will panic if surfaced incorrectly, as such they should be replaced appropriately"]
24-
const DUMMY: Self;
25-
}
26-
27-
impl<Ctx: SyntaxContext> Span for span::SpanData<Ctx> {
28-
#[allow(deprecated)]
29-
const DUMMY: Self = span::SpanData {
30-
range: TextRange::empty(TextSize::new(0)),
31-
anchor: span::SpanAnchor {
32-
file_id: span::FileId::BOGUS,
33-
ast_id: span::ROOT_ERASED_FILE_AST_ID,
34-
},
35-
ctx: Ctx::DUMMY,
36-
};
37-
}
14+
pub trait Span: std::fmt::Debug + Copy + Sized + Eq {}
3815

39-
impl SyntaxContext for span::SyntaxContextId {
40-
const DUMMY: Self = Self::ROOT;
41-
}
16+
impl<Ctx> Span for span::SpanData<Ctx> where span::SpanData<Ctx>: std::fmt::Debug + Copy + Sized + Eq
17+
{}
4218

4319
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
4420
pub enum TokenTree<S> {

0 commit comments

Comments
 (0)