Skip to content
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

Merged
merged 8 commits into from
Sep 20, 2019

Conversation

Aaron1011
Copy link
Member

@Aaron1011 Aaron1011 commented Sep 18, 2019

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.

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.
@rust-highfive

This comment has been minimized.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 18, 2019
src/librustc_typeck/check/mod.rs Outdated Show resolved Hide resolved
src/librustc_typeck/check/mod.rs Outdated Show resolved Hide resolved
src/test/ui/reachable/expr_match.stderr Show resolved Hide resolved
src/test/ui/reachable/expr_return_in_macro.rs Outdated Show resolved Hide resolved
@Centril
Copy link
Contributor

Centril commented Sep 18, 2019

r? @Centril

@rust-highfive rust-highfive assigned Centril and unassigned cramertj Sep 18, 2019
@Aaron1011

This comment has been minimized.

src/librustc_typeck/check/_match.rs Outdated Show resolved Hide resolved
src/librustc_typeck/check/_match.rs Outdated Show resolved Hide resolved
src/librustc_typeck/check/_match.rs Outdated Show resolved Hide resolved
src/librustc_typeck/check/_match.rs Outdated Show resolved Hide resolved
src/librustc_typeck/check/_match.rs Outdated Show resolved Hide resolved
src/librustc_typeck/check/mod.rs Outdated Show resolved Hide resolved
src/librustc_typeck/check/mod.rs Outdated Show resolved Hide resolved
src/librustc_typeck/check/mod.rs Outdated Show resolved Hide resolved
src/librustc_typeck/check/mod.rs Outdated Show resolved Hide resolved
src/librustc_typeck/check/mod.rs Outdated Show resolved Hide resolved
Aaron1011 and others added 3 commits September 18, 2019 19:48
Co-Authored-By: Mazdak Farrokhzad <[email protected]>
Rename the existing Diverges.always method to Diverges.is_always
@Aaron1011

This comment has been minimized.

@Aaron1011
Copy link
Member Author

@Centril fixed

@Centril
Copy link
Contributor

Centril commented Sep 19, 2019

👍 @bors r+

@bors
Copy link
Contributor

bors commented Sep 19, 2019

📌 Commit d67528f has been approved by Centril

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 19, 2019
Centril added a commit to Centril/rust that referenced this pull request Sep 19, 2019
… 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.
bors added a commit that referenced this pull request Sep 19, 2019
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(
Copy link
Contributor

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?

Copy link
Contributor

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?

bors added a commit that referenced this pull request Sep 19, 2019
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
@bors bors merged commit d67528f into rust-lang:master Sep 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
6 participants