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

Commit bdb7ae5

Browse files
committed
Rename syntax_node_to_token_tree_censored
1 parent ecf3cff commit bdb7ae5

File tree

4 files changed

+10
-9
lines changed

4 files changed

+10
-9
lines changed

crates/hir_expand/src/db.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,11 @@ pub fn expand_speculative(
151151
let censor = censor_for_macro_input(&loc, &speculative_args);
152152
let mut fixups = fixup::fixup_syntax(&speculative_args);
153153
fixups.replace.extend(censor.into_iter().map(|node| (node, Vec::new())));
154-
let (mut tt, spec_args_tmap) =
155-
mbe::syntax_node_to_token_tree_censored(&speculative_args, fixups.replace, fixups.append);
154+
let (mut tt, spec_args_tmap) = mbe::syntax_node_to_token_tree_with_modifications(
155+
&speculative_args,
156+
fixups.replace,
157+
fixups.append,
158+
);
156159

157160
let (attr_arg, token_id) = match loc.kind {
158161
MacroCallKind::Attr { invoc_attr_index, .. } => {
@@ -303,11 +306,10 @@ fn macro_arg(
303306

304307
let node = SyntaxNode::new_root(arg);
305308
let censor = censor_for_macro_input(&loc, &node);
306-
// TODO only fixup for attribute macro input
307309
let mut fixups = fixup::fixup_syntax(&node);
308310
fixups.replace.extend(censor.into_iter().map(|node| (node, Vec::new())));
309311
let (mut tt, tmap) =
310-
mbe::syntax_node_to_token_tree_censored(&node, fixups.replace, fixups.append);
312+
mbe::syntax_node_to_token_tree_with_modifications(&node, fixups.replace, fixups.append);
311313

312314
if loc.def.is_proc_macro() {
313315
// proc macros expect their inputs without parentheses, MBEs expect it with them included

crates/hir_expand/src/fixup.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ mod tests {
123123
let parsed = syntax::SourceFile::parse(ra_fixture);
124124
eprintln!("parse: {:#?}", parsed.syntax_node());
125125
let fixups = super::fixup_syntax(&parsed.syntax_node());
126-
let (mut tt, tmap) = mbe::syntax_node_to_token_tree_censored(
126+
let (mut tt, tmap) = mbe::syntax_node_to_token_tree_with_modifications(
127127
&parsed.syntax_node(),
128128
fixups.replace,
129129
fixups.append,

crates/mbe/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ pub use tt::{Delimiter, DelimiterKind, Punct};
3030
pub use crate::{
3131
syntax_bridge::{
3232
parse_exprs_with_sep, parse_to_token_tree, syntax_node_to_token_tree,
33-
syntax_node_to_token_tree_censored, token_tree_to_syntax_node, SyntheticToken,
33+
syntax_node_to_token_tree_with_modifications, token_tree_to_syntax_node, SyntheticToken,
3434
SyntheticTokenId,
3535
},
3636
token_map::TokenMap,

crates/mbe/src/syntax_bridge.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,12 @@ use crate::{to_parser_input::to_parser_input, tt_iter::TtIter, TokenMap};
1515
/// Convert the syntax node to a `TokenTree` (what macro
1616
/// will consume).
1717
pub fn syntax_node_to_token_tree(node: &SyntaxNode) -> (tt::Subtree, TokenMap) {
18-
syntax_node_to_token_tree_censored(node, Default::default(), Default::default())
18+
syntax_node_to_token_tree_with_modifications(node, Default::default(), Default::default())
1919
}
2020

21-
// TODO rename
2221
/// Convert the syntax node to a `TokenTree` (what macro will consume)
2322
/// with the censored range excluded.
24-
pub fn syntax_node_to_token_tree_censored(
23+
pub fn syntax_node_to_token_tree_with_modifications(
2524
node: &SyntaxNode,
2625
replace: FxHashMap<SyntaxNode, Vec<SyntheticToken>>,
2726
append: FxHashMap<SyntaxNode, Vec<SyntheticToken>>,

0 commit comments

Comments
 (0)