-
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
Point at original span when emitting unreachable lint #64592
Conversation
Fixes rust-lang#64590 When we emit an 'unreachable' lint, we now add a note pointing at the expression that actually causes the code to be unreachable (e.g. `return`, `break`, `panic`). This is especially useful when macros are involved, since a diverging expression might be hidden inside of a macro invocation.
This comment has been minimized.
This comment has been minimized.
r? @Centril |
This comment has been minimized.
This comment has been minimized.
Co-Authored-By: Mazdak Farrokhzad <[email protected]>
Rename the existing Diverges.always method to Diverges.is_always
This comment has been minimized.
This comment has been minimized.
Co-Authored-By: Mazdak Farrokhzad <[email protected]>
@Centril fixed |
👍 @bors r+ |
📌 Commit d67528f has been approved by |
… r=Centril Point at original span when emitting unreachable lint Fixes rust-lang#64590 When we emit an 'unreachable' lint, we now add a note pointing at the expression that actually causes the code to be unreachable (e.g. `return`, `break`, `panic`). This is especially useful when macros are involved, since a diverging expression might be hidden inside of a macro invocation.
Rollup of 6 pull requests Successful merges: - #63448 (fix Miri discriminant handling) - #64592 (Point at original span when emitting unreachable lint) - #64601 (Fix backticks in documentation) - #64606 (Remove unnecessary `mut` in doc example) - #64611 (rustbuild: Don't package libstd twice) - #64613 (rustbuild: Copy crate doc files fewer times) Failed merges: r? @ghost
self.tcx().lint_hir(lint::builtin::UNREACHABLE_CODE, id, span, &msg); | ||
let msg = format!("unreachable {}", kind); | ||
self.tcx().struct_span_lint_hir(lint::builtin::UNREACHABLE_CODE, id, span, &msg) | ||
.span_note( |
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.
Could you change this to be a span_label
instead?
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.
Let's do it in a follow up since my rollup is running. :)
Also, @Aaron1011, can you look at @estebank's PR #64624 and close the relevant additional issues?
Rollup of 6 pull requests Successful merges: - #63448 (fix Miri discriminant handling) - #64592 (Point at original span when emitting unreachable lint) - #64601 (Fix backticks in documentation) - #64606 (Remove unnecessary `mut` in doc example) - #64611 (rustbuild: Don't package libstd twice) - #64613 (rustbuild: Copy crate doc files fewer times) Failed merges: r? @ghost
Fix #39858, CC #46426, CC #57377, fix #60394, fix #64590.
When we emit an 'unreachable' lint, we now add a note pointing at the
expression that actually causes the code to be unreachable (e.g.
return
,break
,panic
).This is especially useful when macros are involved, since a diverging
expression might be hidden inside of a macro invocation.