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

Commit bde036b

Browse files
author
Jonas Schievink
committed
Revert "Fix conversion of float literals in TtTreeSink"
This reverts commit 43a066c.
1 parent 4fcdb96 commit bde036b

File tree

2 files changed

+0
-54
lines changed

2 files changed

+0
-54
lines changed

crates/hir-def/src/macro_expansion_tests/mbe/tt_conversion.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,22 +183,18 @@ fn float_literal_in_tt() {
183183
macro_rules! constant {
184184
($( $ret:expr; )*) => {};
185185
}
186-
187186
macro_rules! float_const_impl {
188187
() => ( constant!(0.3; 3.3;); );
189188
}
190-
191189
float_const_impl! {}
192190
"#,
193191
expect![[r#"
194192
macro_rules! constant {
195193
($( $ret:expr; )*) => {};
196194
}
197-
198195
macro_rules! float_const_impl {
199196
() => ( constant!(0.3; 3.3;); );
200197
}
201-
202198
constant!(0.3;
203199
3.3;
204200
);

crates/mbe/src/syntax_bridge.rs

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -740,7 +740,6 @@ struct TtTreeSink<'a> {
740740
text_pos: TextSize,
741741
inner: SyntaxTreeBuilder,
742742
token_map: TokenMap,
743-
remaining_float_lit_text: String,
744743
}
745744

746745
impl<'a> TtTreeSink<'a> {
@@ -752,7 +751,6 @@ impl<'a> TtTreeSink<'a> {
752751
text_pos: 0.into(),
753752
inner: SyntaxTreeBuilder::default(),
754753
token_map: TokenMap::default(),
755-
remaining_float_lit_text: String::new(),
756754
}
757755
}
758756

@@ -779,54 +777,6 @@ impl<'a> TtTreeSink<'a> {
779777
n_tokens = 2;
780778
}
781779

782-
// We need to split a float `tt::Literal` into up to 3 tokens consumed by the parser.
783-
match self.cursor.token_tree() {
784-
Some(tt::buffer::TokenTreeRef::Subtree(sub, _)) if sub.delimiter.is_none() => {
785-
self.cursor = self.cursor.subtree().unwrap()
786-
}
787-
_ => {}
788-
}
789-
let literal = match self.cursor.token_tree() {
790-
Some(tt::buffer::TokenTreeRef::Leaf(tt::Leaf::Literal(lit), _)) => Some(lit),
791-
_ => None,
792-
};
793-
if matches!(
794-
kind,
795-
FLOAT_NUMBER_PART | FLOAT_NUMBER_START_0 | FLOAT_NUMBER_START_1 | FLOAT_NUMBER_START_2
796-
) {
797-
if self.remaining_float_lit_text.is_empty() {
798-
always!(
799-
literal.is_some(),
800-
"kind={:?}, cursor tt={:?}",
801-
kind,
802-
self.cursor.token_tree()
803-
);
804-
let text = literal.map_or(String::new(), |lit| lit.to_string());
805-
self.cursor = self.cursor.bump();
806-
match text.split_once('.') {
807-
Some((start, end)) => {
808-
self.inner.token(kind, start);
809-
self.remaining_float_lit_text = format!(".{end}");
810-
return;
811-
}
812-
None => {
813-
self.inner.token(kind, &text);
814-
return;
815-
}
816-
}
817-
} else {
818-
self.inner.token(kind, &self.remaining_float_lit_text);
819-
self.remaining_float_lit_text.clear();
820-
return;
821-
}
822-
}
823-
if kind == DOT && !self.remaining_float_lit_text.is_empty() {
824-
always!(self.remaining_float_lit_text.chars().next() == Some('.'));
825-
self.inner.token(kind, ".");
826-
self.remaining_float_lit_text = self.remaining_float_lit_text[1..].to_string();
827-
return;
828-
}
829-
830780
let mut last = self.cursor;
831781
for _ in 0..n_tokens {
832782
let tmp: u8;

0 commit comments

Comments
 (0)