-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve diagnostics for const a: = expr;
#100168
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,10 +17,10 @@ LL | | } | |
= note: this error originates in the macro `suite` (in Nightly builds, run with -Z macro-backtrace for more info) | ||
|
||
error: missing type for `const` item | ||
--> $DIR/issue-69396-const-no-type-in-macro.rs:4:19 | ||
--> $DIR/issue-69396-const-no-type-in-macro.rs:4:20 | ||
| | ||
LL | const A = "A".$fn(); | ||
| ^ help: provide a type for the constant: `A: usize` | ||
| ^ help: provide a type for the constant: `: usize` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks kinda off, IMHO: suggestion talks about type but suggest not var+type, not type, but something in between: colon+type. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think old style is better, and also seems more consistant with other suggestions in rustc. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If anything this could be fixed by bumping to a verbose diagnostic, but I don't think this is necessarily a regression. |
||
... | ||
LL | / suite! { | ||
LL | | len; | ||
|
@@ -31,13 +31,13 @@ LL | | } | |
= note: this error originates in the macro `suite` (in Nightly builds, run with -Z macro-backtrace for more info) | ||
|
||
error[E0121]: the placeholder `_` is not allowed within types on item signatures for constants | ||
--> $DIR/issue-69396-const-no-type-in-macro.rs:4:19 | ||
--> $DIR/issue-69396-const-no-type-in-macro.rs:4:20 | ||
| | ||
LL | const A = "A".$fn(); | ||
| ^ | ||
| | | ||
| not allowed in type signatures | ||
| help: replace with the correct type: `bool` | ||
| ^ | ||
| | | ||
| not allowed in type signatures | ||
| help: replace with the correct type: `bool` | ||
... | ||
LL | / suite! { | ||
LL | | len; | ||
|
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 | ||
|
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 | ||
|
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 | ||
} |
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 | ||
} |
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 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
match bool 💀