Improve diagnostics for const a: = expr;#100168
Conversation
compiler-errors
left a comment
There was a problem hiding this comment.
Thanks @WaffleLapkin
| }; | ||
| let mut err = self.struct_span_err(id.span, &format!("missing type for `{kind}` item")); | ||
|
|
||
| let colon = match colon_present { |
|
@bors r+ |
| | | ||
| 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.
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.
I think old style is better, and also seems more consistant with other suggestions in rustc.
There was a problem hiding this comment.
If anything this could be fixed by bumping to a verbose diagnostic, but I don't think this is necessarily a regression.
Rollup of 6 pull requests Successful merges: - rust-lang#99835 (Suggest adding/removing `ref` for binding patterns) - rust-lang#100155 (Use `node_type_opt` to skip over generics that were not expected) - rust-lang#100157 (rustdoc: use `collect()` instead of repeatedly pushing) - rust-lang#100158 (kmc-solid: Add a stub implementation of rust-lang#98246 (`File::set_times`)) - rust-lang#100166 (Remove more Clean trait implementations) - rust-lang#100168 (Improve diagnostics for `const a: = expr;`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
|
@GrigorenkoPV would you like to fix that up?.. Also, how did you stumble upon this on a >3 year old PR? |
Sure, I'll put up a PR.
Had to update the test while working on #149738 and was trying to figure out what it was even supposed to be testing. |
…eLapkin Rename some issue-* tests Also fixes one incorrect issue number: rust-lang#100168 (comment)
…eLapkin Rename some issue-* tests Also fixes one incorrect issue number: rust-lang#100168 (comment)
Rollup merge of #149770 - GrigorenkoPV:tests/consts, r=WaffleLapkin Rename some issue-* tests Also fixes one incorrect issue number: #100168 (comment)
Rename some issue-* tests Also fixes one incorrect issue number: rust-lang/rust#100168 (comment)
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 #100146
r? @compiler-errors