Skip to content

Commit

Permalink
Continue evaluating after incorrect float literal
Browse files Browse the repository at this point in the history
  • Loading branch information
estebank committed Jan 12, 2019
1 parent 65a8d7b commit 8bede50
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 12 deletions.
6 changes: 5 additions & 1 deletion src/libsyntax/parse/mod.rs
Expand Up @@ -673,7 +673,11 @@ fn integer_lit(s: &str, suffix: Option<Symbol>, diag: Option<(Span, &Handler)>)
_ => None,
};
if let Some(err) = err {
err!(diag, |span, diag| diag.span_err(span, err));
err!(diag, |span, diag| {
diag.struct_span_err(span, err)
.span_label(span, "not supported")
.emit();
});
}
return filtered_float_lit(Symbol::intern(s), Some(suf), diag)
}
Expand Down
6 changes: 3 additions & 3 deletions src/test/ui/parser/lex-bad-numeric-literals.stderr
Expand Up @@ -110,7 +110,7 @@ error: octal float literal is not supported
--> $DIR/lex-bad-numeric-literals.rs:5:5
|
LL | 0o2f32; //~ ERROR: octal float literal is not supported
| ^^^^^^
| ^^^^^^ not supported

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

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

error: aborting due to 23 previous errors

5 changes: 3 additions & 2 deletions src/test/ui/parser/no-binary-float-literal.rs
@@ -1,7 +1,8 @@
// error-pattern:binary float literal is not supported

fn main() {
0b101010f64;
//~^ ERROR binary float literal is not supported
0b101.010;
//~^ ERROR binary float literal is not supported
0b101p4f64;
//~^ ERROR invalid suffix `p4f64` for numeric literal
}
18 changes: 16 additions & 2 deletions src/test/ui/parser/no-binary-float-literal.stderr
@@ -1,8 +1,22 @@
error: binary float literal is not supported
--> $DIR/no-binary-float-literal.rs:5:5
--> $DIR/no-binary-float-literal.rs:4:5
|
LL | 0b101.010;
| ^^^^^^^^^

error: aborting due to previous error
error: binary float literal is not supported
--> $DIR/no-binary-float-literal.rs:2:5
|
LL | 0b101010f64;
| ^^^^^^^^^^^ not supported

error: invalid suffix `p4f64` for numeric literal
--> $DIR/no-binary-float-literal.rs:6:5
|
LL | 0b101p4f64;
| ^^^^^^^^^^
|
= help: the suffix must be one of the integral types (`u32`, `isize`, etc)

error: aborting due to 3 previous errors

6 changes: 4 additions & 2 deletions src/test/ui/parser/no-hex-float-literal.rs
@@ -1,7 +1,9 @@
// error-pattern:hexadecimal float literal is not supported

fn main() {
0xABC.Df;
//~^ ERROR `{integer}` is a primitive type and therefore doesn't have fields
0x567.89;
//~^ ERROR hexadecimal float literal is not supported
0xDEAD.BEEFp-2f;
//~^ ERROR invalid suffix `f` for float literal
//~| ERROR `{integer}` is a primitive type and therefore doesn't have fields
}
25 changes: 23 additions & 2 deletions src/test/ui/parser/no-hex-float-literal.stderr
@@ -1,8 +1,29 @@
error: hexadecimal float literal is not supported
--> $DIR/no-hex-float-literal.rs:5:5
--> $DIR/no-hex-float-literal.rs:4:5
|
LL | 0x567.89;
| ^^^^^^^^

error: aborting due to previous error
error: invalid suffix `f` for float literal
--> $DIR/no-hex-float-literal.rs:6:18
|
LL | 0xDEAD.BEEFp-2f;
| ^^
|
= help: valid suffixes are `f32` and `f64`

error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields
--> $DIR/no-hex-float-literal.rs:2:11
|
LL | 0xABC.Df;
| ^^

error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields
--> $DIR/no-hex-float-literal.rs:6:12
|
LL | 0xDEAD.BEEFp-2f;
| ^^^^^

error: aborting due to 4 previous errors

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

0 comments on commit 8bede50

Please sign in to comment.