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
Contributor

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 #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 was marked as outdated.

Copy link
Collaborator

commented Sep 18, 2019

r? @cramertj

(rust_highfive has picked a reviewer for you, use r? to override)

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

This comment has been minimized.

Copy link
Member

commented Sep 18, 2019

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

This comment was marked as resolved.

Copy link
Contributor Author

commented Sep 18, 2019

@Centril: I've addressed your comments.

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 Sep 18, 2019
Co-Authored-By: Mazdak Farrokhzad <twingoow@gmail.com>
Rename the existing Diverges.always method to Diverges.is_always
@Aaron1011

This comment was marked as resolved.

Copy link
Contributor Author

commented Sep 19, 2019

@Centril: I've addressed your second round of comments.

Aaron1011 and others added 2 commits Sep 19, 2019
Co-Authored-By: Mazdak Farrokhzad <twingoow@gmail.com>
@Aaron1011

This comment has been minimized.

Copy link
Contributor Author

commented Sep 19, 2019

@Centril fixed

@Centril

This comment has been minimized.

Copy link
Member

commented Sep 19, 2019

👍 @bors r+

@bors

This comment has been minimized.

Copy link
Contributor

commented Sep 19, 2019

📌 Commit d67528f has been approved by Centril

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(

This comment has been minimized.

Copy link
@estebank

estebank Sep 19, 2019

Contributor

Could you change this to be a span_label instead?

This comment has been minimized.

Copy link
@Centril

Centril Sep 19, 2019

Member

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
4 checks passed
4 checks passed
pr Build #20190919.10 succeeded
Details
pr (Linux mingw-check) Linux mingw-check succeeded
Details
pr (Linux x86_64-gnu-llvm-6.0) Linux x86_64-gnu-llvm-6.0 succeeded
Details
pr (LinuxTools) LinuxTools succeeded
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants
You can’t perform that action at this time.