Skip to content

Commit 8bede50

Browse files
committed
Continue evaluating after incorrect float literal
1 parent 65a8d7b commit 8bede50

File tree

6 files changed

+54
-12
lines changed

6 files changed

+54
-12
lines changed

src/libsyntax/parse/mod.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -673,7 +673,11 @@ fn integer_lit(s: &str, suffix: Option<Symbol>, diag: Option<(Span, &Handler)>)
673673
_ => None,
674674
};
675675
if let Some(err) = err {
676-
err!(diag, |span, diag| diag.span_err(span, err));
676+
err!(diag, |span, diag| {
677+
diag.struct_span_err(span, err)
678+
.span_label(span, "not supported")
679+
.emit();
680+
});
677681
}
678682
return filtered_float_lit(Symbol::intern(s), Some(suf), diag)
679683
}

src/test/ui/parser/lex-bad-numeric-literals.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ error: octal float literal is not supported
110110
--> $DIR/lex-bad-numeric-literals.rs:5:5
111111
|
112112
LL | 0o2f32; //~ ERROR: octal float literal is not supported
113-
| ^^^^^^
113+
| ^^^^^^ not supported
114114

115115
error: int literal is too large
116116
--> $DIR/lex-bad-numeric-literals.rs:16:5
@@ -128,13 +128,13 @@ error: octal float literal is not supported
128128
--> $DIR/lex-bad-numeric-literals.rs:23:5
129129
|
130130
LL | 0o123f64; //~ ERROR: octal float literal is not supported
131-
| ^^^^^^^^
131+
| ^^^^^^^^ not supported
132132

133133
error: binary float literal is not supported
134134
--> $DIR/lex-bad-numeric-literals.rs:25:5
135135
|
136136
LL | 0b101f64; //~ ERROR: binary float literal is not supported
137-
| ^^^^^^^^
137+
| ^^^^^^^^ not supported
138138

139139
error: aborting due to 23 previous errors
140140

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
// error-pattern:binary float literal is not supported
2-
31
fn main() {
42
0b101010f64;
3+
//~^ ERROR binary float literal is not supported
54
0b101.010;
5+
//~^ ERROR binary float literal is not supported
66
0b101p4f64;
7+
//~^ ERROR invalid suffix `p4f64` for numeric literal
78
}
Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,22 @@
11
error: binary float literal is not supported
2-
--> $DIR/no-binary-float-literal.rs:5:5
2+
--> $DIR/no-binary-float-literal.rs:4:5
33
|
44
LL | 0b101.010;
55
| ^^^^^^^^^
66

7-
error: aborting due to previous error
7+
error: binary float literal is not supported
8+
--> $DIR/no-binary-float-literal.rs:2:5
9+
|
10+
LL | 0b101010f64;
11+
| ^^^^^^^^^^^ not supported
12+
13+
error: invalid suffix `p4f64` for numeric literal
14+
--> $DIR/no-binary-float-literal.rs:6:5
15+
|
16+
LL | 0b101p4f64;
17+
| ^^^^^^^^^^
18+
|
19+
= help: the suffix must be one of the integral types (`u32`, `isize`, etc)
20+
21+
error: aborting due to 3 previous errors
822

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
// error-pattern:hexadecimal float literal is not supported
2-
31
fn main() {
42
0xABC.Df;
3+
//~^ ERROR `{integer}` is a primitive type and therefore doesn't have fields
54
0x567.89;
5+
//~^ ERROR hexadecimal float literal is not supported
66
0xDEAD.BEEFp-2f;
7+
//~^ ERROR invalid suffix `f` for float literal
8+
//~| ERROR `{integer}` is a primitive type and therefore doesn't have fields
79
}
Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,29 @@
11
error: hexadecimal float literal is not supported
2-
--> $DIR/no-hex-float-literal.rs:5:5
2+
--> $DIR/no-hex-float-literal.rs:4:5
33
|
44
LL | 0x567.89;
55
| ^^^^^^^^
66

7-
error: aborting due to previous error
7+
error: invalid suffix `f` for float literal
8+
--> $DIR/no-hex-float-literal.rs:6:18
9+
|
10+
LL | 0xDEAD.BEEFp-2f;
11+
| ^^
12+
|
13+
= help: valid suffixes are `f32` and `f64`
14+
15+
error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields
16+
--> $DIR/no-hex-float-literal.rs:2:11
17+
|
18+
LL | 0xABC.Df;
19+
| ^^
20+
21+
error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields
22+
--> $DIR/no-hex-float-literal.rs:6:12
23+
|
24+
LL | 0xDEAD.BEEFp-2f;
25+
| ^^^^^
26+
27+
error: aborting due to 4 previous errors
828

29+
For more information about this error, try `rustc --explain E0610`.

0 commit comments

Comments
 (0)