Use token::Lit in ast::ExprKind::Lit.
Instead of `ast::Lit`. Literal lowering now happens at two different times. Expression literals are lowered when HIR is crated. Attribute literals are lowered during parsing. This commit changes the language very slightly. Some programs that used to not compile now will compile. This is because some invalid literals that are removed by `cfg` or attribute macros will no longer trigger errors. See this comment for more details: https://github.com/rust-lang/rust/pull/102944#issuecomment-1277476773
This commit is contained in:
parent
01760265cb
commit
358a603f11
45 changed files with 701 additions and 581 deletions
|
|
@ -28,12 +28,11 @@ fn main() {
|
|||
}
|
||||
|
||||
#[rustc_dummy = "string"suffix]
|
||||
//~^ ERROR suffixes on string literals are invalid
|
||||
//~^ ERROR unexpected expression: `"string"suffix`
|
||||
fn f() {}
|
||||
|
||||
#[must_use = "string"suffix]
|
||||
//~^ ERROR suffixes on string literals are invalid
|
||||
//~^^ ERROR malformed `must_use` attribute input
|
||||
//~^ ERROR unexpected expression: `"string"suffix`
|
||||
fn g() {}
|
||||
|
||||
#[link(name = "string"suffix)]
|
||||
|
|
|
|||
|
|
@ -10,6 +10,32 @@ error: suffixes on string literals are invalid
|
|||
LL | "C"suffix
|
||||
| ^^^^^^^^^ invalid suffix `suffix`
|
||||
|
||||
error: unexpected expression: `"string"suffix`
|
||||
--> $DIR/bad-lit-suffixes.rs:30:17
|
||||
|
|
||||
LL | #[rustc_dummy = "string"suffix]
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
||||
error: unexpected expression: `"string"suffix`
|
||||
--> $DIR/bad-lit-suffixes.rs:34:14
|
||||
|
|
||||
LL | #[must_use = "string"suffix]
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
||||
error: suffixes on string literals are invalid
|
||||
--> $DIR/bad-lit-suffixes.rs:38:15
|
||||
|
|
||||
LL | #[link(name = "string"suffix)]
|
||||
| ^^^^^^^^^^^^^^ invalid suffix `suffix`
|
||||
|
||||
error: invalid suffix `suffix` for number literal
|
||||
--> $DIR/bad-lit-suffixes.rs:42: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
|
||||
|
|
||||
|
|
@ -110,44 +136,5 @@ LL | 1.0e10suffix;
|
|||
|
|
||||
= help: valid suffixes are `f32` and `f64`
|
||||
|
||||
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: aborting due to 21 previous errors
|
||||
error: aborting due to 20 previous errors
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue