-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Overhaul keyword handling #134253
Overhaul keyword handling #134253
Conversation
HIR ty lowering was modified cc @fmease Some changes occurred in src/tools/rustfmt cc @rust-lang/rustfmt Some changes occurred in src/tools/clippy cc @rust-lang/clippy Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt |
This comment was marked as resolved.
This comment was marked as resolved.
b3dc14a
to
0bbbe89
Compare
0bbbe89
to
a6679b4
Compare
Best reviewed one commit at a time. |
@nnethercote I haven't looked at this in detail just yet, just a quick question: does this PR adjust how contextual keywords like |
No. The only potential behavioural changes are that some of the (non)keywords (e.g. |
Summary: there are many changes here that I wouldn't want to merge. |
(Unassigning myself as petrochenkov is already looking at it) |
a6679b4
to
6a69d7b
Compare
@petrochenkov: your definition of "keyword" doesn't align with that given by the language Reference, or the Ferrocene spec, or the terminology used by the compiler's error messages. But I have zero interest in litigating that so I have removed the things you objected to. I kept @rustbot ready |
6a69d7b
to
9753bf4
Compare
Rebased and comments addressed. @bors r=petrochenkov |
☔ The latest upstream changes (presumably #134243) made this pull request unmergeable. Please resolve the merge conflicts. |
It's a verbose reinvention of a range type, and can be cut down a lot.
`rustc_symbol` is the source of truth for keywords. rustdoc has its own implicit definition of keywords, via the `is_doc_keyword`. It (presumably) intends to include all keywords, but it omits `yeet`. rustfmt has its own explicit list of Rust keywords. It also (presumably) intends to include all keywords, but it omits `await`, `builtin`, `gen`, `macro_rules`, `raw`, `reuse`, `safe`, and `yeet`. Also, it does linear searches through this list, which is inefficient. This commit fixes all of the above problems by introducing a new predicate `is_any_keyword` in rustc and using it in rustdoc and rustfmt. It documents that it's not the right predicate in most cases.
`gen` is an edition-specific keyword used in unstable Rust, and so belongs with `try` (as `is_unused_keyword_conditional` indicates). Also, the cases in `is_unused_keyword_conditional` should be in alphabetical order, to match the keyword list. These changes don't affect the behaviour of any of the `Symbol::is_*` functions.
In particular, clarify which predicates apply to which keywords.
9753bf4
to
6de550c
Compare
I rebased. @bors r=petrochenkov |
…etrochenkov Overhaul keyword handling The compiler's list of keywords has some problems. - It contains several items that aren't keywords. - The order isn't quite right in a couple of places. - Some of the names of predicates relating to keywords are confusing. - rustdoc and rustfmt have their own (incorrect) versions of the keyword list. - `AllKeywords` is unnecessarily complex. r? `@jieyouxu`
…etrochenkov Overhaul keyword handling The compiler's list of keywords has some problems. - It contains several items that aren't keywords. - The order isn't quite right in a couple of places. - Some of the names of predicates relating to keywords are confusing. - rustdoc and rustfmt have their own (incorrect) versions of the keyword list. - `AllKeywords` is unnecessarily complex. r? ``@jieyouxu``
Rollup of 8 pull requests Successful merges: - rust-lang#133702 (Variants::Single: do not use invalid VariantIdx for uninhabited enums) - rust-lang#133926 (Fix const conditions for RPITITs) - rust-lang#134161 (Overhaul token cursors) - rust-lang#134253 (Overhaul keyword handling) - rust-lang#134394 (Clarify the match ergonomics 2024 migration lint's output) - rust-lang#134420 (refactor: replace &PathBuf with &Path to enhance generality) - rust-lang#134444 (Fix `x build --stage 1 std` when using cg_cranelift as the default backend) - rust-lang#134452 (fix(LazyCell): documentation of get[_mut] was wrong) r? `@ghost` `@rustbot` modify labels: rollup
Rollup of 11 pull requests Successful merges: - rust-lang#130786 ( mir-opt: a sub-BB of a cleanup BB must also be a cleanup BB in `EarlyOtherwiseBranch`) - rust-lang#133926 (Fix const conditions for RPITITs) - rust-lang#134161 (Overhaul token cursors) - rust-lang#134253 (Overhaul keyword handling) - rust-lang#134394 (Clarify the match ergonomics 2024 migration lint's output) - rust-lang#134399 (Do not do if ! else, use unnegated cond and swap the branches instead) - rust-lang#134420 (refactor: replace &PathBuf with &Path to enhance generality) - rust-lang#134436 (tests/assembly/asm: Remove uses of rustc_attrs and lang_items features by using minicore) - rust-lang#134444 (Fix `x build --stage 1 std` when using cg_cranelift as the default backend) - rust-lang#134452 (fix(LazyCell): documentation of get[_mut] was wrong) - rust-lang#134460 (Merge some patterns together) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#134253 - nnethercote:overhaul-keywords, r=petrochenkov Overhaul keyword handling The compiler's list of keywords has some problems. - It contains several items that aren't keywords. - The order isn't quite right in a couple of places. - Some of the names of predicates relating to keywords are confusing. - rustdoc and rustfmt have their own (incorrect) versions of the keyword list. - `AllKeywords` is unnecessarily complex. r? ```@jieyouxu```
The compiler's list of keywords has some problems.
AllKeywords
is unnecessarily complex.r? @jieyouxu