Skip to content

magic numbers in token.rs should be static constants #9762

Closed
@pnkfelix

Description

@pnkfelix

There's a large table of special identifiers and (reserved/strict/etc) keywords in mk_fresh_ident_interners.

There is a note that the indices need to match up with the numbers in special_idents.

In addition, though, there are uses of the numbers in match arms within the code, and there is evidence that the numbers are not being kept up to date.

Why aren't we at least binding the magic numbers to static constants in a single place (presumably near the table in mk_fresh_ident_interners and then referencing those named constants instead?

(Or alternatively, we might have the const expressions in the match arms reference the already present static Ident definitions, e.g. self_.name ... but for that, we would need to support x.y as a const expression.)

(More elaborate discussion available in IRC log: https://botbot.me/mozilla/rust-internals/msg/6710787/ )

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-frontendArea: Compiler frontend (errors, parsing and HIR)C-cleanupCategory: PRs that clean code up or issues documenting cleanup.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions