Skip to content
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

cannot cast between pointer types: from *f32x2, to *struct ... in latest versions of rust-gpu #160

Closed
tombh opened this issue Nov 27, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@tombh
Copy link

tombh commented Nov 27, 2024

Expected Behaviour

At some point after September 6th (#4c633aec) the following code stopped compiling.

pub struct Particles {
    pub indices: Indices,
    pub data: [Particle; MAX_PARTICLES_IN_CELL * REQUIRED_CELLS],
    pub centre_count: usize,
}

impl Particles {
    pub fn new(
        ...
    ) -> Self {
        let mut particles = Self {
            data: [Particle::default(); MAX_PARTICLES_IN_CELL * REQUIRED_CELLS], // error here
            ...
        };

Example & Steps To Reproduce

I'm compiling with latest cargo-gpu (Rust-GPU/cargo-gpu@4623ccb) and the full error is:

error: cannot cast between pointer types
       from `*f32x2`
         to `*struct particle::Particle { position: f32x2, velocity: f32x2, index: u32 }`
   --> shaders/physics/src/particles.rs:56:19
    |
56  |             data: [Particle::default(); MAX_PARTICLES_IN_CELL * REQUIRED_CELLS],
    |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

I'm happy to bisect to find the exact commit that introduces the change, but just wondering if anybody already knows what the problem is?

@tombh tombh added the bug Something isn't working label Nov 27, 2024
@LegNeato
Copy link
Collaborator

LegNeato commented Nov 28, 2024

Thanks for the report! This might be #46 ? If so the linked PR where it was discovered has a workaround that may work.

@tombh
Copy link
Author

tombh commented Nov 28, 2024

Ah yes, indeed that's it. Thank you ✨

@tombh tombh closed this as completed Nov 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants