Skip to content

Commit

Permalink
Add regression test for ice 89574
Browse files Browse the repository at this point in the history
  • Loading branch information
nbdd0121 authored and Mark-Simulacrum committed Oct 14, 2021
1 parent c418c6d commit 8d944eb
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 10 deletions.
4 changes: 4 additions & 0 deletions src/test/ui/parser/issue-89574.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
fn main() {
const EMPTY_ARRAY = [];
//~^ missing type for `const` item
}
8 changes: 8 additions & 0 deletions src/test/ui/parser/issue-89574.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
error: missing type for `const` item
--> $DIR/issue-89574.rs:2:11
|
LL | const EMPTY_ARRAY = [];
| ^^^^^^^^^^^ help: provide a type for the item: `EMPTY_ARRAY: <type>`

error: aborting due to previous error

Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ fn main() {}

const A: u8; //~ ERROR free constant item without body
const B; //~ ERROR free constant item without body
//~^ ERROR missing type for `const` item
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,11 @@ LL | const B;
| |
| help: provide a definition for the constant: `= <expr>;`

error: aborting due to 2 previous errors
error: missing type for `const` item
--> $DIR/item-free-const-no-body-semantic-fail.rs:6:7
|
LL | const B;
| ^ help: provide a type for the item: `B: <type>`

error: aborting due to 3 previous errors

2 changes: 2 additions & 0 deletions src/test/ui/parser/item-free-static-no-body-semantic-fail.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ fn main() {}

static A: u8; //~ ERROR free static item without body
static B; //~ ERROR free static item without body
//~^ ERROR missing type for `static` item

static mut C: u8; //~ ERROR free static item without body
static mut D; //~ ERROR free static item without body
//~^ ERROR missing type for `static mut` item
18 changes: 15 additions & 3 deletions src/test/ui/parser/item-free-static-no-body-semantic-fail.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,32 @@ LL | static B;
| help: provide a definition for the static: `= <expr>;`

error: free static item without body
--> $DIR/item-free-static-no-body-semantic-fail.rs:8:1
--> $DIR/item-free-static-no-body-semantic-fail.rs:9:1
|
LL | static mut C: u8;
| ^^^^^^^^^^^^^^^^-
| |
| help: provide a definition for the static: `= <expr>;`

error: free static item without body
--> $DIR/item-free-static-no-body-semantic-fail.rs:9:1
--> $DIR/item-free-static-no-body-semantic-fail.rs:10:1
|
LL | static mut D;
| ^^^^^^^^^^^^-
| |
| help: provide a definition for the static: `= <expr>;`

error: aborting due to 4 previous errors
error: missing type for `static` item
--> $DIR/item-free-static-no-body-semantic-fail.rs:6:8
|
LL | static B;
| ^ help: provide a type for the item: `B: <type>`

error: missing type for `static mut` item
--> $DIR/item-free-static-no-body-semantic-fail.rs:10:12
|
LL | static mut D;
| ^ help: provide a type for the item: `D: <type>`

error: aborting due to 6 previous errors

2 changes: 1 addition & 1 deletion src/test/ui/typeck/issue-79040.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
fn main() {
const FOO = "hello" + 1; //~ ERROR cannot add `{integer}` to `&str`
//~^ ERROR cannot add `{integer}` to `&str`
//~^ missing type for `const` item
println!("{}", FOO);
}
8 changes: 3 additions & 5 deletions src/test/ui/typeck/issue-79040.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@ LL | const FOO = "hello" + 1;
| |
| &str

error[E0369]: cannot add `{integer}` to `&str`
--> $DIR/issue-79040.rs:2:25
error: missing type for `const` item
--> $DIR/issue-79040.rs:2:11
|
LL | const FOO = "hello" + 1;
| ------- ^ - {integer}
| |
| &str
| ^^^ help: provide a type for the item: `FOO: <type>`

error: aborting due to 2 previous errors

Expand Down

0 comments on commit 8d944eb

Please sign in to comment.