Skip to content

gen is a keyword in edition 2024 #1554

@jaskij

Description

@jaskij

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions