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 7 pull requests #138630

Merged
merged 28 commits into from
Mar 18, 2025
Merged

Rollup of 7 pull requests #138630

merged 28 commits into from
Mar 18, 2025

Conversation

matthiaskrgr
Copy link
Member

Successful merges:

r? @ghost
@rustbot modify labels: rollup

Create a similar rollup

hkBst and others added 28 commits March 14, 2025 19:28
This clarifies the explanation of why this is not allowed and also what to do instead.

Fixes 62071

PS There was suggestion of adding a link to the book. I did not yet do that, but if desired that could be added.
This allows the code to be simplified a little bit.
So that we can also observe them for try builds, before merging a PR.
It determines if a function should have any `inline` attributes checked.
For `ItemKind::Fn` it returns true or false depending on the details of
the function; for anything other item kind it returns *true*. This
latter case should instead be *false*. (In the nearby and similar
functions `is_relevant_impl` and `is_relevant_trait` the non-function
cases return false.)

The effect of this is that non-functions are no longer checked. But
rustc already disallows `inline` on any non-function items. So if
anything its a tiny performance win, because that was useless anyway.
This commit fixes an internal compiler error (ICE) that occurs when
rustdoc attempts to process macros with a remapped filename. The issue
arose during macro expansion when the `--remap-path-prefix` option was
used.

Instead of passing remapped filenames through, which would trigger the
"attempted to remap an already remapped filename" panic, we now
extract the original local path from remapped filenames before
processing them.

A test case has been added to verify this behavior.

Fixes rust-lang#138520

Signed-off-by: Charalampos Mitrodimas <charmitro@posteo.net>
`hir::Item` has an `ident` field.

- It's always non-empty for these item kinds: `ExternCrate`, `Static`,
  `Const`, `Fn`, `Macro`, `Mod`, `TyAlias`, `Enum`, `Struct`, `Union`,
  Trait`, TraitAalis`.

- It's always empty for these item kinds: `ForeignMod`, `GlobalAsm`,
  `Impl`.

- For `Use`, it is non-empty for `UseKind::Single` and empty for
  `UseKind::{Glob,ListStem}`.

All of this is quite non-obvious; the only documentation is a single
comment saying "The name might be a dummy name in case of anonymous
items". Some sites that handle items check for an empty ident, some
don't. This is a very C-like way of doing things, but this is Rust, we
have sum types, we can do this properly and never forget to check for
the exceptional case and never YOLO possibly empty identifiers (or
possibly dummy spans) around and hope that things will work out.

The commit is large but it's mostly obvious plumbing work. Some notable
things.

- A similar transformation makes sense for `ast::Item`, but this is
  already a big change. That can be done later.

- Lots of assertions are added to item lowering to ensure that
  identifiers are empty/non-empty as expected. These will be removable
  when `ast::Item` is done later.

- `ItemKind::Use` doesn't get an `Ident`, but `UseKind::Single` does.

- `lower_use_tree` is significantly simpler. No more confusing `&mut
  Ident` to deal with.

- `ItemKind::ident` is a new method, it returns an `Option<Ident>`. It's
  used with `unwrap` in a few places; sometimes it's hard to tell
  exactly which item kinds might occur. None of these unwraps fail on
  the test suite. It's conceivable that some might fail on alternative
  input. We can deal with those if/when they happen.

- In `trait_path` the `find_map`/`if let` is replaced with a loop, and
  things end up much clearer that way.

- `named_span` no longer checks for an empty name; instead the call site
  now checks for a missing identifier if necessary.

- `maybe_inline_local` doesn't need the `glob` argument, it can be
  computed in-function from the `renamed` argument.

- `arbitrary_source_item_ordering::check_mod` had a big `if` statement
  that was just getting the ident from the item kinds that had one. It
  could be mostly replaced by a single call to the new `ItemKind::ident`
  method.

- `ItemKind` grows from 56 to 64 bytes, but `Item` stays the same size,
  and that's what matters, because `ItemKind` only occurs within `Item`.
…=fmease

Move `hir::Item::ident` into `hir::ItemKind`.

 `hir::Item` has an `ident` field.

- It's always non-empty for these item kinds: `ExternCrate`, `Static`, `Const`, `Fn`, `Macro`, `Mod`, `TyAlias`, `Enum`, `Struct`, `Union`, Trait`, TraitAalis`.

- It's always empty for these item kinds: `ForeignMod`, `GlobalAsm`, `Impl`.

- For `Use`, it is non-empty for `UseKind::Single` and empty for `UseKind::{Glob,ListStem}`.

All of this is quite non-obvious; the only documentation is a single comment saying "The name might be a dummy name in case of anonymous items". Some sites that handle items check for an empty ident, some don't. This is a very C-like way of doing things, but this is Rust, we have sum types, we can do this properly and never forget to check for the exceptional case and never YOLO possibly empty identifiers (or possibly dummy spans) around and hope that things will work out.

This is step towards `kw::Empty` elimination (rust-lang#137978).

r? `@fmease`
Clarify "owned data" in E0515.md

This clarifies the explanation of why this is not allowed and also what to do instead.

Fixes rust-lang#62071

PS There was suggestion of adding a link to the book. I did not yet do that, but if desired that could be added.
…oieni

Store test diffs in job summaries and improve analysis formatting

This PR stores the test diffs that we already have in the post-merge workflow also into individual job summaries. This makes it easier to compare test (and later also other) diffs per job, which will be especially useful for try jobs, so that we can actually see the test diffs *before* we merge a given PR.

As a drive-by, I also made a bunch of cleanups in `citool` and in the formatting of the summary and post-merge analyses. These changes are split into self-contained commits.

The analysis can be tested locally with the following command:
```bash
$ curl https://ci-artifacts.rust-lang.org/rustc-builds/<current-sha>/metrics-<job-name>.json > metrics.json
$ cargo run --manifest-path src/ci/citool/Cargo.toml postprocess-metrics metrics.json --job-name <job-name> --parent <parent-sha> > out.md
```
For example, for [this PR](rust-lang#138523):
```bash
$ curl https://ci-artifacts.rust-lang.org/rustc-builds/282865097d138c7f0f7a7566db5b761312dd145c/metrics-aarch64-gnu.json > metrics.json
$ cargo run --manifest-path src/ci/citool/Cargo.toml postprocess-metrics metrics.json --job-name aarch64-gnu --parent d9e5539 > out.md
```

Best reviewed commit by commit.

r? `@marcoieni`

try-job: aarch64-gnu
try-job: dist-x86_64-linux
…ieni

Only use `DIST_TRY_BUILD` for try jobs that were not selected explicitly

Some CI jobs (x64 Linux, ARM64 Linux and x64 MSVC) use the `opt-dist` tool to build an optimized toolchain using PGO and BOLT. When performing a default try build for x64 Linux, in most cases we want to run perf. on that artifact. To reduce the latency of this common use-case, `opt-dist` skips building several components not needed for perf., and it also skips running post-optimization tests, when it detects that the job is executed as a try job (not a merge/auto job).

This is useful, but it also means that if you *want* to run the tests, you had to go to `jobs.yml` and manually comment this environment variable, create a WIP commit, do a try build, and then remove the WIP commit, which is annoying (in the similar way that modifying what gets run in try builds was annoying before we had the `try-job` annotations).

I thought that we could introduce some additional PR description marker like `try-job-run-tests`, but it's hard to discover that such things exist.

Instead, I think that there's a much simpler heuristic for determining whether `DIST_TRY_BUILD` should be used (that I implemented in this PR):
- If you do just ``@bors` try`, without any custom try jobs selected, `DIST_TRY_BUILD` will be activated, to finish the build as fast as possible.
- If you specify any custom try jobs, you are most likely doing experiments and you want to see if tests pass and everything builds as it should. The `DIST_TRY_BUILD` variable will thus *not* be set in this case.

In this way, if you want to run dist tests, you can just add the `try-job: dist-x86_64-linux` line to the PR description, and you don't need to create any WIP commits.

r? `@marcoieni`
…e, r=GuillaumeGomez,Urgau

Fix ICE: attempted to remap an already remapped filename

This commit fixes an internal compiler error (ICE) that occurs when
rustdoc attempts to process macros with a remapped filename. The issue
arose during macro expansion when the `--remap-path-prefix` option was
used.

Instead of passing remapped filenames through, which would trigger the
"attempted to remap an already remapped filename" panic, we now
extract the original local path from remapped filenames before
processing them.

A test case has been added to verify this behavior.

Fixes rust-lang#138520
rustc_target: Add target feature constraints for LoongArch

Part of rust-lang#116344

r? `@RalfJung`
…fs, r=lcnr

Flatten `if`s in `rustc_codegen_ssa`

Best viewed [while ignoring whitespace](https://github.com/rust-lang/rust/pull/138619/files?diff=unified&w=1)
@rustbot rustbot added A-attributes Area: Attributes (`#[…]`, `#![…]`) A-rustc-dev-guide Area: rustc-dev-guide labels Mar 17, 2025
@bors
Copy link
Contributor

bors commented Mar 18, 2025

⌛ Testing commit 597500d with merge af5f102...

@rust-log-analyzer
Copy link
Collaborator

The job x86_64-fuchsia failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
+ .jiri_root/bin/jiri import -name=integration -revision=f6f83d3e3852209f7752be55694006afbe979e50 -overwrite=true flower https://fuchsia.googlesource.com/integration
+ '[' -d .git ']'
+ .jiri_root/bin/jiri update -autoupdate=false
[01:58:18.636] Updating all projects
ERROR: 'git clone --no-checkout --filter=blob:none https://fuchsia.googlesource.com/third_party/github.com/uqfoundation/dill /checkout/obj/fuchsia/third_party/pylibs/dill/src' failed:
stdout:

stderr:
Cloning into '/checkout/obj/fuchsia/third_party/pylibs/dill/src'...
error: RPC failed; HTTP 429 curl 22 The requested URL returned error: 429
fatal: expected flush after ref listing

command fail error: exit status 128

[02:00:08.835] Wait for 1m4s before next attempt...: Cloning https://fuchsia.googlesource.com/third_party/github.com/uqfoundation/dill

ERROR: 'git clone --no-checkout --filter=blob:none https://fuchsia.googlesource.com/third_party/android.googlesource.com/platform/system/libbase /checkout/obj/fuchsia/third_party/android/platform/system/libbase' failed:
stdout:

stderr:
---
command fail error: exit status 128

[02:00:13.020] Wait for 1m4s before next attempt...: Cloning https://fuchsia.googlesource.com/third_party/android.googlesource.com/platform/system/libbase

[02:01:12.845] Attempt 2/3: Cloning https://fuchsia.googlesource.com/third_party/github.com/uqfoundation/dill

[02:01:17.022] Attempt 2/3: Cloning https://fuchsia.googlesource.com/third_party/android.googlesource.com/platform/system/libbase

[03:02:26.168] WARN: Projects with local changes and/or not on JIRI_HEAD:
third_party/go (third_party/go): (Has changes)
third_party/android.googlesource.com/platform/bionic (third_party/android/platform/bionic): (Has changes)
third_party/fmtlib (third_party/fmtlib/src): (Has changes)

To force an update to JIRI_HEAD, you may run 'jiri runp git checkout JIRI_HEAD'
[03:03:24.851] WARN: Some packages are skipped by cipd due to lack of access, you might want to run "/checkout/obj/fuchsia/.jiri_root/bin/cipd auth-login" and try again
++ git -C integration rev-parse HEAD
+ echo integration commit = f6f83d3e3852209f7752be55694006afbe979e50
integration commit = f6f83d3e3852209f7752be55694006afbe979e50
+ bash scripts/rust/build_fuchsia_from_rust_ci.sh
---
You will receive this warning until an option is selected.
To check what data we collect, run `fx metrics`
To opt in or out, run `fx metrics <enable|disable>

ERROR at //build/compiled_action.gni:152:17: Can't load input file.
      deps += [ host_tool ]
                ^--------
Unable to load:
  /checkout/obj/fuchsia/third_party/go/makefuchsia/BUILD.gn
I also checked in the secondary tree for:
  /checkout/obj/fuchsia/build/secondary/third_party/go/makefuchsia/BUILD.gn

For more information how to resolve CI failures of this job, visit this link.

@bors
Copy link
Contributor

bors commented Mar 18, 2025

💔 Test failed - checks-actions

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

@bors retry

@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 Mar 18, 2025
@bors
Copy link
Contributor

bors commented Mar 18, 2025

⌛ Testing commit 597500d with merge 259fdb5...

@matthiaskrgr
Copy link
Member Author

@bors treeclosed=100 fuchsia problems

@bors
Copy link
Contributor

bors commented Mar 18, 2025

☀️ Test successful - checks-actions
Approved by: matthiaskrgr
Pushing 259fdb5 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Mar 18, 2025
@bors bors merged commit 259fdb5 into rust-lang:master Mar 18, 2025
7 checks passed
@rustbot rustbot added this to the 1.87.0 milestone Mar 18, 2025
@rust-timer
Copy link
Collaborator

📌 Perf builds for each rolled up PR:

PR# Message Perf Build Sha
#138384 Move hir::Item::ident into hir::ItemKind. 57369935361f0aeb6a31ab30756b5f0b1b5b4a41 (link)
#138508 Clarify "owned data" in E0515.md a78001570ae589b06a6df656a63e3cf4ee17e774 (link)
#138531 Store test diffs in job summaries and improve analysis form… d88b8b1a2e02a90d6b6970826d4c991daa0b0b2d (link)
#138533 Only use DIST_TRY_BUILD for try jobs that were not select… b2d2fd216569a372ca660eaa9b3ba0ceb2f1cfa2 (link)
#138556 Fix ICE: attempted to remap an already remapped filename d7c43369b70e72eeeabcda268bd98988ca392c1d (link)
#138608 rustc_target: Add target feature constraints for LoongArch 401923d6451df52af7a90c31160cdc8200d87319 (link)
#138619 Flatten ifs in rustc_codegen_ssa 3e1d78f79a4b5d2015863c1936528a4466c7c313 (link)

previous master: 493c38ba37

In the case of a perf regression, run the following command for each PR you suspect might be the cause: @rust-timer build $SHA

Copy link

This is an experimental post-merge analysis report. You can ignore it.

Post-merge report
What is this?

This is an experimental post-merge analysis report that shows differences in
test outcomes between the merged PR and its parent PR.

Comparing 493c38b (parent) -> 259fdb5 (this PR)

Test differences

Show 14 test diffs
  • [ui] tests/rustdoc-ui/remap-path-prefix-macro.rs (stage 1): [missing] -> pass (J0)
  • [ui] tests/rustdoc-ui/remap-path-prefix-macro.rs (stage 2): [missing] -> pass (J1)

Additionally, 12 doctest diffs were found. These are ignored, as they are noisy.

Job group index

  • J0: x86_64-gnu-llvm-18-3, x86_64-gnu-llvm-19-3
  • J1: aarch64-apple, aarch64-gnu, i686-gnu-1, i686-gnu-nopt-1, i686-msvc-1, x86_64-apple-1, x86_64-gnu, x86_64-gnu-llvm-18-1, x86_64-gnu-llvm-18-2, x86_64-gnu-llvm-19-1, x86_64-gnu-llvm-19-2, x86_64-gnu-nopt, x86_64-gnu-stable, x86_64-mingw-1, x86_64-msvc-1

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (259fdb5): comparison URL.

Overall result: ✅ improvements - no action needed

@rustbot label: -perf-regression

Instruction count

This is the most reliable metric that we have; it was used to determine the overall result at the top of this comment. However, even this metric can sometimes exhibit noise.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.1% [-0.2%, -0.1%] 5
Improvements ✅
(secondary)
-0.4% [-0.7%, -0.2%] 4
All ❌✅ (primary) -0.1% [-0.2%, -0.1%] 5

Max RSS (memory usage)

Results (primary 1.1%, secondary 2.3%)

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
2.8% [2.8%, 2.8%] 1
Regressions ❌
(secondary)
2.3% [2.0%, 2.7%] 3
Improvements ✅
(primary)
-0.6% [-0.6%, -0.6%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 1.1% [-0.6%, 2.8%] 2

Cycles

This benchmark run did not return any relevant results for this metric.

Binary size

Results (primary -0.1%, secondary -0.1%)

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.1% [-0.2%, -0.0%] 71
Improvements ✅
(secondary)
-0.1% [-0.7%, -0.0%] 25
All ❌✅ (primary) -0.1% [-0.2%, -0.0%] 71

Bootstrap: 775.508s -> 776.409s (0.12%)
Artifact size: 365.09 MiB -> 365.11 MiB (0.01%)

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Mar 19, 2025
Remove double nesting in post-merge workflow

See [this](rust-lang#138630 (comment)) :)

Can be tested with:
```bash
#!/bin/bash

PARENT_COMMIT=493c38ba371929579fe136df26eccd9516347c7a
SHA=259fdb521200c9abba547302fc2c826479ef26b2

printf "<details>\n<summary>What is this?</summary>\n" >> output.log
printf "This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.\n" >> output.log
printf "</details>\n\n" >> output.log

cargo run --release post-merge-report ${PARENT_COMMIT} ${SHA} >> output.log
```

I think that it's better to leave the notice in CI, to avoid generating it in citool, which can also be executed locally.

r? `@marcoieni`
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Mar 19, 2025
Rollup merge of rust-lang#138656 - Kobzol:post-merge-unnest, r=marcoieni

Remove double nesting in post-merge workflow

See [this](rust-lang#138630 (comment)) :)

Can be tested with:
```bash
#!/bin/bash

PARENT_COMMIT=493c38ba371929579fe136df26eccd9516347c7a
SHA=259fdb521200c9abba547302fc2c826479ef26b2

printf "<details>\n<summary>What is this?</summary>\n" >> output.log
printf "This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.\n" >> output.log
printf "</details>\n\n" >> output.log

cargo run --release post-merge-report ${PARENT_COMMIT} ${SHA} >> output.log
```

I think that it's better to leave the notice in CI, to avoid generating it in citool, which can also be executed locally.

r? `@marcoieni`
github-actions bot pushed a commit to rust-lang/rustc-dev-guide that referenced this pull request Mar 20, 2025
Remove double nesting in post-merge workflow

See [this](rust-lang/rust#138630 (comment)) :)

Can be tested with:
```bash
#!/bin/bash

PARENT_COMMIT=493c38ba371929579fe136df26eccd9516347c7a
SHA=259fdb521200c9abba547302fc2c826479ef26b2

printf "<details>\n<summary>What is this?</summary>\n" >> output.log
printf "This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.\n" >> output.log
printf "</details>\n\n" >> output.log

cargo run --release post-merge-report ${PARENT_COMMIT} ${SHA} >> output.log
```

I think that it's better to leave the notice in CI, to avoid generating it in citool, which can also be executed locally.

r? `@marcoieni`
flip1995 pushed a commit to flip1995/rust that referenced this pull request Mar 20, 2025
…iaskrgr

Rollup of 7 pull requests

Successful merges:

 - rust-lang#138384 (Move `hir::Item::ident` into `hir::ItemKind`.)
 - rust-lang#138508 (Clarify "owned data" in E0515.md)
 - rust-lang#138531 (Store test diffs in job summaries and improve analysis formatting)
 - rust-lang#138533 (Only use `DIST_TRY_BUILD` for try jobs that were not selected explicitly)
 - rust-lang#138556 (Fix ICE: attempted to remap an already remapped filename)
 - rust-lang#138608 (rustc_target: Add target feature constraints for LoongArch)
 - rust-lang#138619 (Flatten `if`s in `rustc_codegen_ssa`)

r? `@ghost`
`@rustbot` modify labels: rollup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-attributes Area: Attributes (`#[…]`, `#![…]`) A-rustc-dev-guide Area: rustc-dev-guide A-testsuite Area: The testsuite used to check the correctness of rustc merged-by-bors This PR was explicitly merged by bors. rollup A PR which is a rollup S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-infra Relevant to the infrastructure 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. T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output.
Projects
None yet
Development

Successfully merging this pull request may close these issues.