-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Skip lint for assertion evaluated to false #119958
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @oli-obk (or someone else) soon. Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (
|
Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt |
The job Click to see the possible cause of the failure (guessed by this bot)
|
fn main() { | ||
let x: [i32; 0] = []; | ||
if x.len() > 0 { | ||
x[0]; |
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.
does this trigger an unreachable/dead code warning?
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.
Nope, lint is omitted for the whole block, as it will never run anyway.
Your change disables all lints on slice length check assertions. I don't think this issue can easily be fixed, although we can special case |
Note that such a change will be much simpler to do after #119627 lands |
☔ The latest upstream changes (presumably #119627) made this pull request unmergeable. Please resolve the merge conflicts. |
The other PR has landed. Thinking about it a bit more, we may not need a special value at all. You could implemenent an arm for
[T]::len method to detect that it's a call to that. If it is, just check the self type and extract the length in case it is an array. There may be some casts involved, so you may also need to implement some sort of helper for unsizing casts (which could probably be a PR on its own, but not sure we can write a test that will actually be affected).
|
@barabadzhi any updates on this? thanks |
Closing this as inactive. Feel free to reöpen this pr or create a new pr if you get the time to work on this. Thanks |
fixes #119908