-
Notifications
You must be signed in to change notification settings - Fork 34
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
proc-macro-crate is not no_std #18
Comments
Thanks for filing an issue! Can I check how this is affecting you? When we added no_std to this crate, the best research I could find was that crates used during compilation/codegen (like this one) can use std dependencies to do their work, as long as the code they generate doesn't use std. Rustc itself, for instance, uses std, but as long as it doesn't generate any code which depends on std things are fine. We added a CI job which shows that this crate can be used for targets which lack std: 455e0ee Is there a particular change you're looking for, or problem you'd like solved? |
So the weird thing is that when I built in a library, it compiled just fine (also embedded). But when using it in an executable, then it complained that that Serde was missing the std libs. I don't know why that is. I can maybe try again tomorrow and give more info. Btw, reading back my issue, I came on a bit strong. I was annoyed that it didn't work. Sorry for that! |
No worries, I totally get that frustration! If you have any way of sharing a repro case (ideally as minimal as possible), that's be really handy :) Our generated code definitely doesn't have any dependency on |
🤔 My guess is that this is due to features being additive (it is related to why
I guess the solution is to make EDIT: I have found the following references: |
I'm also trying to use this crate to build an elf for an embedded device, and is asking for the std crate. |
Same here. I'm trying to build for thumbv7m-none-eabi and I get an error about not finding std. |
Thanks @danielhenrymantilla for the solid investigation! Fix in #19 |
@diondokter @noonien @mendelt can you try adding: [patch.crates-io.num_enum]
git = "https://github.com/illicitonion/num_enum"
rev = "626dde25383685683f8e785bdbc3bd63a0afe2b5" to your |
@danielhenrymantilla Using the patch format in Cargo didn't work, but that may just be a caching error... I used the following: num_enum = { git = "https://github.com/illicitonion/num_enum", branch = "serde", default-features = false } Compilation works just fine now! |
Works for me too! |
Works here too |
The proc-macro-crate depends on toml, which in turn depends on serde _with_ std. Only depend on proc-macro-crate if std is enabled. This means that no_std consumer of num_enum cannot rename their num_enum dependency. This seems like a reasonable restriction. Works around rust-lang/cargo#5730 Fixes #18
Released to crates.io as 0.5.0 :) Thanks all for the reports, investigation, and testing! |
The proc-macro-crate pulls in the toml dependency. Toml is not compatible with no_std, so this library transitively isn't either.
The text was updated successfully, but these errors were encountered: