Skip to content

Commit 8dd701c

Browse files
committed
add test for rejecting EIIs in statement position
1 parent df55233 commit 8dd701c

2 files changed

Lines changed: 19 additions & 9 deletions

File tree

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
#![feature(extern_item_impls)]
2-
// EIIs can, despite not being super useful, be declared in statement position
3-
// nested inside items. Items in statement position, when expanded as part of a macro,
4-
// need to be wrapped slightly differently (in an `ast::Statement`).
5-
// We did this on the happy path (no errors), but when there was an error, we'd
6-
// replace it with *just* an `ast::Item` not wrapped in an `ast::Statement`.
7-
// This caused an ICE (https://github.com/rust-lang/rust/issues/149980).
8-
// this test fails to build, but demonstrates that no ICE is produced.
2+
// EIIs cannot be used in statement position.
3+
// This is also a regression test for an ICE (https://github.com/rust-lang/rust/issues/149980).
94

105
fn main() {
116
struct Bar;
127

138
#[eii]
149
//~^ ERROR `#[eii]` is only valid on functions
1510
impl Bar {}
11+
12+
13+
// Even on functions, eiis in statement position are rejected
14+
#[eii]
15+
//~^ ERROR `#[eii]` can only be used on functions inside a module
16+
fn foo() {}
1617
}
Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
11
error: `#[eii]` is only valid on functions
2-
--> $DIR/error_statement_position.rs:13:5
2+
--> $DIR/error_statement_position.rs:8:5
33
|
44
LL | #[eii]
55
| ^^^^^^
66

7-
error: aborting due to 1 previous error
7+
error: `#[eii]` can only be used on functions inside a module
8+
--> $DIR/error_statement_position.rs:14:5
9+
|
10+
LL | #[eii]
11+
| ^^^^^^
12+
LL |
13+
LL | fn foo() {}
14+
| --- `#[eii]` is used on this item, which is part of another item's local scope
15+
16+
error: aborting due to 2 previous errors
817

0 commit comments

Comments
 (0)