-
Notifications
You must be signed in to change notification settings - Fork 13.4k
For const variable declaration, if type is left dangling, also suggest type #100146
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
cc @WaffleLapkin who knows how to do this since he worked on that |
@rustbot claim |
@Rageking8 what you've meant by a type that's left dangling? |
Basically just that the colon is included but no type is specified. |
This is because if we have colon, the parser will try to parse a type, then error will trigger. const a = 123
=>
const a: _ = 123 Then type checker will enrich the type messages. https://github.com/rust-lang/rust/blob/master/compiler/rustc_parse/src/parser/item.rs#L1183 I'm thinking on the solution. |
@WaffleLapkin |
@chenyukang oh, I've had a fix too, oops 😅 I've opened a PR already: #100168, but feel free to open a PR as well, if you think your approach might be better. |
My fix is shorter, but seems a little bit hacky 😁 |
Uh oh!
There was an error while loading. Please reload this page.
Given the following code:
The current output is:
Since the compiler suggests the type needed for the following:
The output ideally should also suggest the type if its left dangling.
The text was updated successfully, but these errors were encountered: