Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove ast::Lit::kind #101885

Closed
wants to merge 3 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add a test.
This will become interesting in the next commit.
  • Loading branch information
nnethercote committed Sep 20, 2022
commit ca00cfb082ac6af1f7b11bade333da62f93277f6
34 changes: 34 additions & 0 deletions src/test/ui/lowering/literals.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// check-fail

// A variety of code features that require the value of a literal prior to AST
// lowering.

#![feature(concat_bytes)]

#[repr(align(340282366920938463463374607431768211456))]
//~^ ERROR integer literal is too large
struct S1(u32);

#[repr(align(4u7))] //~ ERROR invalid width `7` for integer literal
struct S2(u32);

#[doc = "documentation"suffix]
//~^ ERROR suffixes on a string literal are invalid
//~^^ ERROR attribute must be of the form
//~^^^ WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
struct D;

#[doc(alias = 0u7)] //~ ERROR invalid width `7` for integer literal
struct E;

fn main() {
println!(concat!(
"abc"suffix, //~ ERROR suffixes on a string literal are invalid
"blah"foo, //~ ERROR suffixes on a string literal are invalid
3u33, //~ ERROR invalid width `33` for integer literal
));

let x = concat_bytes!("foo"blah, 3u33);
//~^ ERROR suffixes on a string literal are invalid
//~^^ ERROR invalid width `33` for integer literal
}
74 changes: 74 additions & 0 deletions src/test/ui/lowering/literals.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
error: suffixes on a string literal are invalid
--> $DIR/literals.rs:15:9
|
LL | #[doc = "documentation"suffix]
| ^^^^^^^^^^^^^^^^^^^^^ invalid suffix `suffix`

error: suffixes on a string literal are invalid
--> $DIR/literals.rs:26:9
|
LL | "abc"suffix,
| ^^^^^^^^^^^ invalid suffix `suffix`

error: suffixes on a string literal are invalid
--> $DIR/literals.rs:27:9
|
LL | "blah"foo,
| ^^^^^^^^^ invalid suffix `foo`

error: invalid width `33` for integer literal
--> $DIR/literals.rs:28:9
|
LL | 3u33,
| ^^^^
|
= help: valid widths are 8, 16, 32, 64 and 128

error: suffixes on a string literal are invalid
--> $DIR/literals.rs:31:27
|
LL | let x = concat_bytes!("foo"blah, 3u33);
| ^^^^^^^^^ invalid suffix `blah`

error: invalid width `33` for integer literal
--> $DIR/literals.rs:31:38
|
LL | let x = concat_bytes!("foo"blah, 3u33);
| ^^^^
|
= help: valid widths are 8, 16, 32, 64 and 128

error: integer literal is too large
--> $DIR/literals.rs:8:14
|
LL | #[repr(align(340282366920938463463374607431768211456))]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: invalid width `7` for integer literal
--> $DIR/literals.rs:12:14
|
LL | #[repr(align(4u7))]
| ^^^
|
= help: valid widths are 8, 16, 32, 64 and 128

error: invalid width `7` for integer literal
--> $DIR/literals.rs:21:15
|
LL | #[doc(alias = 0u7)]
| ^^^
|
= help: valid widths are 8, 16, 32, 64 and 128

error: attribute must be of the form `#[doc(hidden|inline|...)]` or `#[doc = "string"]`
--> $DIR/literals.rs:15:1
|
LL | #[doc = "documentation"suffix]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: `#[deny(ill_formed_attribute_input)]` on by default
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #57571 <https://github.com/rust-lang/rust/issues/57571>

error: aborting due to 10 previous errors