-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Array indexed by enum cast to usize no longer has bounds check eliminated #102303
Comments
@rustbot label +T-compiler +A-codegen +I-slow |
Regressed in #96862 |
@Dajamante is working on it |
Note that this still works: pub fn func(inbounds: &Enum, array: &[i16; 3]) -> i16 {
array[*inbounds as usize]
} So this is also the classic "LLVM doesn't have range metadata on parameters" problem. (When there's a load, it gets EDIT: Filed #102389 to discuss with lang whether that should compile. It didn't used to. |
Should that work?
But I don't see why a change in drop behavior should affect whether a value is moved or not, and of course, there is no warning. |
Example of the specific behavior with IR and using the load "workaround" https://godbolt.org/z/YK79ErY5r |
WG-prioritization assigning priority (Zulip discussion). @rustbot label -I-prioritize +P-medium |
@rustbot claim |
Rust compiler fails to eliminate bounds check when array is indexed by an enum cast to usize
Compiler explorer: https://godbolt.org/z/4o5cqT1eK
Code
I expected the compiler to remove the bounds checks like it did previously however it failed to do so.
Version it worked on
It most recently worked on: Rust 1.63.0
Version with regression
@rustbot modify labels: +regression-from-stable-to-stable -regression-untriaged
The text was updated successfully, but these errors were encountered: