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

improve unconditional_panic description #80578

Merged
merged 1 commit into from
Jan 2, 2021

Conversation

RalfJung
Copy link
Member

@RalfJung RalfJung commented Jan 1, 2021

The fact that the lint is triggered by the ConstProp pass is an implementation detail, I do not think that this should be mentioned in the description.

Cc @oli-obk @ehuss

@rust-highfive
Copy link
Collaborator

r? @lcnr

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jan 1, 2021
@oli-obk
Copy link
Contributor

oli-obk commented Jan 1, 2021

r? @oli-obk

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Jan 1, 2021

📌 Commit 51cf9c32ec009a5d321e8c9d0a40523935d6c271 has been approved by oli-obk

@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 Jan 1, 2021
/// compile-time, and instead continue to generate code to evaluate at
/// runtime, which may panic during runtime.
/// This lint detects code that is very likely incorrect because it will always panic, e.g.
/// division by zero and out-of-bounds array accesses.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// division by zero and out-of-bounds array accesses.
/// division by zero and out-of-bounds array accesses. Consider adjusting your code or,
/// in case the panic is intended, using the `panic!` or `unreachable!` macro instead.

do you think this would be helpful here to be make the explanation a bit more helpful?
Mostly locked at the arithmetic_overflow lint for reference

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure; what about this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that the only time I have actually encountered this in the wild, adjusting the code was not an option, but allowing the lint was the right way. This is in performance sensitive code that should only have debug assertions if the main crate has debug assertions on, but the code was in core: https://github.com/rust-lang/rust/blob/master/library/core/src/iter/range.rs#L204-L208

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's just a hack because we have this "overflow check inherited from root crate" but we don't have the same for debug_assert!, right?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yea, that's indeed a hack for this. Maybe we should crate an intrinsic replacement for cfg(debug_assertions) that has the same inheriting behaviour

@RalfJung RalfJung force-pushed the panic-lint-description branch from 51cf9c3 to b31400a Compare January 1, 2021 14:00
@lcnr
Copy link
Contributor

lcnr commented Jan 1, 2021

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Jan 1, 2021

📌 Commit b31400a has been approved by lcnr

bors added a commit to rust-lang-ci/rust that referenced this pull request Jan 2, 2021
Rollup of 6 pull requests

Successful merges:

 - rust-lang#80546 (clippy fixes for librustdoc)
 - rust-lang#80555 (Improve library tracking issue template)
 - rust-lang#80574 (Clean bootstrap artifacts on `x.py clean`)
 - rust-lang#80578 (improve unconditional_panic description)
 - rust-lang#80599 (`const_generics_defaults`: don't ICE in the unimplemented parts)
 - rust-lang#80613 (Diag: print enum variant instead of enum type)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit bb70305 into rust-lang:master Jan 2, 2021
@rustbot rustbot added this to the 1.51.0 milestone Jan 2, 2021
@RalfJung RalfJung deleted the panic-lint-description branch January 3, 2021 16:20
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
Development

Successfully merging this pull request may close these issues.

6 participants