forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#100168 - WaffleLapkin:improve_diagnostics_f…
…or_missing_type_in_a_const_item, r=compiler-errors Improve diagnostics for `const a: = expr;` Adds a suggestion to write a type when there is a colon, but the type is not present. I've also shrunk spans a little, so the suggestions are a little nicer. Resolves rust-lang#100146 r? `@compiler-errors`
- Loading branch information
Showing
16 changed files
with
109 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
error: missing type for `const` item | ||
--> $DIR/issue-89574.rs:2:11 | ||
--> $DIR/issue-89574.rs:2:22 | ||
| | ||
LL | const EMPTY_ARRAY = []; | ||
| ^^^^^^^^^^^ help: provide a type for the item: `EMPTY_ARRAY: <type>` | ||
| ^ help: provide a type for the item: `: <type>` | ||
|
||
error: aborting due to previous error | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,44 @@ | ||
error: missing type for `const` item | ||
--> $DIR/const-no-type.rs:33:7 | ||
--> $DIR/const-no-type.rs:33:8 | ||
| | ||
LL | const C = 42; | ||
| ^ help: provide a type for the constant: `C: i32` | ||
| ^ help: provide a type for the constant: `: i32` | ||
|
||
error: missing type for `const` item | ||
--> $DIR/const-no-type.rs:38:7 | ||
--> $DIR/const-no-type.rs:38:8 | ||
| | ||
LL | const D = &&42; | ||
| ^ help: provide a type for the constant: `D: &&i32` | ||
| ^ help: provide a type for the constant: `: &&i32` | ||
|
||
error: missing type for `static` item | ||
--> $DIR/const-no-type.rs:43:8 | ||
--> $DIR/const-no-type.rs:43:9 | ||
| | ||
LL | static S = Vec::<String>::new(); | ||
| ^ help: provide a type for the static variable: `S: Vec<String>` | ||
| ^ help: provide a type for the static variable: `: Vec<String>` | ||
|
||
error: missing type for `static mut` item | ||
--> $DIR/const-no-type.rs:48:12 | ||
--> $DIR/const-no-type.rs:48:14 | ||
| | ||
LL | static mut SM = "abc"; | ||
| ^^ help: provide a type for the static variable: `SM: &str` | ||
| ^ help: provide a type for the static variable: `: &str` | ||
|
||
error: missing type for `const` item | ||
--> $DIR/const-no-type.rs:14:7 | ||
--> $DIR/const-no-type.rs:14:9 | ||
| | ||
LL | const C2 = 42; | ||
| ^^ help: provide a type for the item: `C2: <type>` | ||
| ^ help: provide a type for the item: `: <type>` | ||
|
||
error: missing type for `static` item | ||
--> $DIR/const-no-type.rs:20:8 | ||
--> $DIR/const-no-type.rs:20:10 | ||
| | ||
LL | static S2 = "abc"; | ||
| ^^ help: provide a type for the item: `S2: <type>` | ||
| ^ help: provide a type for the item: `: <type>` | ||
|
||
error: missing type for `static mut` item | ||
--> $DIR/const-no-type.rs:26:12 | ||
--> $DIR/const-no-type.rs:26:15 | ||
| | ||
LL | static mut SM2 = "abc"; | ||
| ^^^ help: provide a type for the item: `SM2: <type>` | ||
| ^ help: provide a type for the item: `: <type>` | ||
|
||
error: aborting due to 7 previous errors | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// run-rustfix | ||
|
||
const _A: i32 = 123; | ||
//~^ ERROR: missing type for `const` item | ||
|
||
fn main() { | ||
const _B: i32 = 123; | ||
//~^ ERROR: missing type for `const` item | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// run-rustfix | ||
|
||
const _A: = 123; | ||
//~^ ERROR: missing type for `const` item | ||
|
||
fn main() { | ||
const _B: = 123; | ||
//~^ ERROR: missing type for `const` item | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
error: missing type for `const` item | ||
--> $DIR/issue-100164.rs:3:10 | ||
| | ||
LL | const _A: = 123; | ||
| ^ help: provide a type for the constant: `i32` | ||
|
||
error: missing type for `const` item | ||
--> $DIR/issue-100164.rs:7:14 | ||
| | ||
LL | const _B: = 123; | ||
| ^ help: provide a type for the constant: `i32` | ||
|
||
error: aborting due to 2 previous errors | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters