Repository navigation
Regression: usize to u32 conversion could not be compiled now #615
Copy link
Copy link
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Before updating to nightly-2026-05-22, inline integer convertions like u32::try_from(usize_value).ok().unwrap() used to work, but after an update these are failing with such message:
error: cannot offset a pointer to an arbitrary element
--> <...\.rustup\toolchains\nightly-2026-05-22-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\core\src\convert\num.rs>:454:5
|
454 | impl_try_from_unbounded!(usize => u32, u64, u128);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: used from within `<u32 as core::convert::TryFrom<usize>>::try_from`
--> <...\.rustup\toolchains\nightly-2026-05-22-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\core\src\convert\num.rs>:454:5
|
454 | impl_try_from_unbounded!(usize => u32, u64, u128);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...
error: cannot cast between pointer types
from `*struct core::result::Result<u32, core::num::TryFromIntError> { discriminant: bool }`
to `*u8`
--> <...\.rustup\toolchains\nightly-2026-05-22-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\core\src\convert\num.rs>:454:5
|
454 | impl_try_from_unbounded!(usize => u32, u64, u128);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: used from within `<u32 as core::convert::TryFrom<usize>>::try_from`
--> <...\.rustup\toolchains\nightly-2026-05-22-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\core\src\convert\num.rs>:454:5
|
454 | impl_try_from_unbounded!(usize => u32, u64, u128);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...
error: cannot cast between pointer types
from `*u8`
to `*u32`
--> <...\.rustup\toolchains\nightly-2026-05-22-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\core\src\convert\num.rs>:454:5
|
454 | impl_try_from_unbounded!(usize => u32, u64, u128);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: used from within `<u32 as core::convert::TryFrom<usize>>::try_from`
--> <...\.rustup\toolchains\nightly-2026-05-22-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\core\src\convert\num.rs>:454:5
|
454 | impl_try_from_unbounded!(usize => u32, u64, u128);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...
error: cannot offset a pointer to an arbitrary element
--> <...\.rustup\toolchains\nightly-2026-05-22-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\core\src\result.rs>:714:16
|
714 | Ok(x) => Some(x),
| ^
|
note: used from within `<core::result::Result<u32, core::num::error::TryFromIntError>>::ok`
--> <...\.rustup\toolchains\nightly-2026-05-22-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\core\src\result.rs>:714:16
|
714 | Ok(x) => Some(x),
| ^
...
error: cannot cast between pointer types
from `*struct core::result::Result<u32, core::num::TryFromIntError> { discriminant: bool }`
to `*u8`
--> <...\.rustup\toolchains\nightly-2026-05-22-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\core\src\result.rs>:714:16
|
714 | Ok(x) => Some(x),
| ^
|
note: used from within `<core::result::Result<u32, core::num::error::TryFromIntError>>::ok`
--> <...\.rustup\toolchains\nightly-2026-05-22-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\core\src\result.rs>:714:16
|
714 | Ok(x) => Some(x),
| ^
...
error: cannot cast between pointer types
from `*u8`
to `*u32`
--> <...\.rustup\toolchains\nightly-2026-05-22-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\core\src\result.rs>:714:16
|
714 | Ok(x) => Some(x),
| ^
|
note: used from within `<core::result::Result<u32, core::num::error::TryFromIntError>>::ok`
--> <...\.rustup\toolchains\nightly-2026-05-22-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\core\src\result.rs>:714:16
|
714 | Ok(x) => Some(x),
| ^
...
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working
Activity
nazar-pc commentedon Jun 12, 2026
I think I'm getting the same. Clippy is fine, but actual compilation is not:
#612 has the same issue as well.
Fix codegen of Memory-repr enum payload accesses
LegNeato commentedon Jun 14, 2026
If ya'll could confirm #616 fixes it that would be great!
Fix codegen of Memory-repr enum payload accesses
Fix codegen of Memory-repr enum payload accesses
Fix codegen of Memory-repr enum payload accesses