This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +25
-41
lines changed
hir-def/src/macro_expansion_tests/mbe Expand file tree Collapse file tree 4 files changed +25
-41
lines changed Original file line number Diff line number Diff line change @@ -80,7 +80,7 @@ macro_rules! f3 { ($i:_) => () }
80
80
81
81
#[ test]
82
82
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>
84
84
check (
85
85
r#"
86
86
macro_rules! m0 { ($($($i:ident)?)+) => {}; }
Original file line number Diff line number Diff line change @@ -38,7 +38,6 @@ macro_rules! m {
38
38
let _ = 12E+99_f64;
39
39
let _ = "rust1";
40
40
let _ = -92;
41
- let _ = -1.3e4f32;
42
41
}
43
42
}
44
43
fn f() {
@@ -53,7 +52,6 @@ macro_rules! m {
53
52
let _ = 12E+99_f64;
54
53
let _ = "rust1";
55
54
let _ = -92;
56
- let _ = -1.3e4f32;
57
55
}
58
56
}
59
57
fn f() {
@@ -62,7 +60,6 @@ fn f() {
62
60
let _ = 12E+99_f64;
63
61
let _ = "rust1";
64
62
let _ = -92;
65
- let _ = -1.3e4f32;
66
63
}
67
64
"# ] ] ,
68
65
) ;
@@ -152,30 +149,6 @@ $ = ();
152
149
)
153
150
}
154
151
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
-
179
152
#[ test]
180
153
fn float_literal_in_tt ( ) {
181
154
check (
@@ -201,3 +174,27 @@ constant!(0.3;
201
174
"# ] ] ,
202
175
) ;
203
176
}
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
+ }
Original file line number Diff line number Diff line change @@ -266,13 +266,11 @@ fn convert_tokens<C: TokenConvertor>(conv: &mut C) -> tt::Subtree {
266
266
let mut text = token. to_text ( conv) . to_string ( ) ;
267
267
if kind == FLOAT_NUMBER_START_1 || kind == FLOAT_NUMBER_START_2 {
268
268
let ( dot, dot_range) = conv. bump ( ) . unwrap ( ) ;
269
- assert_eq ! ( dot. kind( conv) , DOT ) ;
270
269
text += & * dot. to_text ( conv) ;
271
270
range = TextRange :: new ( range. start ( ) , dot_range. end ( ) ) ;
272
271
273
272
if kind == FLOAT_NUMBER_START_2 {
274
273
let ( tail, tail_range) = conv. bump ( ) . unwrap ( ) ;
275
- assert_eq ! ( tail. kind( conv) , FLOAT_NUMBER_PART ) ;
276
274
text += & * tail. to_text ( conv) ;
277
275
range = TextRange :: new ( range. start ( ) , tail_range. end ( ) ) ;
278
276
}
Original file line number Diff line number Diff line change @@ -90,20 +90,9 @@ impl<'a> TtIter<'a> {
90
90
91
91
let mut cursor = buffer. begin ( ) ;
92
92
let mut error = false ;
93
- let mut float_fragments_to_skip = 0 ;
94
93
for step in tree_traversal. iter ( ) {
95
94
match step {
96
95
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
- }
107
96
if kind == SyntaxKind :: LIFETIME_IDENT {
108
97
n_input_tokens = 2 ;
109
98
}
You can’t perform that action at this time.
0 commit comments