mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-05 13:13:40 +00:00
226edf64fa
Attribute values must be literals. The error you get when that doesn't hold is pretty bad, e.g.: ``` unexpected expression: 1 + 1 ``` You also get the same error if the attribute value is a literal, but an invalid literal, e.g.: ``` unexpected expression: "foo"suffix ``` This commit does two things. - Changes the error message to "attribute value must be a literal", which gives a better idea of what the problem is and how to fix it. It also no longer prints the invalid expression, because the carets below highlight it anyway. - Separates the "not a literal" case from the "invalid literal" case. Which means invalid literals now get the specific error at the literal level, rather than at the attribute level.
154 lines
3.9 KiB
Plaintext
154 lines
3.9 KiB
Plaintext
error: suffixes on string literals are invalid
|
|
--> $DIR/bad-lit-suffixes.rs:4:5
|
|
|
|
|
LL | "C"suffix
|
|
| ^^^^^^^^^ invalid suffix `suffix`
|
|
|
|
error: suffixes on string literals are invalid
|
|
--> $DIR/bad-lit-suffixes.rs:8:5
|
|
|
|
|
LL | "C"suffix
|
|
| ^^^^^^^^^ invalid suffix `suffix`
|
|
|
|
error: suffixes on string literals are invalid
|
|
--> $DIR/bad-lit-suffixes.rs:30:17
|
|
|
|
|
LL | #[rustc_dummy = "string"suffix]
|
|
| ^^^^^^^^^^^^^^ invalid suffix `suffix`
|
|
|
|
error: suffixes on string literals are invalid
|
|
--> $DIR/bad-lit-suffixes.rs:34:14
|
|
|
|
|
LL | #[must_use = "string"suffix]
|
|
| ^^^^^^^^^^^^^^ invalid suffix `suffix`
|
|
|
|
error: malformed `must_use` attribute input
|
|
--> $DIR/bad-lit-suffixes.rs:34:1
|
|
|
|
|
LL | #[must_use = "string"suffix]
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
help: the following are the possible correct uses
|
|
|
|
|
LL | #[must_use = "reason"]
|
|
|
|
|
LL | #[must_use]
|
|
|
|
|
|
|
error: suffixes on string literals are invalid
|
|
--> $DIR/bad-lit-suffixes.rs:39:15
|
|
|
|
|
LL | #[link(name = "string"suffix)]
|
|
| ^^^^^^^^^^^^^^ invalid suffix `suffix`
|
|
|
|
error: invalid suffix `suffix` for number literal
|
|
--> $DIR/bad-lit-suffixes.rs:43:41
|
|
|
|
|
LL | #[rustc_layout_scalar_valid_range_start(0suffix)]
|
|
| ^^^^^^^ invalid suffix `suffix`
|
|
|
|
|
= help: the suffix must be one of the numeric types (`u32`, `isize`, `f32`, etc.)
|
|
|
|
error: suffixes on string literals are invalid
|
|
--> $DIR/bad-lit-suffixes.rs:12:5
|
|
|
|
|
LL | ""suffix;
|
|
| ^^^^^^^^ invalid suffix `suffix`
|
|
|
|
error: suffixes on byte string literals are invalid
|
|
--> $DIR/bad-lit-suffixes.rs:13:5
|
|
|
|
|
LL | b""suffix;
|
|
| ^^^^^^^^^ invalid suffix `suffix`
|
|
|
|
error: suffixes on string literals are invalid
|
|
--> $DIR/bad-lit-suffixes.rs:14:5
|
|
|
|
|
LL | r#""#suffix;
|
|
| ^^^^^^^^^^^ invalid suffix `suffix`
|
|
|
|
error: suffixes on byte string literals are invalid
|
|
--> $DIR/bad-lit-suffixes.rs:15:5
|
|
|
|
|
LL | br#""#suffix;
|
|
| ^^^^^^^^^^^^ invalid suffix `suffix`
|
|
|
|
error: suffixes on char literals are invalid
|
|
--> $DIR/bad-lit-suffixes.rs:16:5
|
|
|
|
|
LL | 'a'suffix;
|
|
| ^^^^^^^^^ invalid suffix `suffix`
|
|
|
|
error: suffixes on byte literals are invalid
|
|
--> $DIR/bad-lit-suffixes.rs:17:5
|
|
|
|
|
LL | b'a'suffix;
|
|
| ^^^^^^^^^^ invalid suffix `suffix`
|
|
|
|
error: invalid width `1024` for integer literal
|
|
--> $DIR/bad-lit-suffixes.rs:19:5
|
|
|
|
|
LL | 1234u1024;
|
|
| ^^^^^^^^^
|
|
|
|
|
= help: valid widths are 8, 16, 32, 64 and 128
|
|
|
|
error: invalid width `1024` for integer literal
|
|
--> $DIR/bad-lit-suffixes.rs:20:5
|
|
|
|
|
LL | 1234i1024;
|
|
| ^^^^^^^^^
|
|
|
|
|
= help: valid widths are 8, 16, 32, 64 and 128
|
|
|
|
error: invalid width `1024` for float literal
|
|
--> $DIR/bad-lit-suffixes.rs:21:5
|
|
|
|
|
LL | 1234f1024;
|
|
| ^^^^^^^^^
|
|
|
|
|
= help: valid widths are 32 and 64
|
|
|
|
error: invalid width `1024` for float literal
|
|
--> $DIR/bad-lit-suffixes.rs:22:5
|
|
|
|
|
LL | 1234.5f1024;
|
|
| ^^^^^^^^^^^
|
|
|
|
|
= help: valid widths are 32 and 64
|
|
|
|
error: invalid suffix `suffix` for number literal
|
|
--> $DIR/bad-lit-suffixes.rs:24:5
|
|
|
|
|
LL | 1234suffix;
|
|
| ^^^^^^^^^^ invalid suffix `suffix`
|
|
|
|
|
= help: the suffix must be one of the numeric types (`u32`, `isize`, `f32`, etc.)
|
|
|
|
error: invalid suffix `suffix` for number literal
|
|
--> $DIR/bad-lit-suffixes.rs:25:5
|
|
|
|
|
LL | 0b101suffix;
|
|
| ^^^^^^^^^^^ invalid suffix `suffix`
|
|
|
|
|
= help: the suffix must be one of the numeric types (`u32`, `isize`, `f32`, etc.)
|
|
|
|
error: invalid suffix `suffix` for float literal
|
|
--> $DIR/bad-lit-suffixes.rs:26:5
|
|
|
|
|
LL | 1.0suffix;
|
|
| ^^^^^^^^^ invalid suffix `suffix`
|
|
|
|
|
= help: valid suffixes are `f32` and `f64`
|
|
|
|
error: invalid suffix `suffix` for float literal
|
|
--> $DIR/bad-lit-suffixes.rs:27:5
|
|
|
|
|
LL | 1.0e10suffix;
|
|
| ^^^^^^^^^^^^ invalid suffix `suffix`
|
|
|
|
|
= help: valid suffixes are `f32` and `f64`
|
|
|
|
error: aborting due to 21 previous errors
|
|
|