google / zerocopy

https://discord.gg/MAvWH2R6zk
Apache License 2.0
1.46k stars 95 forks source link

Zerocopy Derives Use core Namespace Instead of ::core #1536

Closed Aleksbgbg closed 2 weeks ago

Aleksbgbg commented 2 months ago

Would it be possible to adjust zerocopy's macros to disambiguate the root core namespace (by using ::core instead of core everywhere)? I'm working on a project where there is a crate::core namespace which causes failures when the derive macros are evaluated.

jswrenn commented 2 months ago

Yes, that's absolutely possible and we strive to do it everywhere already. If we've missed a spot, that's a minor soundness bug.

What version of zerocopy are you using? Is there a particular macro that you're having trouble with?

Aleksbgbg commented 2 months ago

I am running into this on zerocopy 0.7.35 and Rust Nightly 1.82.0. Strangely, I tried to reproduce this just now and could no longer do so on Windows (the last time I tried this was ~2 months ago), however when I uploaded my code to GitLab, it failed to build on the Linux docker container running on the build server: https://gitlab.com/Aleksbgbg/opencraft/-/jobs/7443005160. The change that switches to using zerocopy and fails the build can be viewed at https://gitlab.com/Aleksbgbg/opencraft/-/commit/f372e3449ec162b4f7e9e7250fb2a8c05b0fb7bc, it is only a small diff.

Note also #[derive(AsBytes)] is only failing in opencraft/src/main.rs where mod core; is present (not in opencraft/src/core/math/mat4.rs). The error complains about core::mem missing, which is of course the case as my core module does not have a mem module.

joshlf commented 3 weeks ago

Are you still seeing this issue? If so, does it work on 0.8.0-alpha.22? We are about to release 0.8 stably, at which point we will stop actively maintaining 0.7.

Aleksbgbg commented 2 weeks ago

I no longer see the issue in 0.8.0-alpha.25 :)

joshlf commented 2 weeks ago

Awesome, thanks for following up!