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

Commit 2287ae2

Browse files
author
Jonas Schievink
committed
Revert "Skip only the tt::Literal when consuming float tokens"
This reverts commit 7db5531.
1 parent bde036b commit 2287ae2

File tree

4 files changed

+25
-41
lines changed

4 files changed

+25
-41
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ macro_rules! f3 { ($i:_) => () }
8080

8181
#[test]
8282
fn test_rustc_issue_57597() {
83-
// <https://github.com/rust-lang/rust/blob/master/src/test/ui/macros/issue-57597.rs>
83+
// <https://github.com/rust-lang/rust/blob/master/src/test/ui/issues/issue-57597.rs>
8484
check(
8585
r#"
8686
macro_rules! m0 { ($($($i:ident)?)+) => {}; }

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

Lines changed: 24 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ macro_rules! m {
3838
let _ = 12E+99_f64;
3939
let _ = "rust1";
4040
let _ = -92;
41-
let _ = -1.3e4f32;
4241
}
4342
}
4443
fn f() {
@@ -53,7 +52,6 @@ macro_rules! m {
5352
let _ = 12E+99_f64;
5453
let _ = "rust1";
5554
let _ = -92;
56-
let _ = -1.3e4f32;
5755
}
5856
}
5957
fn f() {
@@ -62,7 +60,6 @@ fn f() {
6260
let _ = 12E+99_f64;
6361
let _ = "rust1";
6462
let _ = -92;
65-
let _ = -1.3e4f32;
6663
}
6764
"#]],
6865
);
@@ -152,30 +149,6 @@ $ = ();
152149
)
153150
}
154151

155-
#[test]
156-
fn float_literal_in_output() {
157-
check(
158-
r#"
159-
macro_rules! constant {
160-
($e:expr ;) => {$e};
161-
}
162-
163-
const _: () = constant!(0.0;);
164-
const _: () = constant!(0.;);
165-
const _: () = constant!(0e0;);
166-
"#,
167-
expect![[r#"
168-
macro_rules! constant {
169-
($e:expr ;) => {$e};
170-
}
171-
172-
const _: () = 0.0;
173-
const _: () = 0.;
174-
const _: () = 0e0;
175-
"#]],
176-
);
177-
}
178-
179152
#[test]
180153
fn float_literal_in_tt() {
181154
check(
@@ -201,3 +174,27 @@ constant!(0.3;
201174
"#]],
202175
);
203176
}
177+
178+
#[test]
179+
fn float_literal_in_output() {
180+
check(
181+
r#"
182+
macro_rules! constant {
183+
($e:expr ;) => {$e};
184+
}
185+
186+
const _: () = constant!(0.0;);
187+
const _: () = constant!(0.;);
188+
const _: () = constant!(0e0;);
189+
"#,
190+
expect![[r#"
191+
macro_rules! constant {
192+
($e:expr ;) => {$e};
193+
}
194+
195+
const _: () = 0.0;
196+
const _: () = 0.;
197+
const _: () = 0e0;
198+
"#]],
199+
);
200+
}

crates/mbe/src/syntax_bridge.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,13 +266,11 @@ fn convert_tokens<C: TokenConvertor>(conv: &mut C) -> tt::Subtree {
266266
let mut text = token.to_text(conv).to_string();
267267
if kind == FLOAT_NUMBER_START_1 || kind == FLOAT_NUMBER_START_2 {
268268
let (dot, dot_range) = conv.bump().unwrap();
269-
assert_eq!(dot.kind(conv), DOT);
270269
text += &*dot.to_text(conv);
271270
range = TextRange::new(range.start(), dot_range.end());
272271

273272
if kind == FLOAT_NUMBER_START_2 {
274273
let (tail, tail_range) = conv.bump().unwrap();
275-
assert_eq!(tail.kind(conv), FLOAT_NUMBER_PART);
276274
text += &*tail.to_text(conv);
277275
range = TextRange::new(range.start(), tail_range.end());
278276
}

crates/mbe/src/tt_iter.rs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -90,20 +90,9 @@ impl<'a> TtIter<'a> {
9090

9191
let mut cursor = buffer.begin();
9292
let mut error = false;
93-
let mut float_fragments_to_skip = 0;
9493
for step in tree_traversal.iter() {
9594
match step {
9695
parser::Step::Token { kind, mut n_input_tokens } => {
97-
if float_fragments_to_skip > 0 {
98-
float_fragments_to_skip -= 1;
99-
n_input_tokens = 0;
100-
}
101-
match kind {
102-
SyntaxKind::LIFETIME_IDENT => n_input_tokens = 2,
103-
SyntaxKind::FLOAT_NUMBER_START_1 => float_fragments_to_skip = 1,
104-
SyntaxKind::FLOAT_NUMBER_START_2 => float_fragments_to_skip = 2,
105-
_ => {}
106-
}
10796
if kind == SyntaxKind::LIFETIME_IDENT {
10897
n_input_tokens = 2;
10998
}

0 commit comments

Comments
 (0)