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

schemars::gen module name from 0.8.x is incompatible with 2024 edition #377

Open
woody77 opened this issue Feb 21, 2025 · 2 comments
Open

Comments

@woody77
Copy link

woody77 commented Feb 21, 2025

The 2024 edition now reserves gen as a keyword: https://doc.rust-lang.org/edition-guide/rust-2024/gen-keyword.html

This makes it difficult to use schemars from crates switching to the 2024 edition.

error: expected identifier, found reserved keyword `gen`
  --> ../../src/lib/assembly/util/src/paths.rs:63:16
   |
63 | fn path_schema(gen: &mut schemars::gen::SchemaGenerator) -> schemars::schema::Schema {
   |                ^^^ expected identifier, found reserved keyword
   |
help: escape `gen` to use it as an identifier
   |
63 | fn path_schema(r#gen: &mut schemars::gen::SchemaGenerator) -> schemars::schema::Schema {
   |                ++
@woody77 woody77 changed the title schemars::gen module name is incompatible with 2024 edition schemars::gen module name from 0.8.x is incompatible with 2024 edition Feb 21, 2025
@woody77
Copy link
Author

woody77 commented Feb 21, 2025

It looks like some escaping needs to be added to the derive macro here:
https://github.com/GREsau/schemars/blob/v0/schemars_derive/src/lib.rs#L71-L77

havasd added a commit to havasd/schemars that referenced this issue Feb 23, 2025
havasd added a commit to havasd/schemars that referenced this issue Feb 24, 2025
havasd added a commit to havasd/schemars that referenced this issue Feb 24, 2025
havasd added a commit to havasd/schemars that referenced this issue Feb 24, 2025
GREsau pushed a commit that referenced this issue Feb 25, 2025
eval-exec pushed a commit to eval-exec/schemars that referenced this issue Feb 27, 2025
@SimonSapin
Copy link

#376 and v0.8.22 changed the code emitted by proc macros to use r#gen raw identifier syntax so that it’s now possible (even if not pretty) to do the same in user code and use the 2024 edition. cargo --fix --edition can help make that change automatically.

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

No branches or pull requests

2 participants