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

Compilation error with no-std + serde + validation #207

Open
Indy2222 opened this issue Feb 4, 2025 · 1 comment · May be fixed by #208
Open

Compilation error with no-std + serde + validation #207

Indy2222 opened this issue Feb 4, 2025 · 1 comment · May be fixed by #208

Comments

@Indy2222
Copy link

Indy2222 commented Feb 4, 2025

This macro #[nutype(validate(less_or_equal = 100), derive(Deserialize))] causes a compilation error when used in no_std environment. The error is due to the use of format!() macro (which depends on alloc) when reporting an error during serde de-serialization. See the minimal example in this repository: https://github.com/Indy2222/nutype-nostd-serde

Compilation error:

error: cannot find macro `format` in this scope
 --> src/lib.rs:4:1
  |
4 | #[nutype(validate(less_or_equal = 100), derive(Deserialize))]
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: this error originates in the attribute macro `nutype` (in Nightly builds, run with -Z macro-backtrace for more info)

error: could not compile `nutype-issue` (lib) due to 1 previous error

I think this should be fixed, as both Nutype and Serde support no_std environments.

@greyblake
Copy link
Owner

@Indy2222 Thank you for the report!

matoushybl added a commit to matoushybl/nutype that referenced this issue Feb 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants