Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add label for invalid literal suffix
  • Loading branch information
estebank committed Jan 12, 2019
1 parent 3ead6de commit 1550787
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 8 deletions.
2 changes: 2 additions & 0 deletions src/libsyntax/parse/mod.rs
Expand Up @@ -520,6 +520,7 @@ fn filtered_float_lit(data: Symbol, suffix: Option<Symbol>, diag: Option<(Span,
} else {
let msg = format!("invalid suffix `{}` for float literal", suf);
diag.struct_span_err(span, &msg)
.span_label(span, format!("invalid suffix `{}`", suf))
.help("valid suffixes are `f32` and `f64`")
.emit();
}
Expand Down Expand Up @@ -716,6 +717,7 @@ fn integer_lit(s: &str, suffix: Option<Symbol>, diag: Option<(Span, &Handler)>)
} else {
let msg = format!("invalid suffix `{}` for numeric literal", suf);
diag.struct_span_err(span, &msg)
.span_label(span, format!("invalid suffix `{}`", suf))
.help("the suffix must be one of the integral types \
(`u32`, `isize`, etc)")
.emit();
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/old-suffixes-are-really-forbidden.stderr
Expand Up @@ -2,15 +2,15 @@ error: invalid suffix `is` for numeric literal
--> $DIR/old-suffixes-are-really-forbidden.rs:2:13
|
LL | let a = 1_is; //~ ERROR invalid suffix
| ^^^^
| ^^^^ invalid suffix `is`
|
= help: the suffix must be one of the integral types (`u32`, `isize`, etc)

error: invalid suffix `us` for numeric literal
--> $DIR/old-suffixes-are-really-forbidden.rs:3:13
|
LL | let b = 2_us; //~ ERROR invalid suffix
| ^^^^
| ^^^^ invalid suffix `us`
|
= help: the suffix must be one of the integral types (`u32`, `isize`, etc)

Expand Down
8 changes: 4 additions & 4 deletions src/test/ui/parser/bad-lit-suffixes.stderr
Expand Up @@ -82,31 +82,31 @@ error: invalid suffix `suffix` for numeric literal
--> $DIR/bad-lit-suffixes.rs:25:5
|
LL | 1234suffix; //~ ERROR invalid suffix `suffix` for numeric literal
| ^^^^^^^^^^
| ^^^^^^^^^^ invalid suffix `suffix`
|
= help: the suffix must be one of the integral types (`u32`, `isize`, etc)

error: invalid suffix `suffix` for numeric literal
--> $DIR/bad-lit-suffixes.rs:26:5
|
LL | 0b101suffix; //~ ERROR invalid suffix `suffix` for numeric literal
| ^^^^^^^^^^^
| ^^^^^^^^^^^ invalid suffix `suffix`
|
= help: the suffix must be one of the integral types (`u32`, `isize`, etc)

error: invalid suffix `suffix` for float literal
--> $DIR/bad-lit-suffixes.rs:27:5
|
LL | 1.0suffix; //~ ERROR invalid suffix `suffix` for float literal
| ^^^^^^^^^
| ^^^^^^^^^ invalid suffix `suffix`
|
= help: valid suffixes are `f32` and `f64`

error: invalid suffix `suffix` for float literal
--> $DIR/bad-lit-suffixes.rs:28:5
|
LL | 1.0e10suffix; //~ ERROR invalid suffix `suffix` for float literal
| ^^^^^^^^^^^^
| ^^^^^^^^^^^^ invalid suffix `suffix`
|
= help: valid suffixes are `f32` and `f64`

Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/parser/no-binary-float-literal.stderr
Expand Up @@ -14,7 +14,7 @@ error: invalid suffix `p4f64` for numeric literal
--> $DIR/no-binary-float-literal.rs:6:5
|
LL | 0b101p4f64;
| ^^^^^^^^^^
| ^^^^^^^^^^ invalid suffix `p4f64`
|
= help: the suffix must be one of the integral types (`u32`, `isize`, etc)

Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/parser/no-hex-float-literal.stderr
Expand Up @@ -8,7 +8,7 @@ error: invalid suffix `f` for float literal
--> $DIR/no-hex-float-literal.rs:6:18
|
LL | 0xDEAD.BEEFp-2f;
| ^^
| ^^ invalid suffix `f`
|
= help: valid suffixes are `f32` and `f64`

Expand Down

0 comments on commit 1550787

Please sign in to comment.