-
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
improve unconditional_panic description #80578
Conversation
r? @lcnr (rust-highfive has picked a reviewer for you, use r? to override) |
📌 Commit 51cf9c32ec009a5d321e8c9d0a40523935d6c271 has been approved by |
/// 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. |
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.
/// 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
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.
Sure; what about this?
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.
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
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.
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?
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.
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
51cf9c3
to
b31400a
Compare
@bors r+ rollup |
📌 Commit b31400a has been approved by |
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
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