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

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

Closed
pnkfelix opened this issue Oct 8, 2013 · 1 comment · Fixed by #30729
Closed

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

pnkfelix opened this issue Oct 8, 2013 · 1 comment · Fixed by #30729
Labels
A-frontend Area: Compiler frontend (errors, parsing and HIR) C-cleanup Category: PRs that clean code up or issues documenting cleanup.

Comments

@pnkfelix
Copy link
Member

pnkfelix commented Oct 8, 2013

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/ )

@steveklabnik
Copy link
Member

Triage: this is still true today.

fn mk_fresh_ident_interner() -> IdentInterner {

huonw added a commit to huonw/rust that referenced this issue Jan 6, 2016
The fundamental problem of duplication was fixed in rust-lang#10891, but the comment was preserved. Closes rust-lang#9762.
steveklabnik added a commit to steveklabnik/rust that referenced this issue Jan 6, 2016
The fundamental problem of duplication was fixed in rust-lang#10891, but the comment was preserved. Closes rust-lang#9762.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-frontend Area: Compiler frontend (errors, parsing and HIR) C-cleanup Category: PRs that clean code up or issues documenting cleanup.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants