Skip to content

Rollup of 11 pull requests #143976

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 42 commits into from

Conversation

samueltardieu
Copy link
Contributor

@samueltardieu samueltardieu commented Jul 15, 2025

Successful merges:

r? @ghost
@rustbot modify labels: rollup

Create a similar rollup

hkBst and others added 30 commits July 3, 2025 09:05
If the remote process is terminated by a signal, make `remote-test-client` exit
with the code `128 + <signal-number>` instead of always `3`. This follows common
practice among tools such as bash [^1]:

> When a command terminates on a fatal signal whose number is N, Bash uses the
> value 128+N as the exit status.

It also allows us to differentiate between `run-pass` and `run-crash` ui tests
without special case code in compiletest for that when `remote-test-client` is
used.

[^1]: https://www.gnu.org/software/bash/manual/html_node/Exit-Status.html
This is used for string interpolation currently, so rename it as so.
The name `Const` will be used to denote a general CTFE constant that
can either be integer or pointer.
This is intended for supporting passing arbitrary CTFE const into inline
assembly.
`global_asm!` themselves don't need symbol names; they currently only have
a symbol name during mono collecion to identify them to partitioning
algorithm.

However it will have shims generated under it which will need unique symbol
names. The name themselves ultimately doesn't matter, so they're generated
like other shim instances.
This is currently a no-op, but will be useful when const in `global_asm!`
can be pointers.
Also make it *only* usable on nightly
…-errors

Support using const pointers in asm `const` operand

Implements rust-lang#128464

This adds support of const pointers for asm `const` in addition to plain integers.

The inline `asm!` support is implemented using `i` constraint, and the `global_asm!` and `naked_asm!` support is implemented by inserting `symbol + offset` and make `symbol` compiler-used. For unnamed consts, it will create additional internal & hidden symbols so that they can be referenced by global_asm.

The feature is also implemented for GCC backend but it's untested.
…, r=Mark-Simulacrum

wrapping shift: remove first bitmask and table

```rust
        #[inline(always)]
        pub const fn wrapping_shl(self, rhs: u32) -> Self {
            // SAFETY: the masking by the bitsize of the type ensures that we do not shift
            // out of bounds
            unsafe {
                self.unchecked_shl(rhs & (Self::BITS - 1))
            }
        }
```
already does the bitmask, so it seems unnecessary here.

More context: internals.rust-lang.org/t/wrapping-shift-operator-code-doing-bitmasking-twice/23167
…, r=Mark-Simulacrum

remote-test-client: Exit code `128 + <signal-number>` instead of `3`

If the remote process is terminated by a signal, make `remote-test-client` exit with the code `128 + <signal-number>` instead of always `3`. This follows common practice among tools such as bash [^1]:

> When a command terminates on a fatal signal whose number is N, Bash uses the
> value 128+N as the exit status.

It also allows us to differentiate between `run-pass` and `run-crash` ui tests without special case code in compiletest for that when `remote-test-client` is used. See rust-lang#143002 and in particular rust-lang#143002 (comment).

Exiting with code `3` has been done from the start (see rust-lang#39400) and seems arbitrary rather than a deliberate design decision, so changing it does not seem like an extraordinarily big deal.

### Regression testing

Note that rust-lang#143002 will act as a regression test once it is rebased on this PR.

### Why a separate PR

I think it is comforting to know that CI does not break with just this change. But if my reviewer prefers, we can move this commit to be part of rust-lang#143002 instead.

[^1]: https://www.gnu.org/software/bash/manual/html_node/Exit-Status.html
miri: fix out-of-bounds error for ptrs with negative offsets

r? ``@oli-obk``
Emit warning when there is no space between `-o` and arg

Closes rust-lang#142812

`getopt` doesn't seem to have an API to check this, so we have to check the args manually.

r? compiler
…=tgross35

Move several float tests to floats/mod.rs

This PR moves several tests to `floats/mod.rs`, as discussed in rust-lang#141726. The tests moved are:

- `test_num_f*`
- `test_infinity`
- `test_neg_infinity`
- `test_zero`
- `test_neg_zero`
- `test_one`
- `test_is_nan`
- `test_is_infinite`
- `test_is_finite`
- `test_is_normal`
- `test_classify`

Each test is its own commit, so it may be easiest to review each commit individually.

r? tgross35
…szelmann

Port `#[coverage]` to the new attribute system

r? ``@jdonszelmann``
Constify `Index` traits

tracking issue: rust-lang#143775

the `SliceIndex` trait cannot be implemented by users as it is sealed. While it would be useful for the `get` method on slices, it seems weird to have a feature gate for that that isn't also gating index syntax at the same time, so I put them under the same feature gate.

r? ``@fee1-dead``
…ee1-dead

Make slice comparisons const

This needed a fix for `derive_const`, too, as it wasn't usable in libcore anymore as trait impls need const stability attributes. I think we can't use the same system as normal trait impls while `const_trait_impl` is still unstable.

r? ```@fee1-dead```

cc rust-lang#143800
Add tracing to `InterpCx::fn_abi_of_instance/fn_abi_of_fn_ptr`

This PR adds tracing to the `InterpCx::fn_abi_of_instance`/`::fn_abi_of_fn_ptr` functions by shadowing `FnAbiOf`'s trait methods with inherent methods on `InterpCx`, like done in rust-lang#142721. The reason why I am targeting these two functions is because they are used for Miri interpretation, and they make a `layout_of` query down the line without passing through the `layout_of` that was traced in rust-lang#142721.

There are other places where `layout_of` is called without being traced (see the analysis below), but that's because the `Machine` used there is not `MiriMachine` but rather `CompileTimeMachine` which does not implement `enter_trace_span()`. But after discussing with ``@RalfJung`` we agreed that the const-eval part should not be traced together with Miri, that's why I am ignoring the other places where `layout_of` is called.

r? ``@RalfJung``

<details><summary>Analysis of the places where <code>layout_of</code> is called</summary>

I did some analysis for rust-lang#142721 (comment), and these are all the places where the query `tcx.layout_of` is called (directly or indirectly) outside of a traced `InterpCx::layout_of` while a program is being interpreted by Miri:

```
adjust_for_rust_scalar  at ./compiler/rustc_ty_utils/src/abi.rs:302:35
{closure#2}             at ./compiler/rustc_ty_utils/src/abi.rs:522:25
eval_body_using_ecx<>   at ./compiler/rustc_const_eval/src/const_eval/eval_queries.rs:49:22
{closure#1}<>           at ./compiler/rustc_const_eval/src/interpret/operand.rs:851:76
{closure#0}<>           at ./compiler/rustc_const_eval/src/interpret/stack.rs:612:18
size_and_align          at ./compiler/rustc_middle/src/mir/interpret/mod.rs:387:38
```

I got these by:
- patching rustc with this patch that adds a span to the `layout_of` query which prints the backtrace:
[layout_of_other_places.diff.txt](https://github.com/user-attachments/files/21235523/layout_of_other_places.diff.txt)
- adding this to my bootstrap.toml to have debug symbols inside the Miri binary: `rust.debuginfo-level = "line-tables-only"` and also `build.tool.miri.features = ["tracing"]`
- obtaining a trace file with `MIRI_TRACING=1 ./x.py run miri --stage 1 --warnings warn --args src/tools/miri/tests/pass/hello.rs` (note: maybe using a file different than "src/tools/miri/tests/pass/hello.rs" would lead to more places where layout_of is called?)
-  running this query in Perfetto to select all `layout_of` spans that have as a direct parent a span named "frame" (as opposed to the parent being `InterpCx::layout_of`) and extract their backtrace: `select args.string_value from slice left join args on slice.arg_set_id = args.id where slice.name = "tcx.layout_of" and slice.parent_id in (select slice2.id from slice as slice2 where slice2.name = "frame") group by args.string_value`
- exporting the data as `.tsv` and processing that file through this Python script. It finds the first path in the backtraces where "layout" isn't mentioned, which imo is a good heuristic to not consider `layout_of` wrappers/friends as call places, but rather go down the backtrace until an actual call place is reached. [layout_of_other_places.py.txt](https://github.com/user-attachments/files/21235529/layout_of_other_places.py.txt)

</details>
@rustbot rustbot added A-attributes Area: Attributes (`#[…]`, `#![…]`) A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. A-run-make Area: port run-make Makefiles to rmake.rs A-testsuite Area: The testsuite used to check the correctness of rustc S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. 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. rollup A PR which is a rollup labels Jul 15, 2025
@samueltardieu
Copy link
Contributor Author

@bors r+ p=5 rollup=never

@bors
Copy link
Collaborator

bors commented Jul 15, 2025

📌 Commit d8578d1 has been approved by samueltardieu

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 Jul 15, 2025
@samueltardieu
Copy link
Contributor Author

#138618 has failed a previous solo bors run, I've r-'ed it and will reinclude #143920
@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 Jul 15, 2025
@rustbot rustbot removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Jul 15, 2025
@samueltardieu samueltardieu deleted the rollup-6veoazi branch July 15, 2025 16:04
@rust-log-analyzer
Copy link
Collaborator

The job aarch64-gnu-llvm-19-1 failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
test [ui] tests/ui/zero-sized/zero-sized-btreemap-insert.rs ... ok

failures:

---- [ui] tests/ui/traits/const-traits/match-non-const-eq.rs#stock stdout ----
Saved the actual stderr to `/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/traits/const-traits/match-non-const-eq.stock/match-non-const-eq.stock.stderr`
diff of stderr:

6    |
7    = note: `str` cannot be compared in compile-time, and therefore cannot be used in `match`es
8    = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
-    = note: see issue #67792 <https://github.com/rust-lang/rust/issues/67792> for more information
+    = note: see issue #143874 <https://github.com/rust-lang/rust/issues/143874> for more information
10    = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable
11    = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
12 


The actual stderr differed from the expected stderr
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args traits/const-traits/match-non-const-eq.rs`

error in revision `stock`: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/traits/const-traits/match-non-const-eq.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2" "--target=aarch64-unknown-linux-gnu" "--cfg" "stock" "--check-cfg" "cfg(test,FALSE,stock,gated)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/traits/const-traits/match-non-const-eq.stock" "-A" "unused" "-A" "internal_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/aarch64-unknown-linux-gnu/native/rust-test-helpers"
stdout: none
--- stderr -------------------------------
error[E0658]: cannot match on `str` in constant functions
##[error]  --> /checkout/tests/ui/traits/const-traits/match-non-const-eq.rs:7:9
   |
LL |         "a" => (),
   |         ^^^
   |
   = note: `str` cannot be compared in compile-time, and therefore cannot be used in `match`es
   = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
   = note: see issue #143874 <https://github.com/rust-lang/rust/issues/143874> for more information
   = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable
   = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date

error: `PartialEq` is not yet stable as a const trait
##[error]  --> /checkout/tests/ui/traits/const-traits/match-non-const-eq.rs:7:9
   |
LL |         "a" => (),

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-attributes Area: Attributes (`#[…]`, `#![…]`) A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. A-run-make Area: port run-make Makefiles to rmake.rs A-testsuite Area: The testsuite used to check the correctness of rustc rollup A PR which is a rollup 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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.