Skip to content

Rollup of 7 pull requests #134454

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

Closed
wants to merge 26 commits into from
Closed

Conversation

jieyouxu
Copy link
Member

Successful merges:

r? @ghost
@rustbot modify labels: rollup

Create a similar rollup

RalfJung and others added 26 commits December 4, 2024 07:34
Co-authored-by: Jack Wrenn <me@jswrenn.com>
Co-authored-by: Camille Gillot <gillot.camille@gmail.com>
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.
Variants::Single: do not use invalid VariantIdx for uninhabited enums

~~Stacked on top of rust-lang#133681, only the last commit is new.~~

Currently, `Variants::Single` for an empty enum contains a `VariantIdx` of 0; looking that up in the enum variant list will ICE. That's quite confusing. So let's fix that by adding a new `Variants::Empty` case for types that have 0 variants.
…r=lcnr

Fix const conditions for RPITITs

Fixes rust-lang#133918

r? lcnr
…, r=spastorino

Overhaul token cursors

Some nice cleanups here.

r? ``@davidtwco``
… 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``
@rustbot rustbot added 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 labels Dec 18, 2024
@rustbot rustbot added 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. rollup A PR which is a rollup labels Dec 18, 2024
@jieyouxu
Copy link
Member Author

@bors r+ rollup=never p=5

@bors
Copy link
Collaborator

bors commented Dec 18, 2024

📌 Commit 3bcaddd 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
@rust-log-analyzer
Copy link
Collaborator

The job mingw-check-tidy failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)

COPY host-x86_64/mingw-check/validate-toolstate.sh /scripts/
COPY host-x86_64/mingw-check/validate-error-codes.sh /scripts/

# NOTE: intentionally uses python2 for x.py so we can test it still works.
# validate-toolstate only runs in our CI, so it's ok for it to only support python3.
ENV SCRIPT TIDY_PRINT_DIFF=1 python2.7 ../x.py test \
           --stage 0 src/tools/tidy tidyselftest --extra-checks=py:lint,cpp:fmt
# This file is autogenerated by pip-compile with Python 3.10
# by the following command:
#
#    pip-compile --allow-unsafe --generate-hashes reuse-requirements.in
---
#13 2.878 Building wheels for collected packages: reuse
#13 2.879   Building wheel for reuse (pyproject.toml): started
#13 3.127   Building wheel for reuse (pyproject.toml): finished with status 'done'
#13 3.128   Created wheel for reuse: filename=reuse-4.0.3-cp310-cp310-manylinux_2_35_x86_64.whl size=132720 sha256=026f3bb0f1aa8090b861fd0a0939cb1a782396d84c8aab7875096557d637a0f6
#13 3.128   Stored in directory: /tmp/pip-ephem-wheel-cache-z7z_67gd/wheels/3d/8d/0a/e0fc6aba4494b28a967ab5eaf951c121d9c677958714e34532
#13 3.131 Installing collected packages: boolean-py, binaryornot, tomlkit, reuse, python-debian, markupsafe, license-expression, jinja2, chardet, attrs
#13 3.524 Successfully installed attrs-23.2.0 binaryornot-0.4.4 boolean-py-4.0 chardet-5.2.0 jinja2-3.1.4 license-expression-30.3.0 markupsafe-2.1.5 python-debian-0.1.49 reuse-4.0.3 tomlkit-0.13.0
#13 3.524 WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
#13 4.059 Collecting virtualenv
#13 4.059 Collecting virtualenv
#13 4.124   Downloading virtualenv-20.28.0-py3-none-any.whl (4.3 MB)
#13 4.223      ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 4.3/4.3 MB 44.9 MB/s eta 0:00:00
#13 4.283 Collecting filelock<4,>=3.12.2
#13 4.296   Downloading filelock-3.16.1-py3-none-any.whl (16 kB)
#13 4.334 Collecting platformdirs<5,>=3.9.1
#13 4.346   Downloading platformdirs-4.3.6-py3-none-any.whl (18 kB)
#13 4.371 Collecting distlib<1,>=0.3.7
#13 4.391      ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 469.0/469.0 KB 88.0 MB/s eta 0:00:00
#13 4.391      ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 469.0/469.0 KB 88.0 MB/s eta 0:00:00
#13 4.472 Installing collected packages: distlib, platformdirs, filelock, virtualenv
#13 4.655 Successfully installed distlib-0.3.9 filelock-3.16.1 platformdirs-4.3.6 virtualenv-20.28.0
#13 DONE 4.7s

#14 [7/8] COPY host-x86_64/mingw-check/validate-toolstate.sh /scripts/
#14 DONE 0.0s
---
DirectMap4k:      141248 kB
DirectMap2M:     7198720 kB
DirectMap1G:    11534336 kB
##[endgroup]
Executing TIDY_PRINT_DIFF=1 python2.7 ../x.py test            --stage 0 src/tools/tidy tidyselftest --extra-checks=py:lint,cpp:fmt
+ TIDY_PRINT_DIFF=1 python2.7 ../x.py test --stage 0 src/tools/tidy tidyselftest --extra-checks=py:lint,cpp:fmt
    Finished `dev` profile [unoptimized] target(s) in 0.04s
##[endgroup]
WARN: currently no CI rustc builds have rustc debug assertions enabled. Please either set `rust.debug-assertions` to `false` if you want to use download CI rustc or set `rust.download-rustc` to `false`.
downloading https://static.rust-lang.org/dist/2024-11-27/rustfmt-nightly-x86_64-unknown-linux-gnu.tar.xz
---
   Compiling tidy v0.1.0 (/checkout/src/tools/tidy)
    Finished `release` profile [optimized] target(s) in 31.65s
##[endgroup]
fmt check
Diff in /checkout/compiler/rustc_ty_utils/src/layout.rs:926:
                 &ReprOptions::default(),
                 StructKind::Prefixed(prefix_size, prefix_align.abi),
             )?;
-            variant.variants = Variants::Single { index: index };
+            variant.variants = Variants::Single { index };
 
             let FieldsShape::Arbitrary { offsets, memory_index } = variant.fields else {
                 bug!();
fmt error: Running `"/checkout/obj/build/x86_64-unknown-linux-gnu/rustfmt/bin/rustfmt" "--config-path" "/checkout" "--edition" "2021" "--unstable-features" "--skip-children" "--check" "/checkout/compiler/rustc_target/src/asm/avr.rs" "/checkout/compiler/rustc_target/src/asm/csky.rs" "/checkout/compiler/rustc_target/src/asm/bpf.rs" "/checkout/compiler/rustc_target/src/asm/hexagon.rs" "/checkout/compiler/rustc_target/src/asm/riscv.rs" "/checkout/compiler/rustc_target/src/asm/powerpc.rs" "/checkout/compiler/rustc_symbol_mangling/src/legacy.rs" "/checkout/compiler/rustc_symbol_mangling/src/test.rs" "/checkout/compiler/rustc_symbol_mangling/src/lib.rs" "/checkout/compiler/rustc_symbol_mangling/src/hashed.rs" "/checkout/compiler/rustc_symbol_mangling/src/errors.rs" "/checkout/compiler/rustc_symbol_mangling/src/v0.rs" "/checkout/compiler/rustc_ty_utils/src/needs_drop.rs" "/checkout/compiler/rustc_ty_utils/src/sig_types.rs" "/checkout/compiler/rustc_ty_utils/src/implied_bounds.rs" "/checkout/compiler/rustc_ty_utils/src/instance.rs" "/checkout/compiler/rustc_ty_utils/src/common_traits.rs" "/checkout/compiler/rustc_ty_utils/src/ty.rs" "/checkout/compiler/rustc_ty_utils/src/structural_match.rs" "/checkout/compiler/rustc_ty_utils/src/abi.rs" "/checkout/compiler/rustc_ty_utils/src/layout/invariant.rs" "/checkout/compiler/rustc_ty_utils/src/lib.rs" "/checkout/compiler/rustc_ty_utils/src/representability.rs" "/checkout/compiler/rustc_ty_utils/src/assoc.rs" "/checkout/compiler/rustc_ty_utils/src/consts.rs" "/checkout/compiler/rustc_ty_utils/src/errors.rs" "/checkout/compiler/rustc_ty_utils/src/opaque_types.rs" "/checkout/compiler/rustc_ty_utils/src/layout.rs" "/checkout/compiler/rustc_macros/build.rs" "/checkout/compiler/rustc_macros/src/diagnostics/subdiagnostic.rs" "/checkout/compiler/rustc_macros/src/diagnostics/diagnostic.rs" "/checkout/compiler/rustc_macros/src/diagnostics/error.rs" "/checkout/compiler/rustc_macros/src/diagnostics/utils.rs" "/checkout/compiler/rustc_macros/src/diagnostics/diagnostic_builder.rs" "/checkout/compiler/rustc_macros/src/diagnostics/mod.rs" "/checkout/compiler/rustc_macros/src/type_foldable.rs" "/checkout/compiler/rustc_macros/src/extension.rs" "/checkout/compiler/rustc_macros/src/lift.rs" "/checkout/compiler/rustc_macros/src/hash_stable.rs" "/checkout/compiler/rustc_macros/src/serialize.rs" "/checkout/compiler/rustc_macros/src/current_version.rs" "/checkout/compiler/rustc_macros/src/lib.rs" "/checkout/compiler/rustc_macros/src/query.rs" "/checkout/compiler/rustc_macros/src/try_from.rs" "/checkout/compiler/rustc_macros/src/type_visitable.rs" "/checkout/compiler/rustc_macros/src/symbols/tests.rs" "/checkout/compiler/rustc_macros/src/symbols.rs" "/checkout/compiler/rustc_type_ir/src/fold.rs" "/checkout/compiler/rustc_type_ir/src/canonical.rs" "/checkout/compiler/rustc_type_ir/src/elaborate.rs" "/checkout/compiler/rustc_type_ir/src/flags.rs" "/checkout/compiler/rustc_type_ir/src/inherent.rs" "/checkout/compiler/rustc_type_ir/src/solve/inspect.rs" "/checkout/compiler/rustc_type_ir/src/solve/mod.rs" "/checkout/compiler/rustc_type_ir/src/relate/combine.rs" "/checkout/compiler/rustc_type_ir/src/relate/solver_relating.rs" "/checkout/compiler/rustc_type_ir/src/predicate.rs" "/checkout/compiler/rustc_type_ir/src/data_structures/delayed_map.rs" "/checkout/compiler/rustc_type_ir/src/data_structures/mod.rs" "/checkout/compiler/rustc_type_ir/src/ty_info.rs" "/checkout/compiler/rustc_type_ir/src/visit.rs" "/checkout/compiler/rustc_type_ir/src/lift.rs" "/checkout/compiler/rustc_type_ir/src/search_graph/global_cache.rs" "/checkout/compiler/rustc_target/src/asm/arm.rs"` failed.
If you're running `tidy`, try again with `--bless`. Or, if you just want to format code, run `./x.py fmt` instead.
  local time: Wed Dec 18 09:37:40 UTC 2024
  network time: Wed, 18 Dec 2024 09:37:40 GMT
##[error]Process completed with exit code 1.
Post job cleanup.

@jieyouxu
Copy link
Member Author

@bors r-

@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-jifxsrb branch December 18, 2024 09:49
@@ -4,6 +4,7 @@ use_small_heuristics = "Max"
merge_derives = false
group_imports = "StdExternalCrate"
imports_granularity = "Module"
use_field_init_shorthand = true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR changes the fmt config, that's why it causes unrelated PRs to break.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... Thanks, I missed that part.

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.