Skip to content

Rollup of 10 pull requests #140414

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 28 commits into from
Closed

Conversation

ChrisDenton
Copy link
Member

Successful merges:

Failed merges:

r? @ghost
@rustbot modify labels: rollup

Create a similar rollup

scottmcm and others added 28 commits April 10, 2025 21:07
Also mention them from `as_flattened(_mut)`.
Since deref patterns on boxes will be lowered differently, I'll be
making a separate test file for them. This makes sure we're still
testing the generic `Deref(Mut)::deref(_mut)`-based lowering.
This allows deref patterns to move out of boxes.

Implementation-wise, I've opted to put the information of whether a
deref pattern uses a built-in deref or a method call in the THIR. It'd
be a bit less code to check `.is_box()` everywhere, but I think this way
feels more robust (and we don't have a `mutability` field in the THIR
that we ignore when the smart pointer's a box). I'm not sure about the
naming (or using `ByRef`), though.
Support for `f16` and `f128` is varied across targets, backends, and
backend versions. Eventually we would like to reach a point where all
backends support these approximately equally, but until then we have to
work around some of these nuances of support being observable.

Introduce the `cfg_target_has_reliable_f16_f128` internal feature, which
provides the following new configuration gates:

* `cfg(target_has_reliable_f16)`
* `cfg(target_has_reliable_f16_math)`
* `cfg(target_has_reliable_f128)`
* `cfg(target_has_reliable_f128_math)`

`reliable_f16` and `reliable_f128` indicate that basic arithmetic for
the type works correctly. The `_math` versions indicate that anything
relying on `libm` works correctly, since sometimes this hits a separate
class of codegen bugs.

These options match configuration set by the build script at [1]. The
logic for LLVM support is duplicated as-is from the same script. There
are a few possible updates that will come as a follow up.

The config introduced here is not planned to ever become stable, it is
only intended to replace the build scripts for `std` tests and
`compiler-builtins` that don't have any way to configure based on the
codegen backend.

MCP: rust-lang/compiler-team#866
Closes: rust-lang/compiler-team#866

[1]: https://github.com/rust-lang/rust/blob/555e1d0386f024a8359645c3217f4b3eae9be042/library/std/build.rs#L84-L186
New compiler configuration has been introduced that is designed to
replace the build script configuration `reliable_f16`, `reliable_f128`,
`reliable_f16_math`, and `reliable_f128_math`. Do this replacement here,
which allows us to clean up `std`'s build script.

All tests are gated by `#[cfg(bootstrap)]` rather than doing a more
complicated `cfg(bootstrap)` / `cfg(not(bootstrap))` split since the
next beta split is within two weeks.
The test run-make/amdgpu-kd has an issue where rust-lld will sometimes fail with error 0xc0000374 (STATUS_HEAP_CORRUPTION).
…-inline, r=ZuseZ4

add autodiff inline

closes: rust-lang#138920

r? ``@ZuseZ4``

try-job: dist-aarch64-linux
…, r=dtolnay

Stabilize `slice_as_chunks` library feature

~~Draft as this needs rust-lang#139163 to land first.~~

FCP: rust-lang#74985 (comment)

Methods being stabilized are:
```rust
impl [T] {
    const fn as_chunks<const N: usize>(&self) -> (&[[T; N]], &[T]);
    const fn as_rchunks<const N: usize>(&self) -> (&[T], &[[T; N]]);
    const unsafe fn as_chunks_unchecked<const N: usize>(&self) -> &[[T; N]];
    const fn as_chunks_mut<const N: usize>(&mut self) -> (&mut [[T; N]], &mut [T]);
    const fn as_rchunks_mut<const N: usize>(&mut self) -> (&mut [T], &mut [[T; N]]);
    const unsafe fn as_chunks_unchecked_mut<const N: usize>(&mut self) -> &mut [[T; N]];
}
```

~~(FCP's not done quite yet, but will in another day if I'm counting right.)~~ FCP Complete: rust-lang#74985 (comment)
allow deref patterns to move out of boxes

This adds a case to lower deref patterns on boxes using a built-in deref instead of a `Deref::deref` or `DerefMut::deref_mut` call: if `deref!(inner): Box<T>` is matching on place `place`, the inner pattern `inner` now matches on `*place` rather than a temporary. No longer needing to call a method also means it won't borrow the scrutinee in match arms. This allows for bindings in `inner` to move out of `*place`.

For comparison with box patterns, this uses the same MIR lowering but different THIR. Consequently, deref patterns on boxes are treated the same as any other deref patterns in match exhaustiveness analysis. Box patterns can't quite be implemented in terms of deref patterns until exhaustiveness checking for deref patterns is implemented (I'll open a PR for exhaustiveness soon!).

Tracking issue: rust-lang#87121

r? `@Nadrieril`
…y, r=lcnr

Do not compute type_of for impl item if impl where clauses are unsatisfied

Consider the following code:

```rust
trait Foo {
    fn call(self) -> impl Send;
}

trait Nested {}
impl<T> Foo for T
where
    T: Nested,
{
    fn call(self) -> impl Sized {
        NotSatisfied.call()
    }
}

struct NotSatisfied;
impl Foo for NotSatisfied {
    fn call(self) -> impl Sized {
        todo!()
    }
}
```

In `impl Foo for NotSatisfied`, we need to prove that the RPITIT is well formed. This requires proving the item bound `<NotSatisfied as Foo>::RPITIT: Send`. Normalizing `<NotSatisfied as Foo>::RPITIT: Send` assembles two impl candidates, via the `NotSatisfied` impl and the blanket `T` impl. We end up computing the `type_of` for the blanket impl even if `NotSatisfied: Nested` where clause does not hold.

This type_of query ends up needing to prove that its own `impl Sized` RPIT satisfies `Send`, which ends up needing to compute the hidden type of the RPIT, which is equal to the return type  of `NotSatisfied.call()`. That ends up in a query cycle, since we subsequently try normalizing that return type via the blanket impl again!

In the old solver, we don't end up computing the `type_of` an impl candidate if its where clauses don't hold, since this select call would fail before confirming the projection candidate:

https://github.com/rust-lang/rust/blob/d7ea436a02d5de4033fcf7fd4eb8ed965d0f574c/compiler/rustc_trait_selection/src/traits/project.rs#L882

This PR makes the new solver more consistent with the old solver by adding a call to `try_evaluate_added_goals` after regstering the impl predicates, which causes us to bail before computing the `type_of` for impls if the impl definitely doesn't apply.

r? lcnr

Fixes rust-lang/trait-system-refactor-initiative#185
…lcnr

Move inline asm check to typeck, properly handle aliases

Pull `InlineAsmCtxt` down to `rustc_hir_typeck`, and instead of using things like `Ty::is_copy`, use the `InferCtxt`-aware methods. To fix rust-lang/trait-system-refactor-initiative#189, we also add a `try_structurally_resolve_*` call to `expr_ty`.

r? lcnr
Implement the internal feature `cfg_target_has_reliable_f16_f128`

Support for `f16` and `f128` is varied across targets, backends, and backend versions. Eventually we would like to reach a point where all backends support these approximately equally, but until then we have to work around some of these nuances of support being observable.

Introduce the `cfg_target_has_reliable_f16_f128` internal feature, which provides the following new configuration gates:

* `cfg(target_has_reliable_f16)`
* `cfg(target_has_reliable_f16_math)`
* `cfg(target_has_reliable_f128)`
* `cfg(target_has_reliable_f128_math)`

`reliable_f16` and `reliable_f128` indicate that basic arithmetic for the type works correctly. The `_math` versions indicate that anything relying on `libm` works correctly, since sometimes this hits a separate class of codegen bugs.

These options match configuration set by the build script at [1]. The logic for LLVM support is duplicated as-is from the same script. There are a few possible updates that will come as a follow up.

The config introduced here is not planned to ever become stable, it is only intended to replace the build scripts for `std` tests and `compiler-builtins` that don't have any way to configure based on the codegen backend.

MCP: rust-lang/compiler-team#866
Closes: rust-lang/compiler-team#866

[1]: https://github.com/rust-lang/rust/blob/555e1d0386f024a8359645c3217f4b3eae9be042/library/std/build.rs#L84-L186

---

The second commit makes use of this config to replace `cfg_{f16,f128}{,_math}` in `library/`. I omitted providing a `cfg(bootstrap)` configuration to keep things simpler since the next beta branch is in two weeks.

try-job: aarch64-gnu
try-job: i686-msvc-1
try-job: test-various
try-job: x86_64-gnu
try-job: x86_64-msvc-ext2
Rename sub_ptr to offset_from_unsigned in docs

There are still a few mentions of `sub_ptr` in comments and doc comments, which were missed in rust-lang#137483.
…jieyouxu

Make bootstrap git tests more self-contained

Based on https://stackoverflow.com/a/67512433/1107768.

Fixes: rust-lang#140387

r? ``@jieyouxu``
Workaround for windows-gnu rust-lld test failure

The test run-make/amdgpu-kd has an issue on windows-gnu where rust-lld will sometimes fail with error 0xc0000374 (`STATUS_HEAP_CORRUPTION`).

This works around the issue by passing `--threads=1` to the linker as suggested [here](rust-lang#115985 (comment)). Note I don't know if this will help and it happens only sometimes in our CI so it's hard to test.
…r=compiler-errors

only return nested goals for `Certainty::Yes`

Ambiguous `NormalizesTo` goals can otherwise repeatedly add the same nested goals to the parent.

r? ``@compiler-errors``
@rustbot rustbot added A-run-make Area: port run-make Makefiles to rmake.rs F-autodiff `#![feature(autodiff)]` labels Apr 28, 2025
@rustbot rustbot added 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. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver) rollup A PR which is a rollup labels Apr 28, 2025
@ChrisDenton
Copy link
Member Author

@bors r+ rollup=never p=5

@bors
Copy link
Collaborator

bors commented Apr 28, 2025

📌 Commit d5ecdab has been approved by ChrisDenton

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 Apr 28, 2025
@bors
Copy link
Collaborator

bors commented Apr 28, 2025

⌛ Testing commit d5ecdab with merge 140a9b4bbc0e947373007736fefc5e9b24c1b9f9...

bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 28, 2025
…enton

Rollup of 10 pull requests

Successful merges:

 - rust-lang#139308 (add autodiff inline)
 - rust-lang#139656 (Stabilize `slice_as_chunks` library feature)
 - rust-lang#140022 (allow deref patterns to move out of boxes)
 - rust-lang#140276 (Do not compute type_of for impl item if impl where clauses are unsatisfied)
 - rust-lang#140302 (Move inline asm check to typeck, properly handle aliases)
 - rust-lang#140323 (Implement the internal feature `cfg_target_has_reliable_f16_f128`)
 - rust-lang#140391 (Rename sub_ptr to offset_from_unsigned in docs)
 - rust-lang#140394 (Make bootstrap git tests more self-contained)
 - rust-lang#140396 (Workaround for windows-gnu rust-lld test failure)
 - rust-lang#140402 (only return nested goals for `Certainty::Yes`)

Failed merges:

 - rust-lang#139765 ([beta] Delay `hash_extract_if` stabilization from 1.87 to 1.88)

r? `@ghost`
`@rustbot` modify labels: rollup
@rust-log-analyzer
Copy link
Collaborator

The job aarch64-apple failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
---- [run-make] tests/run-make/amdgpu-kd stdout ----

error: run-make test failed: could not build `rmake.rs` recipe
status: exit status: 1
command: RUSTC_BOOTSTRAP="-1" "/Users/runner/work/rust/rust/build/aarch64-apple-darwin/stage0/bin/rustc" "-o" "/Users/runner/work/rust/rust/build/aarch64-apple-darwin/test/run-make/amdgpu-kd/rmake" "-Ldependency=/Users/runner/work/rust/rust/build/aarch64-apple-darwin/stage0-bootstrap-tools/aarch64-apple-darwin/release" "-Ldependency=/Users/runner/work/rust/rust/build/aarch64-apple-darwin/stage0-bootstrap-tools/aarch64-apple-darwin/release/deps" "-Ldependency=/Users/runner/work/rust/rust/build/aarch64-apple-darwin/stage0-bootstrap-tools/release/deps" "--extern" "run_make_support=/Users/runner/work/rust/rust/build/aarch64-apple-darwin/stage0-bootstrap-tools/aarch64-apple-darwin/release/librun_make_support.rlib" "--edition=2021" "/Users/runner/work/rust/rust/tests/run-make/amdgpu-kd/rmake.rs" "-Cprefer-dynamic" "-Dunused_must_use"
stdout: none
--- stderr -------------------------------
error[E0308]: `if` and `else` have incompatible types
##[error]  --> /Users/runner/work/rust/rust/tests/run-make/amdgpu-kd/rmake.rs:16:84
   |
16 |     let extra_args = if is_windows_gnu() { ["-C", "link-arg=--threads=1"] } else { [] };
   |                                            ------------------------------          ^^ expected an array with a size of 2, found one with a size of 0
   |                                            |
   |                                            expected because of this
   |
   = note: expected array `[&str; 2]`
              found array `[_; 0]`

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0308`.
------------------------------------------

@bors
Copy link
Collaborator

bors commented Apr 28, 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 Apr 28, 2025
@ChrisDenton ChrisDenton deleted the rollup-sgoos3d branch April 28, 2025 23:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-run-make Area: port run-make Makefiles to rmake.rs F-autodiff `#![feature(autodiff)]` rollup A PR which is a rollup 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. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver)
Projects
None yet
Development

Successfully merging this pull request may close these issues.