ndk-macro: Remove faulty crate name fallback in fn crate_path()#229
Conversation
`proc_macro_crate::crate_name` fails to find our `ndk-glue` crate when it sits inside `[target.'cfg(target_os = "android")'.dev-dependencies]` as shown in [RustAudio/cpal#641], with a fix pending in [bkchr/proc-macro-crate#15]. This function is only ever called with `"ndk-glue"` which is an invalid identifier and should have its dash replaced with an underscore to be valid. However, since this fallback doesn't seem to have been hit before (we've never received reports of `` `"ndk-glue"` is not a valid identifier ``) it is safe and desired to enforce the crate name to reside in `Cargo.toml` and `proc-macro-crate` being able to find it. [RustAudio/cpal#641]: https://github.com/RustAudio/cpal/runs/5203107529?check_suite_focus=true [bkchr/proc-macro-crate#15]: bkchr/proc-macro-crate#15
ea664e7 to
57078d9
Compare
|
I encountered this when trying to use this macro in a Bazel build. I was able to work around it by making a dummy |
|
@Calsign With "this isn't a valid assumption" I presume you are referring to I've recently had identical troubles with this macro, where I wanted to re-wrap Perhaps we can re-export |
|
@MarijnS95 Sorry, I was referring to the assumption that "it is safe and desired to enforce the crate name to reside in Cargo.toml and proc-macro-crate being able to find it." In non-cargo build systems there is no Cargo.toml. But I found it is easy to work around this, at least for my case, because |
|
@Calsign In that "assumption" the only important bit is that Do you think the custom |
|
I think in this case using the override is fine, I just found it very surprising and confusing at first (but this wasn't the first time with trying to use bazel). More broadly I was concerned that other things could rest on the assumption of cargo, and I just wanted to do my small part to make it easier for other to people to use non-cargo build systems in the future. |
proc_macro_crate::crate_namefails to find ourndk-gluecrate when it sits inside[target.'cfg(target_os = "android")'.dev-dependencies]as shown in RustAudio/cpal#641, with a fix pending in bkchr/proc-macro-crate#15. This function is only ever called with"ndk-glue"which is an invalid identifier and should have its dash replaced with an underscore to be valid. However, since this fallback doesn't seem to have been hit before (we've never received reports of`"ndk-glue"` is not a valid identifier) it is safe and desired to enforce the crate name to reside inCargo.tomlandproc-macro-cratebeing able to find it.