-
Notifications
You must be signed in to change notification settings - Fork 13k
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
three diagnostics upgrades #51750
three diagnostics upgrades #51750
Conversation
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
fcdf08d
to
1658449
Compare
src/librustc_typeck/check/cast.rs
Outdated
"type ascription or " | ||
} else { | ||
"" | ||
}; | ||
if t_cast.is_numeric() && t_expr.is_numeric() { |
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.
The only difference between the two branches is the lint ID and the word numeric
, can you pull those out into variables and only make a single error emitting call?
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.
done
Now that `..=` inclusive ranges are stabilized, people probably shouldn't be using `...` even in patterns, even if it's still legal there (see rust-lang#51043). To avoid drawing attention to `...` being a real thing, let's reword this message to just say "unexpected token" rather "cannot be used in expressions".
The top level message shouldn't be too long; the replaced-by-coercion/temporary-variable advice can live in a note. Also, don't mention type ascription when it's not actually available as a real thing. (The current state of discussion on the type ascription tracking issue rust-lang#23416 makes one rather suspect it will never be a stable thing in its current form, but that's not for us to adjudicate in this commit.) While we're here, yank out the differentiating parts of the numeric/other conditional and only have one codepath emitting the diagnostic.
1658449
to
0b39a82
Compare
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
@bors roll to disbelieve |
@bors r+ |
📌 Commit 0b39a82 has been approved by |
three diagnostics upgrades * reword `...` expression syntax error to not imply that you should use it in patterns either (#51043) and make it a structured suggestion * shorten the top-line message for the trivial-casts lint by tucking the advisory sentence into a help note * structured suggestion for pattern-named-the-same-as-variant warning r? @oli-obk
☀️ Test successful - status-appveyor, status-travis |
...
expression syntax error to not imply that you should use it in patterns either (rewrite...
to..=
as an idiom lint for Rust 2018 edition #51043) and make it a structured suggestionr? @oli-obk