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

Rollup of 8 pull requests #134456

Closed
wants to merge 28 commits into from
Closed

Conversation

jieyouxu
Copy link
Member

Successful merges:

r? @ghost
@rustbot modify labels: rollup

Create a similar rollup

Integral-Tech and others added 28 commits December 18, 2024 00:28
Field init shorthand allows writing initializers like `tcx: tcx` as
`tcx`. The compiler already uses it extensively. Fix the last few places
where it isn't yet used.
As it happens, lookahead values of 0, 1, and 2 all work fine here, due
to the structure of the code. (Values or 3 or greater cause test
failures.) This commit changes the lookahead to zero because that will
facilitate cleanups in subsequent commits.
It's only ever used with a lookahead of 0, so this commit removes the
lookahead and renames it `peek`.
Because `TokenStreamIter` is a much better name for a `TokenStream`
iterator. Also rename the `TokenStream::trees` method as
`TokenStream::iter`, and some local variables.
Currently there are two ways to peek at a `TokenStreamIter`.
- Wrap it in a `Peekable` and use that traits `peek` method.
- Use `TokenStreamIter`'s inherent `peek` method.

Some code uses one, some use the other. This commit converts all places
to the inherent method. This eliminates mixing of `TokenStreamIter` and
`Peekable<TokenStreamIter>` and some use of `impl Iterator` and `dyn
Iterator`.
…ckend

Before, cg_cranelift would ICE when trying to lower f16 and f128. The
library/ crates had all the infrastructure to omit using them, it just
wasn't hooked up to bootstrap.
- Move it to `rustc_parse`, which is the only crate that uses it. This
  lets us remove all the `pub` markers from it.

- Change `next_ref` and `look_ahead` to `get` and `bump`, which work
  better for the `rustc_parse` uses.

- This requires adding a `TokenStream::get` method, which is simple.

- In `TokenCursor`, we currently duplicate the
  `DelimSpan`/`DelimSpacing`/`Delimiter` from the surrounding
  `TokenTree::Delimited` in the stack. This isn't necessary so long as
  we don't prematurely move past the `Delimited`, and is a small perf
  win on a very hot code path.

- In `parse_token_tree`, we clone the relevant `TokenTree::Delimited`
  instead of constructing an identical one from pieces.
- `LazyCell::get`: said it was returning a **mutable** reference.
- `LazyCell::get_mut`: said it was returning a reference (the mutable
  was missing).
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.
…r=lcnr

Fix const conditions for RPITITs

Fixes rust-lang#133918

r? lcnr
…, r=spastorino

Overhaul token cursors

Some nice cleanups here.

r? ```@davidtwco```
…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`
… r=compiler-errors

Clarify the match ergonomics 2024 migration lint's output

This makes a few changes:
- Rather than using the whole pattern as a span for the lint, this collects spans for each problematic default binding mode reset and labels them with why they're problems.
- The lint's suggestions are now verbose-styled, so that it's clear what's being suggested vs. what's problematic.
- The wording is now less technical, and the hard error version of this diagnostic now links to the same reference material as the lint (currently an unwritten page of the edition guide).

I'm not totally confident in the wording or formatting, so I'd appreciate feedback on that in particular. I tried to draw a connection with word choice between the labels and the suggestion, but it might be imprecise, unclear, or cluttered. If so, it might be worth making the labels more terse and adding notes that explain them, but that's harder to read in a way too.

cc `@Nadrieril` `@Jules-Bertholet`

Closes rust-lang#133854. For reference, the error from that issue becomes:
```
error: pattern uses features incompatible with edition 2024
  --> $DIR/remove-me.rs:6:25
   |
LL |     map.iter().filter(|(&(_x, _y), &_c)| false);
   |                         ^          ^ cannot implicitly match against multiple layers of reference
   |                         |
   |                         cannot implicitly match against multiple layers of reference
   |
help: make the implied reference pattern explicit
   |
LL |     map.iter().filter(|&(&(_x, _y), &_c)| false);
   |                        +
```
…compiler-errors

refactor: replace &PathBuf with &Path to enhance generality

- According to [style.md](https://github.com/rust-lang/rust/blob/master/src/tools/rust-analyzer/docs/dev/style.md#useless-types):

> More generally, always prefer types on the left
```rust
// GOOD      BAD
&[T]         &Vec<T>
&str         &String
Option<&T>   &Option<T>
&Path        &PathBuf
```
…and, r=lqd,tgross35,nnethercote

Use field init shorthand where possible

Field init shorthand allows writing initializers like `tcx: tcx` as
`tcx`. The compiler already uses it extensively. Fix the last few places
where it isn't yet used.
Fix `x build --stage 1 std` when using cg_cranelift as the default backend

Before, cg_cranelift would ICE when trying to lower f16 and f128. The library/ crates had all the infrastructure to omit using them, it just wasn't hooked up to bootstrap.

r? ```@bjorn3```
…=tgross35

fix(LazyCell): documentation of get[_mut] was wrong

- `LazyCell::get`: said it was returning a **mutable** reference.
- `LazyCell::get_mut`: said it was returning a reference (the mutable was missing).

Related to rust-lang#129333 (`lazy_get`). `LazyLock`'s documentation was correct.
@rustbot rustbot added A-compiletest Area: The compiletest test runner A-meta Area: Issues & PRs about the rust-lang/rust repository itself labels Dec 18, 2024
@rustbot rustbot added A-run-make Area: port run-make Makefiles to rmake.rs A-testsuite Area: The testsuite used to check the correctness of rustc O-hermit Operating System: Hermit O-SGX Target: SGX S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Dec 18, 2024
@jieyouxu
Copy link
Member Author

@bors r+ rollup=never p=5

@rustbot rustbot added the rollup A PR which is a rollup label Dec 18, 2024
@bors
Copy link
Contributor

bors commented Dec 18, 2024

📌 Commit 9f17602 has been approved by jieyouxu

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Dec 18, 2024
@jieyouxu
Copy link
Member Author

@bors r- (there's a PR in here that changes rustfmt.toml)

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Dec 18, 2024
@jieyouxu jieyouxu closed this Dec 18, 2024
@jieyouxu jieyouxu deleted the rollup-fqlagwe branch December 18, 2024 10:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-compiletest Area: The compiletest test runner A-meta Area: Issues & PRs about the rust-lang/rust repository itself A-run-make Area: port run-make Makefiles to rmake.rs A-testsuite Area: The testsuite used to check the correctness of rustc O-hermit Operating System: Hermit O-SGX Target: SGX rollup A PR which is a rollup S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants