Skip to content

Regression: usize to u32 conversion could not be compiled now #615

Description

@tuguzT

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),
      |                ^
...

Activity

  1. nazar-pc commented on Jun 12, 2026

    @nazar-pc
    Contributor

    I think I'm getting the same. Clippy is fine, but actual compilation is not:

    error: cannot offset a pointer to an arbitrary element
       --> </home/nazar-pc/.cache/rustup/toolchains/nightly-2026-05-22-x86_64-unknown-linux-gnu/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`
       --> </home/nazar-pc/.cache/rustup/toolchains/nightly-2026-05-22-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/convert/num.rs>:454:5
        |
    454 |     impl_try_from_unbounded!(usize => u32, u64, u128);
        |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    note: called by `<core::iter::adapters::step_by::StepBy<core::ops::range::Range<u32>> as core::iter::adapters::step_by::StepByImpl<core::ops::range::Range<u32>>>::spec_next`
       --> </home/nazar-pc/.cache/rustup/toolchains/nightly-2026-05-22-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/iter/adapters/step_by.rs>:574:1
        |
    574 | spec_int_ranges!(u8 u16 u32 usize);
        | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    note: called by `<core::iter::adapters::step_by::StepBy<core::ops::range::Range<u32>> as core::iter::traits::iterator::Iterator>::next`
       --> </home/nazar-pc/.cache/rustup/toolchains/nightly-2026-05-22-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/iter/adapters/step_by.rs>:59:14
        |
     59 |         self.spec_next()
        |              ^^^^^^^^^^^
    note: called by `ab_proof_of_space_gpu::shader::find_proofs::find_local_proof_targets::<1>`
       --> <crates/farmer/ab-proof-of-space-gpu/src/shader/find_proofs.rs>:113:9
        |
    113 | /         for index in (subgroup_local_invocation_id..bucket_size).step_by(SUBGROUP_SIZE as usize) {
    114 | |             let proof_targets = bucket[index as usize];
    115 | |             if proof_targets.absolute_position < local_min_absolute_position[0] {
    116 | |                 local_min_absolute_position[0] = proof_targets.absolute_position;
    ...   |
    119 | |         }
        | |_________^
    

    #612 has the same issue as well.

  2. added a commit that references this issue on Jun 14, 2026
    fb1d7d4
  3. LegNeato commented on Jun 14, 2026

    @LegNeato
    Collaborator

    If ya'll could confirm #616 fixes it that would be great!

  4. added 2 commits that reference this issue on Jun 14, 2026
    138d04a
    dfdd6e0
  5. added a commit that references this issue on Jun 22, 2026
    67f1ff2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions