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

gen is a keyword in edition 2024 #1554

Closed
jaskij opened this issue Jan 15, 2025 · 2 comments
Closed

gen is a keyword in edition 2024 #1554

jaskij opened this issue Jan 15, 2025 · 2 comments

Comments

@jaskij
Copy link

jaskij commented Jan 15, 2025

playground link

As in the title, when trying to use Rng::gen() I'm getting a compilation error:

error: `gen` is a keyword in the 2024 edition
  --> libraries/database/src/tests/insert_generic_metrics.rs:26:51
   |
26 |             value: GenericMetricValue::Number(rng.gen()),
   |                                                   ^^^ help: you can use a raw identifier to stay compatible: `r#gen`
   |
   = warning: this is accepted in the current edition (Rust 2021) but is a hard error in Rust 2024!
   = note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716>
   = note: `-F keyword-idents-2024` implied by `-F keyword-idents`

Using a raw identifier as a workaround is fine, but I believe there should be a new name for the method (generate()?).

Since this could lead to a breaking API change, it may be worth holding back #1165 until there is a decision what to do.

@josephlr
Copy link
Member

Duplicate of #1435 (this has already been done for 0.9)

@dhardy
Copy link
Member

dhardy commented Jan 16, 2025

Yes. Unfortunately since 0.9 still isn't out, I can only recommend trying rand = "=0.9.0-beta.3".

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

3 participants