Skip to content

Commit 72e4a6b

Browse files
Update ui tests with new macro early erroring
1 parent 36dc498 commit 72e4a6b

23 files changed

+303
-245
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
trait Marker<const N: usize> {}
2+
struct Example<const N: usize>;
3+
impl<const N: usize> Marker<N> for Example<N> {}
4+
5+
fn make_marker() -> impl Marker<gimme_a_const!(marker)> {
6+
//~^ ERROR: type provided when a constant was expected
7+
//~| ERROR: type provided when a constant was expected
8+
Example::<gimme_a_const!(marker)>
9+
//~^ ERROR: type provided when a constant was expected
10+
}
11+
12+
fn main() {
13+
let _ok = Example::<{
14+
#[macro_export]
15+
macro_rules! gimme_a_const {
16+
($rusty: ident) => {{ let $rusty = 3; *&$rusty }}
17+
//~^ ERROR expected type
18+
//~| ERROR expected type
19+
}
20+
gimme_a_const!(run)
21+
}>;
22+
let _ok = Example::<{gimme_a_const!(marker)}>;
23+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
error: expected type, found `{`
2+
--> $DIR/macro-fail-const.rs:16:27
3+
|
4+
LL | fn make_marker() -> impl Marker<gimme_a_const!(marker)> {
5+
| ----------------------
6+
| |
7+
| this macro call doesn't expand to a type
8+
| in this macro invocation
9+
...
10+
LL | ($rusty: ident) => {{ let $rusty = 3; *&$rusty }}
11+
| ^ expected type
12+
|
13+
= note: this error originates in the macro `gimme_a_const` (in Nightly builds, run with -Z macro-backtrace for more info)
14+
15+
error: expected type, found `{`
16+
--> $DIR/macro-fail-const.rs:16:27
17+
|
18+
LL | Example::<gimme_a_const!(marker)>
19+
| ----------------------
20+
| |
21+
| this macro call doesn't expand to a type
22+
| in this macro invocation
23+
...
24+
LL | ($rusty: ident) => {{ let $rusty = 3; *&$rusty }}
25+
| ^ expected type
26+
|
27+
= note: this error originates in the macro `gimme_a_const` (in Nightly builds, run with -Z macro-backtrace for more info)
28+
29+
error[E0747]: type provided when a constant was expected
30+
--> $DIR/macro-fail-const.rs:5:33
31+
|
32+
LL | fn make_marker() -> impl Marker<gimme_a_const!(marker)> {
33+
| ^^^^^^^^^^^^^^^^^^^^^^
34+
35+
error[E0747]: type provided when a constant was expected
36+
--> $DIR/macro-fail-const.rs:5:33
37+
|
38+
LL | fn make_marker() -> impl Marker<gimme_a_const!(marker)> {
39+
| ^^^^^^^^^^^^^^^^^^^^^^
40+
|
41+
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
42+
43+
error[E0747]: type provided when a constant was expected
44+
--> $DIR/macro-fail-const.rs:8:13
45+
|
46+
LL | Example::<gimme_a_const!(marker)>
47+
| ^^^^^^^^^^^^^^^^^^^^^^
48+
49+
error: aborting due to 5 previous errors
50+
51+
For more information about this error, try `rustc --explain E0747`.

tests/ui/const-generics/min_const_generics/macro-fail.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,7 @@ trait Marker<const N: usize> {}
1212
impl<const N: usize> Marker<N> for Example<N> {}
1313

1414
fn make_marker() -> impl Marker<gimme_a_const!(marker)> {
15-
//~^ ERROR: type provided when a constant was expected
16-
//~| ERROR: type provided when a constant was expected
1715
Example::<gimme_a_const!(marker)>
18-
//~^ ERROR: type provided when a constant was expected
1916
}
2017

2118
fn from_marker(_: impl Marker<{
@@ -35,9 +32,7 @@ fn main() {
3532
}>;
3633

3734
let _fail = Example::<external_macro!()>;
38-
//~^ ERROR: type provided when a constant
3935

4036
let _fail = Example::<gimme_a_const!()>;
41-
//~^ ERROR unexpected end of macro invocation
42-
//~| ERROR: type provided when a constant was expected
37+
//~^ ERROR: unexpected end of macro invocation
4338
}
Lines changed: 5 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: expected type, found `{`
2-
--> $DIR/macro-fail.rs:30:27
2+
--> $DIR/macro-fail.rs:27:27
33
|
44
LL | fn make_marker() -> impl Marker<gimme_a_const!(marker)> {
55
| ----------------------
@@ -13,7 +13,7 @@ LL | ($rusty: ident) => {{ let $rusty = 3; *&$rusty }}
1313
= note: this error originates in the macro `gimme_a_const` (in Nightly builds, run with -Z macro-backtrace for more info)
1414

1515
error: expected type, found `{`
16-
--> $DIR/macro-fail.rs:30:27
16+
--> $DIR/macro-fail.rs:27:27
1717
|
1818
LL | Example::<gimme_a_const!(marker)>
1919
| ----------------------
@@ -41,7 +41,7 @@ LL | let _fail = Example::<external_macro!()>;
4141
= note: this error originates in the macro `external_macro` (in Nightly builds, run with -Z macro-backtrace for more info)
4242

4343
error: unexpected end of macro invocation
44-
--> $DIR/macro-fail.rs:40:25
44+
--> $DIR/macro-fail.rs:36:25
4545
|
4646
LL | macro_rules! gimme_a_const {
4747
| -------------------------- when calling this macro
@@ -50,43 +50,10 @@ LL | let _fail = Example::<gimme_a_const!()>;
5050
| ^^^^^^^^^^^^^^^^ missing tokens in macro arguments
5151
|
5252
note: while trying to match meta-variable `$rusty:ident`
53-
--> $DIR/macro-fail.rs:30:8
53+
--> $DIR/macro-fail.rs:27:8
5454
|
5555
LL | ($rusty: ident) => {{ let $rusty = 3; *&$rusty }}
5656
| ^^^^^^^^^^^^^
5757

58-
error[E0747]: type provided when a constant was expected
59-
--> $DIR/macro-fail.rs:14:33
60-
|
61-
LL | fn make_marker() -> impl Marker<gimme_a_const!(marker)> {
62-
| ^^^^^^^^^^^^^^^^^^^^^^
63-
64-
error[E0747]: type provided when a constant was expected
65-
--> $DIR/macro-fail.rs:14:33
66-
|
67-
LL | fn make_marker() -> impl Marker<gimme_a_const!(marker)> {
68-
| ^^^^^^^^^^^^^^^^^^^^^^
69-
|
70-
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
71-
72-
error[E0747]: type provided when a constant was expected
73-
--> $DIR/macro-fail.rs:17:13
74-
|
75-
LL | Example::<gimme_a_const!(marker)>
76-
| ^^^^^^^^^^^^^^^^^^^^^^
77-
78-
error[E0747]: type provided when a constant was expected
79-
--> $DIR/macro-fail.rs:37:25
80-
|
81-
LL | let _fail = Example::<external_macro!()>;
82-
| ^^^^^^^^^^^^^^^^^
83-
84-
error[E0747]: type provided when a constant was expected
85-
--> $DIR/macro-fail.rs:40:25
86-
|
87-
LL | let _fail = Example::<gimme_a_const!()>;
88-
| ^^^^^^^^^^^^^^^^
89-
90-
error: aborting due to 9 previous errors
58+
error: aborting due to 4 previous errors
9159

92-
For more information about this error, try `rustc --explain E0747`.

tests/ui/editions/edition-keywords-2018-2015-parsing.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ pub fn check_async() {
2626
module::async(); //~ ERROR expected identifier, found keyword `async`
2727
module::r#async(); // OK
2828

29-
let _recovery_witness: () = 0; //~ ERROR mismatched types
29+
let _recovery_witness: () = 0; // not emitted because of the macro parsing error
3030
}
3131

3232
//~? ERROR macro expansion ends with an incomplete expression

tests/ui/editions/edition-keywords-2018-2015-parsing.stderr

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,5 @@ error: macro expansion ends with an incomplete expression: expected one of `move
6161
LL | if passes_tt!(async) == 1 {}
6262
| ^ expected one of `move`, `use`, `{`, `|`, or `||`
6363

64-
error[E0308]: mismatched types
65-
--> $DIR/edition-keywords-2018-2015-parsing.rs:29:33
66-
|
67-
LL | let _recovery_witness: () = 0;
68-
| -- ^ expected `()`, found integer
69-
| |
70-
| expected due to this
71-
72-
error: aborting due to 7 previous errors
64+
error: aborting due to 6 previous errors
7365

74-
For more information about this error, try `rustc --explain E0308`.

tests/ui/editions/edition-keywords-2018-2018-parsing.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ pub fn check_async() {
3636
if local_passes_tt!(r#async) == 1 {} // OK
3737
module::async(); //~ ERROR expected identifier, found keyword `async`
3838
module::r#async(); // OK
39-
40-
let _recovery_witness: () = 0; //~ ERROR mismatched types
4139
}
4240

4341
//~? ERROR macro expansion ends with an incomplete expression

tests/ui/editions/edition-keywords-2018-2018-parsing.stderr

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,5 @@ error: macro expansion ends with an incomplete expression: expected one of `move
7373
LL | if local_passes_tt!(async) == 1 {}
7474
| ^ expected one of `move`, `use`, `{`, `|`, or `||`
7575

76-
error[E0308]: mismatched types
77-
--> $DIR/edition-keywords-2018-2018-parsing.rs:40:33
78-
|
79-
LL | let _recovery_witness: () = 0;
80-
| -- ^ expected `()`, found integer
81-
| |
82-
| expected due to this
83-
84-
error: aborting due to 9 previous errors
76+
error: aborting due to 8 previous errors
8577

86-
For more information about this error, try `rustc --explain E0308`.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#![feature(builtin_syntax)]
2+
3+
use std::mem::offset_of;
4+
5+
fn main() {
6+
offset_of!((u8, u8), _0); //~ ERROR no field `_0`
7+
offset_of!((u8, u8), 01); //~ ERROR no field `01`
8+
offset_of!((u8, u8), 1e2); //~ ERROR no field `1e2`
9+
offset_of!((u8, u8), 1_u8); //~ ERROR no field `1_`
10+
//~| ERROR suffixes on a tuple index
11+
12+
builtin # offset_of((u8, u8), 1e2); //~ ERROR no field `1e2`
13+
builtin # offset_of((u8, u8), _0); //~ ERROR no field `_0`
14+
builtin # offset_of((u8, u8), 01); //~ ERROR no field `01`
15+
builtin # offset_of((u8, u8), 1_u8); //~ ERROR no field `1_`
16+
//~| ERROR suffixes on a tuple index
17+
18+
offset_of!(((u8, u16), (u32, u16, u8)), 0.2); //~ ERROR no field `2`
19+
offset_of!(((u8, u16), (u32, u16, u8)), 0.1e2); //~ ERROR no field `1e2`
20+
offset_of!(((u8, u16), (u32, u16, u8)), 1.2);
21+
offset_of!(((u8, u16), (u32, u16, u8)), 1.2.0); //~ ERROR no field `0`
22+
}
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
error: suffixes on a tuple index are invalid
2+
--> $DIR/offset-of-tuple-field.rs:15:35
3+
|
4+
LL | builtin # offset_of((u8, u8), 1_u8);
5+
| ^^^^ invalid suffix `u8`
6+
7+
error: suffixes on a tuple index are invalid
8+
--> $DIR/offset-of-tuple-field.rs:9:26
9+
|
10+
LL | offset_of!((u8, u8), 1_u8);
11+
| ^^^^ invalid suffix `u8`
12+
13+
error[E0609]: no field `_0` on type `(u8, u8)`
14+
--> $DIR/offset-of-tuple-field.rs:6:26
15+
|
16+
LL | offset_of!((u8, u8), _0);
17+
| ^^
18+
19+
error[E0609]: no field `01` on type `(u8, u8)`
20+
--> $DIR/offset-of-tuple-field.rs:7:26
21+
|
22+
LL | offset_of!((u8, u8), 01);
23+
| ^^
24+
25+
error[E0609]: no field `1e2` on type `(u8, u8)`
26+
--> $DIR/offset-of-tuple-field.rs:8:26
27+
|
28+
LL | offset_of!((u8, u8), 1e2);
29+
| ^^^
30+
31+
error[E0609]: no field `1_` on type `(u8, u8)`
32+
--> $DIR/offset-of-tuple-field.rs:9:26
33+
|
34+
LL | offset_of!((u8, u8), 1_u8);
35+
| ^^^^
36+
37+
error[E0609]: no field `1e2` on type `(u8, u8)`
38+
--> $DIR/offset-of-tuple-field.rs:12:35
39+
|
40+
LL | builtin # offset_of((u8, u8), 1e2);
41+
| ^^^
42+
43+
error[E0609]: no field `_0` on type `(u8, u8)`
44+
--> $DIR/offset-of-tuple-field.rs:13:35
45+
|
46+
LL | builtin # offset_of((u8, u8), _0);
47+
| ^^
48+
49+
error[E0609]: no field `01` on type `(u8, u8)`
50+
--> $DIR/offset-of-tuple-field.rs:14:35
51+
|
52+
LL | builtin # offset_of((u8, u8), 01);
53+
| ^^
54+
55+
error[E0609]: no field `1_` on type `(u8, u8)`
56+
--> $DIR/offset-of-tuple-field.rs:15:35
57+
|
58+
LL | builtin # offset_of((u8, u8), 1_u8);
59+
| ^^^^
60+
61+
error[E0609]: no field `2` on type `(u8, u16)`
62+
--> $DIR/offset-of-tuple-field.rs:18:47
63+
|
64+
LL | offset_of!(((u8, u16), (u32, u16, u8)), 0.2);
65+
| ^
66+
67+
error[E0609]: no field `1e2` on type `(u8, u16)`
68+
--> $DIR/offset-of-tuple-field.rs:19:47
69+
|
70+
LL | offset_of!(((u8, u16), (u32, u16, u8)), 0.1e2);
71+
| ^^^
72+
73+
error[E0609]: no field `0` on type `u8`
74+
--> $DIR/offset-of-tuple-field.rs:21:49
75+
|
76+
LL | offset_of!(((u8, u16), (u32, u16, u8)), 1.2.0);
77+
| ^
78+
79+
error: aborting due to 13 previous errors
80+
81+
For more information about this error, try `rustc --explain E0609`.

0 commit comments

Comments
 (0)