Skip to content

Commit 840c8d3

Browse files
committed
Use LitKind::Err for floats with unsupported bases.
This slightly changes error messages in `float-field.rs`, but nothing of real importance.
1 parent 7976609 commit 840c8d3

File tree

3 files changed

+77
-67
lines changed

3 files changed

+77
-67
lines changed

compiler/rustc_parse/src/lexer/mod.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,9 @@ impl<'sess, 'src> StringReader<'sess, 'src> {
515515
};
516516
if let Some(base) = base {
517517
let span = self.mk_sp(start, end);
518-
self.dcx().emit_err(errors::FloatLiteralUnsupportedBase { span, base });
518+
let guar =
519+
self.dcx().emit_err(errors::FloatLiteralUnsupportedBase { span, base });
520+
kind = token::Err(guar)
519521
}
520522
(kind, self.symbol_from_to(start, end))
521523
}

tests/ui/parser/float-field.rs

+9-7
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,17 @@ fn main() {
3333

3434
{ s.0x1e1; } //~ ERROR no field `0x1e1` on type `S`
3535

36-
{ s.0x1.; } //~ ERROR no field `0x1` on type `S`
37-
//~| ERROR hexadecimal float literal is not supported
38-
//~| ERROR unexpected token: `;`
36+
{ s.0x1.; } //~ ERROR hexadecimal float literal is not supported
37+
//~| ERROR unexpected token: `0x1.`
38+
//~| ERROR expected one of `.`, `;`, `?`, `}`, or an operator, found `0x1.`
3939

40-
{ s.0x1.1; } //~ ERROR no field `0x1` on type `S`
41-
//~| ERROR hexadecimal float literal is not supported
40+
{ s.0x1.1; } //~ ERROR hexadecimal float literal is not supported
41+
//~| ERROR unexpected token: `0x1.1`
42+
//~| expected one of `.`, `;`, `?`, `}`, or an operator, found `0x1.1`
4243

43-
{ s.0x1.1e1; } //~ ERROR no field `0x1` on type `S`
44-
//~| ERROR hexadecimal float literal is not supported
44+
{ s.0x1.1e1; } //~ ERROR hexadecimal float literal is not supported
45+
//~| ERROR unexpected token: `0x1.1e1`
46+
//~| expected one of `.`, `;`, `?`, `}`, or an operator, found `0x1.1e1`
4547

4648
{ s.0x1e+; } //~ ERROR expected expression, found `;`
4749

tests/ui/parser/float-field.stderr

+65-59
Original file line numberDiff line numberDiff line change
@@ -23,31 +23,31 @@ LL | { s.0x1.1; }
2323
| ^^^^^
2424

2525
error: hexadecimal float literal is not supported
26-
--> $DIR/float-field.rs:43:9
26+
--> $DIR/float-field.rs:44:9
2727
|
2828
LL | { s.0x1.1e1; }
2929
| ^^^^^^^
3030

3131
error: hexadecimal float literal is not supported
32-
--> $DIR/float-field.rs:54:9
32+
--> $DIR/float-field.rs:56:9
3333
|
3434
LL | { s.0x1.1e+1; }
3535
| ^^^^^^^^
3636

3737
error: hexadecimal float literal is not supported
38-
--> $DIR/float-field.rs:58:9
38+
--> $DIR/float-field.rs:60:9
3939
|
4040
LL | { s.0x1.1e-1; }
4141
| ^^^^^^^^
4242

4343
error: expected at least one digit in exponent
44-
--> $DIR/float-field.rs:72:9
44+
--> $DIR/float-field.rs:74:9
4545
|
4646
LL | { s.1e+f32; }
4747
| ^^^^^^
4848

4949
error: expected at least one digit in exponent
50-
--> $DIR/float-field.rs:76:9
50+
--> $DIR/float-field.rs:78:9
5151
|
5252
LL | { s.1e-f32; }
5353
| ^^^^^^
@@ -130,134 +130,164 @@ error: expected one of `.`, `;`, `?`, `}`, or an operator, found `1.1e-1`
130130
LL | { s.1.1e-1; }
131131
| ^^^^^^ expected one of `.`, `;`, `?`, `}`, or an operator
132132

133-
error: unexpected token: `;`
134-
--> $DIR/float-field.rs:36:13
133+
error: unexpected token: `0x1.`
134+
--> $DIR/float-field.rs:36:9
135+
|
136+
LL | { s.0x1.; }
137+
| ^^^^
138+
139+
error: expected one of `.`, `;`, `?`, `}`, or an operator, found `0x1.`
140+
--> $DIR/float-field.rs:36:9
135141
|
136142
LL | { s.0x1.; }
137-
| ^
143+
| ^^^^ expected one of `.`, `;`, `?`, `}`, or an operator
144+
145+
error: unexpected token: `0x1.1`
146+
--> $DIR/float-field.rs:40:9
147+
|
148+
LL | { s.0x1.1; }
149+
| ^^^^^
150+
151+
error: expected one of `.`, `;`, `?`, `}`, or an operator, found `0x1.1`
152+
--> $DIR/float-field.rs:40:9
153+
|
154+
LL | { s.0x1.1; }
155+
| ^^^^^ expected one of `.`, `;`, `?`, `}`, or an operator
156+
157+
error: unexpected token: `0x1.1e1`
158+
--> $DIR/float-field.rs:44:9
159+
|
160+
LL | { s.0x1.1e1; }
161+
| ^^^^^^^
162+
163+
error: expected one of `.`, `;`, `?`, `}`, or an operator, found `0x1.1e1`
164+
--> $DIR/float-field.rs:44:9
165+
|
166+
LL | { s.0x1.1e1; }
167+
| ^^^^^^^ expected one of `.`, `;`, `?`, `}`, or an operator
138168

139169
error: expected expression, found `;`
140-
--> $DIR/float-field.rs:46:14
170+
--> $DIR/float-field.rs:48:14
141171
|
142172
LL | { s.0x1e+; }
143173
| ^ expected expression
144174

145175
error: expected expression, found `;`
146-
--> $DIR/float-field.rs:48:14
176+
--> $DIR/float-field.rs:50:14
147177
|
148178
LL | { s.0x1e-; }
149179
| ^ expected expression
150180

151181
error: unexpected token: `0x1.1e+1`
152-
--> $DIR/float-field.rs:54:9
182+
--> $DIR/float-field.rs:56:9
153183
|
154184
LL | { s.0x1.1e+1; }
155185
| ^^^^^^^^
156186

157187
error: expected one of `.`, `;`, `?`, `}`, or an operator, found `0x1.1e+1`
158-
--> $DIR/float-field.rs:54:9
188+
--> $DIR/float-field.rs:56:9
159189
|
160190
LL | { s.0x1.1e+1; }
161191
| ^^^^^^^^ expected one of `.`, `;`, `?`, `}`, or an operator
162192

163193
error: unexpected token: `0x1.1e-1`
164-
--> $DIR/float-field.rs:58:9
194+
--> $DIR/float-field.rs:60:9
165195
|
166196
LL | { s.0x1.1e-1; }
167197
| ^^^^^^^^
168198

169199
error: expected one of `.`, `;`, `?`, `}`, or an operator, found `0x1.1e-1`
170-
--> $DIR/float-field.rs:58:9
200+
--> $DIR/float-field.rs:60:9
171201
|
172202
LL | { s.0x1.1e-1; }
173203
| ^^^^^^^^ expected one of `.`, `;`, `?`, `}`, or an operator
174204

175205
error: suffixes on a tuple index are invalid
176-
--> $DIR/float-field.rs:62:9
206+
--> $DIR/float-field.rs:64:9
177207
|
178208
LL | { s.1e1f32; }
179209
| ^^^^^^ invalid suffix `f32`
180210

181211
error: suffixes on a tuple index are invalid
182-
--> $DIR/float-field.rs:67:9
212+
--> $DIR/float-field.rs:69:9
183213
|
184214
LL | { s.1.1f32; }
185215
| ^^^^^^ invalid suffix `f32`
186216

187217
error: suffixes on a tuple index are invalid
188-
--> $DIR/float-field.rs:69:9
218+
--> $DIR/float-field.rs:71:9
189219
|
190220
LL | { s.1.1e1f32; }
191221
| ^^^^^^^^ invalid suffix `f32`
192222

193223
error: unexpected token: `1e+f32`
194-
--> $DIR/float-field.rs:72:9
224+
--> $DIR/float-field.rs:74:9
195225
|
196226
LL | { s.1e+f32; }
197227
| ^^^^^^
198228

199229
error: expected one of `.`, `;`, `?`, `}`, or an operator, found `1e+f32`
200-
--> $DIR/float-field.rs:72:9
230+
--> $DIR/float-field.rs:74:9
201231
|
202232
LL | { s.1e+f32; }
203233
| ^^^^^^ expected one of `.`, `;`, `?`, `}`, or an operator
204234

205235
error: unexpected token: `1e-f32`
206-
--> $DIR/float-field.rs:76:9
236+
--> $DIR/float-field.rs:78:9
207237
|
208238
LL | { s.1e-f32; }
209239
| ^^^^^^
210240

211241
error: expected one of `.`, `;`, `?`, `}`, or an operator, found `1e-f32`
212-
--> $DIR/float-field.rs:76:9
242+
--> $DIR/float-field.rs:78:9
213243
|
214244
LL | { s.1e-f32; }
215245
| ^^^^^^ expected one of `.`, `;`, `?`, `}`, or an operator
216246

217247
error: unexpected token: `1e+1f32`
218-
--> $DIR/float-field.rs:80:9
248+
--> $DIR/float-field.rs:82:9
219249
|
220250
LL | { s.1e+1f32; }
221251
| ^^^^^^^
222252

223253
error: expected one of `.`, `;`, `?`, `}`, or an operator, found `1e+1f32`
224-
--> $DIR/float-field.rs:80:9
254+
--> $DIR/float-field.rs:82:9
225255
|
226256
LL | { s.1e+1f32; }
227257
| ^^^^^^^ expected one of `.`, `;`, `?`, `}`, or an operator
228258

229259
error: unexpected token: `1e-1f32`
230-
--> $DIR/float-field.rs:83:9
260+
--> $DIR/float-field.rs:85:9
231261
|
232262
LL | { s.1e-1f32; }
233263
| ^^^^^^^
234264

235265
error: expected one of `.`, `;`, `?`, `}`, or an operator, found `1e-1f32`
236-
--> $DIR/float-field.rs:83:9
266+
--> $DIR/float-field.rs:85:9
237267
|
238268
LL | { s.1e-1f32; }
239269
| ^^^^^^^ expected one of `.`, `;`, `?`, `}`, or an operator
240270

241271
error: unexpected token: `1.1e+1f32`
242-
--> $DIR/float-field.rs:86:9
272+
--> $DIR/float-field.rs:88:9
243273
|
244274
LL | { s.1.1e+1f32; }
245275
| ^^^^^^^^^
246276

247277
error: expected one of `.`, `;`, `?`, `}`, or an operator, found `1.1e+1f32`
248-
--> $DIR/float-field.rs:86:9
278+
--> $DIR/float-field.rs:88:9
249279
|
250280
LL | { s.1.1e+1f32; }
251281
| ^^^^^^^^^ expected one of `.`, `;`, `?`, `}`, or an operator
252282

253283
error: unexpected token: `1.1e-1f32`
254-
--> $DIR/float-field.rs:89:9
284+
--> $DIR/float-field.rs:91:9
255285
|
256286
LL | { s.1.1e-1f32; }
257287
| ^^^^^^^^^
258288

259289
error: expected one of `.`, `;`, `?`, `}`, or an operator, found `1.1e-1f32`
260-
--> $DIR/float-field.rs:89:9
290+
--> $DIR/float-field.rs:91:9
261291
|
262292
LL | { s.1.1e-1f32; }
263293
| ^^^^^^^^^ expected one of `.`, `;`, `?`, `}`, or an operator
@@ -284,66 +314,42 @@ LL | { s.0x1e1; }
284314
|
285315
= note: available fields are: `0`, `1`
286316

287-
error[E0609]: no field `0x1` on type `S`
288-
--> $DIR/float-field.rs:36:9
289-
|
290-
LL | { s.0x1.; }
291-
| ^^^ unknown field
292-
|
293-
= note: available fields are: `0`, `1`
294-
295-
error[E0609]: no field `0x1` on type `S`
296-
--> $DIR/float-field.rs:40:9
297-
|
298-
LL | { s.0x1.1; }
299-
| ^^^ unknown field
300-
|
301-
= note: available fields are: `0`, `1`
302-
303-
error[E0609]: no field `0x1` on type `S`
304-
--> $DIR/float-field.rs:43:9
305-
|
306-
LL | { s.0x1.1e1; }
307-
| ^^^ unknown field
308-
|
309-
= note: available fields are: `0`, `1`
310-
311317
error[E0609]: no field `0x1e` on type `S`
312-
--> $DIR/float-field.rs:50:9
318+
--> $DIR/float-field.rs:52:9
313319
|
314320
LL | { s.0x1e+1; }
315321
| ^^^^ unknown field
316322
|
317323
= note: available fields are: `0`, `1`
318324

319325
error[E0609]: no field `0x1e` on type `S`
320-
--> $DIR/float-field.rs:52:9
326+
--> $DIR/float-field.rs:54:9
321327
|
322328
LL | { s.0x1e-1; }
323329
| ^^^^ unknown field
324330
|
325331
= note: available fields are: `0`, `1`
326332

327333
error[E0609]: no field `1e1` on type `S`
328-
--> $DIR/float-field.rs:62:9
334+
--> $DIR/float-field.rs:64:9
329335
|
330336
LL | { s.1e1f32; }
331337
| ^^^^^^ unknown field
332338
|
333339
= note: available fields are: `0`, `1`
334340

335341
error[E0609]: no field `f32` on type `(u8, u8)`
336-
--> $DIR/float-field.rs:65:11
342+
--> $DIR/float-field.rs:67:11
337343
|
338344
LL | { s.1.f32; }
339345
| ^^^ unknown field
340346

341347
error[E0609]: no field `1e1` on type `(u8, u8)`
342-
--> $DIR/float-field.rs:69:9
348+
--> $DIR/float-field.rs:71:9
343349
|
344350
LL | { s.1.1e1f32; }
345351
| ^^^^^^^^ unknown field
346352

347-
error: aborting due to 55 previous errors
353+
error: aborting due to 57 previous errors
348354

349355
For more information about this error, try `rustc --explain E0609`.

0 commit comments

Comments
 (0)