We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
I tried this code:
pub fn reg_name(x: RegisterNo) -> &'static str { NAME[x as usize] } const NAME: [&'static str; 8] = [ "al", "cl", "dl", "bl", "ah", "ch", "dh", "bh" ]; #[repr(i8)] pub enum RegisterNo { AL = 0, CL = 1, DL = 2, BL = 3, AH = 4, CH = 5, DH = 6, BH = 7, }
I expected to see this happen: all range checks would be eliminated and function would be panic-free.
Instead, this happened: range checks are still there and function is no longer panic-free.
It most recently worked on: 1.63
rustc --version --verbose:
rustc --version --verbose
rustc 1.64.0 (a55dd71d5 2022-09-19) binary: rustc commit-hash: a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52 commit-date: 2022-09-19 host: x86_64-unknown-linux-gnu release: 1.64.0 LLVM version: 14.0.6
Workaround that currently works is to use NAME[x as usize & 0x7].
NAME[x as usize & 0x7]
But this seems strange, wrong, and shouldn't be necessary (it worked in the past!).
The text was updated successfully, but these errors were encountered:
This is fixed in 1.67.0 (#103584), which was released a few days ago. Godbolt just isn't updated yet.
Sorry, something went wrong.
Playground confirms this is fixed on stable (1.67.0): https://play.rust-lang.org/?version=stable&mode=release&edition=2021&gist=d7b5d65a8e0c13005d2b1ce4fa773801
playground::reg_name: movzx ecx, dil shl rcx, 4 lea rdx, [rip + .L__unnamed_1] mov rax, qword ptr [rcx + rdx] mov rdx, qword ptr [rcx + rdx + 8] ret
(And it's still fixed in nightly (2023-01-27) too.)
No branches or pull requests
Code
I tried this code:
I expected to see this happen: all range checks would be eliminated and function would be panic-free.
Instead, this happened: range checks are still there and function is no longer panic-free.
Version it worked on
It most recently worked on: 1.63
Version with regression
rustc --version --verbose
:Workaround that currently works is to use
NAME[x as usize & 0x7]
.But this seems strange, wrong, and shouldn't be necessary (it worked in the past!).
The text was updated successfully, but these errors were encountered: