Skip to content

Commit 31f8dc7

Browse files
committed
Bring our TokenTree model closer to rustc's
1 parent 50882fb commit 31f8dc7

File tree

4 files changed

+418
-396
lines changed

4 files changed

+418
-396
lines changed

crates/hir-expand/src/db.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use crate::{
2525
MacroDefId, MacroDefKind, MacroFileId,
2626
};
2727
/// This is just to ensure the types of smart_macro_arg and macro_arg are the same
28-
type MacroArgResult = (Arc<tt::Subtree>, SyntaxFixupUndoInfo, Span);
28+
type MacroArgResult = (Arc<tt::TokenStream>, SyntaxFixupUndoInfo, Span);
2929
/// Total limit on the number of tokens produced by any macro invocation.
3030
///
3131
/// If an invocation produces more tokens than this limit, it will not be stored in the database and

crates/hir-expand/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ pub mod tt {
7070
pub type Punct = ::tt::Punct<Span>;
7171
pub type Ident = ::tt::Ident<Span>;
7272
pub type TokenTree = ::tt::TokenTree<Span>;
73+
pub type TokenStream = ::tt::TokenStream<Span>;
7374
}
7475

7576
#[macro_export]

crates/syntax-bridge/src/lib.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ pub fn syntax_node_to_token_tree<Ctx, SpanMap>(
9999
map: SpanMap,
100100
span: SpanData<Ctx>,
101101
mode: DocCommentDesugarMode,
102-
) -> tt::Subtree<SpanData<Ctx>>
102+
) -> tt::TokenStream<SpanData<Ctx>>
103103
where
104104
SpanData<Ctx>: Copy + fmt::Debug,
105105
SpanMap: SpanMapper<SpanData<Ctx>>,
@@ -114,11 +114,11 @@ where
114114
pub fn syntax_node_to_token_tree_modified<Ctx, SpanMap>(
115115
node: &SyntaxNode,
116116
map: SpanMap,
117-
append: FxHashMap<SyntaxElement, Vec<tt::Leaf<SpanData<Ctx>>>>,
117+
append: FxHashMap<SyntaxElement, Vec<tt::Token<SpanData<Ctx>>>>,
118118
remove: FxHashSet<SyntaxElement>,
119119
call_site: SpanData<Ctx>,
120120
mode: DocCommentDesugarMode,
121-
) -> tt::Subtree<SpanData<Ctx>>
121+
) -> tt::TokenStream<SpanData<Ctx>>
122122
where
123123
SpanMap: SpanMapper<SpanData<Ctx>>,
124124
SpanData<Ctx>: Copy + fmt::Debug,
@@ -139,10 +139,10 @@ where
139139
// * AssocItems(SmallVec<[ast::AssocItem; 1]>)
140140
// * ForeignItems(SmallVec<[ast::ForeignItem; 1]>
141141

142-
/// Converts a [`tt::Subtree`] back to a [`SyntaxNode`].
142+
/// Converts a [`tt::TokenStream`] back to a [`SyntaxNode`].
143143
/// The produced `SpanMap` contains a mapping from the syntax nodes offsets to the subtree's spans.
144144
pub fn token_tree_to_syntax_node<Ctx>(
145-
tt: &tt::Subtree<SpanData<Ctx>>,
145+
tt: &tt::TokenStream<SpanData<Ctx>>,
146146
entry_point: parser::TopEntryPoint,
147147
edition: parser::Edition,
148148
) -> (Parse<SyntaxNode>, SpanMap<Ctx>)

0 commit comments

Comments
 (0)