From b4c62d5f2c0cec1b5332dbbf843b4134ad8123ae Mon Sep 17 00:00:00 2001 From: Gary Guo Date: Wed, 6 Oct 2021 01:52:45 +0100 Subject: [PATCH] Add regression test for ice 89574 --- src/test/ui/parser/issue-89574.rs | 4 ++++ src/test/ui/parser/issue-89574.stderr | 8 ++++++++ .../item-free-const-no-body-semantic-fail.rs | 1 + ...tem-free-const-no-body-semantic-fail.stderr | 8 +++++++- .../item-free-static-no-body-semantic-fail.rs | 2 ++ ...em-free-static-no-body-semantic-fail.stderr | 18 +++++++++++++++--- src/test/ui/typeck/issue-79040.rs | 2 +- src/test/ui/typeck/issue-79040.stderr | 8 +++----- 8 files changed, 41 insertions(+), 10 deletions(-) create mode 100644 src/test/ui/parser/issue-89574.rs create mode 100644 src/test/ui/parser/issue-89574.stderr diff --git a/src/test/ui/parser/issue-89574.rs b/src/test/ui/parser/issue-89574.rs new file mode 100644 index 0000000000000..0a477f1aa5fb6 --- /dev/null +++ b/src/test/ui/parser/issue-89574.rs @@ -0,0 +1,4 @@ +fn main() { + const EMPTY_ARRAY = []; + //~^ missing type for `const` item +} diff --git a/src/test/ui/parser/issue-89574.stderr b/src/test/ui/parser/issue-89574.stderr new file mode 100644 index 0000000000000..cbee3d35155c7 --- /dev/null +++ b/src/test/ui/parser/issue-89574.stderr @@ -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: ` + +error: aborting due to previous error + diff --git a/src/test/ui/parser/item-free-const-no-body-semantic-fail.rs b/src/test/ui/parser/item-free-const-no-body-semantic-fail.rs index 15a15a207b1ca..613b3c9856171 100644 --- a/src/test/ui/parser/item-free-const-no-body-semantic-fail.rs +++ b/src/test/ui/parser/item-free-const-no-body-semantic-fail.rs @@ -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 diff --git a/src/test/ui/parser/item-free-const-no-body-semantic-fail.stderr b/src/test/ui/parser/item-free-const-no-body-semantic-fail.stderr index aa75e5cee01d4..c340e958ee585 100644 --- a/src/test/ui/parser/item-free-const-no-body-semantic-fail.stderr +++ b/src/test/ui/parser/item-free-const-no-body-semantic-fail.stderr @@ -14,5 +14,11 @@ LL | const B; | | | help: provide a definition for the constant: `= ;` -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: ` + +error: aborting due to 3 previous errors diff --git a/src/test/ui/parser/item-free-static-no-body-semantic-fail.rs b/src/test/ui/parser/item-free-static-no-body-semantic-fail.rs index 61d3eab24d8c7..780479e3d26ac 100644 --- a/src/test/ui/parser/item-free-static-no-body-semantic-fail.rs +++ b/src/test/ui/parser/item-free-static-no-body-semantic-fail.rs @@ -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 diff --git a/src/test/ui/parser/item-free-static-no-body-semantic-fail.stderr b/src/test/ui/parser/item-free-static-no-body-semantic-fail.stderr index 7b408323674de..4d542b79861fd 100644 --- a/src/test/ui/parser/item-free-static-no-body-semantic-fail.stderr +++ b/src/test/ui/parser/item-free-static-no-body-semantic-fail.stderr @@ -15,7 +15,7 @@ LL | static B; | help: provide a definition for the static: `= ;` 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; | ^^^^^^^^^^^^^^^^- @@ -23,12 +23,24 @@ LL | static mut C: u8; | help: provide a definition for the static: `= ;` 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: `= ;` -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: ` + +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: ` + +error: aborting due to 6 previous errors diff --git a/src/test/ui/typeck/issue-79040.rs b/src/test/ui/typeck/issue-79040.rs index af2a9c1ba87ef..941612542207c 100644 --- a/src/test/ui/typeck/issue-79040.rs +++ b/src/test/ui/typeck/issue-79040.rs @@ -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); } diff --git a/src/test/ui/typeck/issue-79040.stderr b/src/test/ui/typeck/issue-79040.stderr index 32049e5d96860..aec2e1ec9e4ef 100644 --- a/src/test/ui/typeck/issue-79040.stderr +++ b/src/test/ui/typeck/issue-79040.stderr @@ -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: ` error: aborting due to 2 previous errors