Skip to content

Commit 280d8dd

Browse files
committed
Bring our TokenTree model closer to rustc's
1 parent 34d9409 commit 280d8dd

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
@@ -69,6 +69,7 @@ pub mod tt {
6969
pub type Punct = ::tt::Punct<Span>;
7070
pub type Ident = ::tt::Ident<Span>;
7171
pub type TokenTree = ::tt::TokenTree<Span>;
72+
pub type TokenStream = ::tt::TokenStream<Span>;
7273
}
7374

7475
#[macro_export]

crates/syntax-bridge/src/lib.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ pub fn syntax_node_to_token_tree<Ctx, SpanMap>(
9898
map: SpanMap,
9999
span: SpanData<Ctx>,
100100
mode: DocCommentDesugarMode,
101-
) -> tt::Subtree<SpanData<Ctx>>
101+
) -> tt::TokenStream<SpanData<Ctx>>
102102
where
103103
SpanData<Ctx>: Copy + fmt::Debug,
104104
SpanMap: SpanMapper<SpanData<Ctx>>,
@@ -113,11 +113,11 @@ where
113113
pub fn syntax_node_to_token_tree_modified<Ctx, SpanMap>(
114114
node: &SyntaxNode,
115115
map: SpanMap,
116-
append: FxHashMap<SyntaxElement, Vec<tt::Leaf<SpanData<Ctx>>>>,
116+
append: FxHashMap<SyntaxElement, Vec<tt::Token<SpanData<Ctx>>>>,
117117
remove: FxHashSet<SyntaxElement>,
118118
call_site: SpanData<Ctx>,
119119
mode: DocCommentDesugarMode,
120-
) -> tt::Subtree<SpanData<Ctx>>
120+
) -> tt::TokenStream<SpanData<Ctx>>
121121
where
122122
SpanMap: SpanMapper<SpanData<Ctx>>,
123123
SpanData<Ctx>: Copy + fmt::Debug,
@@ -138,10 +138,10 @@ where
138138
// * AssocItems(SmallVec<[ast::AssocItem; 1]>)
139139
// * ForeignItems(SmallVec<[ast::ForeignItem; 1]>
140140

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

0 commit comments

Comments
 (0)