Skip to content

Commit ca00cfb

Browse files
committed
Add a test.
This will become interesting in the next commit.
1 parent 0bed23b commit ca00cfb

File tree

2 files changed

+108
-0
lines changed

2 files changed

+108
-0
lines changed

src/test/ui/lowering/literals.rs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// check-fail
2+
3+
// A variety of code features that require the value of a literal prior to AST
4+
// lowering.
5+
6+
#![feature(concat_bytes)]
7+
8+
#[repr(align(340282366920938463463374607431768211456))]
9+
//~^ ERROR integer literal is too large
10+
struct S1(u32);
11+
12+
#[repr(align(4u7))] //~ ERROR invalid width `7` for integer literal
13+
struct S2(u32);
14+
15+
#[doc = "documentation"suffix]
16+
//~^ ERROR suffixes on a string literal are invalid
17+
//~^^ ERROR attribute must be of the form
18+
//~^^^ WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
19+
struct D;
20+
21+
#[doc(alias = 0u7)] //~ ERROR invalid width `7` for integer literal
22+
struct E;
23+
24+
fn main() {
25+
println!(concat!(
26+
"abc"suffix, //~ ERROR suffixes on a string literal are invalid
27+
"blah"foo, //~ ERROR suffixes on a string literal are invalid
28+
3u33, //~ ERROR invalid width `33` for integer literal
29+
));
30+
31+
let x = concat_bytes!("foo"blah, 3u33);
32+
//~^ ERROR suffixes on a string literal are invalid
33+
//~^^ ERROR invalid width `33` for integer literal
34+
}

src/test/ui/lowering/literals.stderr

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
error: suffixes on a string literal are invalid
2+
--> $DIR/literals.rs:15:9
3+
|
4+
LL | #[doc = "documentation"suffix]
5+
| ^^^^^^^^^^^^^^^^^^^^^ invalid suffix `suffix`
6+
7+
error: suffixes on a string literal are invalid
8+
--> $DIR/literals.rs:26:9
9+
|
10+
LL | "abc"suffix,
11+
| ^^^^^^^^^^^ invalid suffix `suffix`
12+
13+
error: suffixes on a string literal are invalid
14+
--> $DIR/literals.rs:27:9
15+
|
16+
LL | "blah"foo,
17+
| ^^^^^^^^^ invalid suffix `foo`
18+
19+
error: invalid width `33` for integer literal
20+
--> $DIR/literals.rs:28:9
21+
|
22+
LL | 3u33,
23+
| ^^^^
24+
|
25+
= help: valid widths are 8, 16, 32, 64 and 128
26+
27+
error: suffixes on a string literal are invalid
28+
--> $DIR/literals.rs:31:27
29+
|
30+
LL | let x = concat_bytes!("foo"blah, 3u33);
31+
| ^^^^^^^^^ invalid suffix `blah`
32+
33+
error: invalid width `33` for integer literal
34+
--> $DIR/literals.rs:31:38
35+
|
36+
LL | let x = concat_bytes!("foo"blah, 3u33);
37+
| ^^^^
38+
|
39+
= help: valid widths are 8, 16, 32, 64 and 128
40+
41+
error: integer literal is too large
42+
--> $DIR/literals.rs:8:14
43+
|
44+
LL | #[repr(align(340282366920938463463374607431768211456))]
45+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
46+
47+
error: invalid width `7` for integer literal
48+
--> $DIR/literals.rs:12:14
49+
|
50+
LL | #[repr(align(4u7))]
51+
| ^^^
52+
|
53+
= help: valid widths are 8, 16, 32, 64 and 128
54+
55+
error: invalid width `7` for integer literal
56+
--> $DIR/literals.rs:21:15
57+
|
58+
LL | #[doc(alias = 0u7)]
59+
| ^^^
60+
|
61+
= help: valid widths are 8, 16, 32, 64 and 128
62+
63+
error: attribute must be of the form `#[doc(hidden|inline|...)]` or `#[doc = "string"]`
64+
--> $DIR/literals.rs:15:1
65+
|
66+
LL | #[doc = "documentation"suffix]
67+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
68+
|
69+
= note: `#[deny(ill_formed_attribute_input)]` on by default
70+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
71+
= note: for more information, see issue #57571 <https://github.com/rust-lang/rust/issues/57571>
72+
73+
error: aborting due to 10 previous errors
74+

0 commit comments

Comments
 (0)