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 #120622

Closed
wants to merge 28 commits into from

Conversation

matthiaskrgr
Copy link
Member

Successful merges:

Failed merges:

r? @ghost
@rustbot modify labels: rollup

Create a similar rollup

saethlin and others added 28 commits January 20, 2024 20:18
it works when a non-const context that does not enable effects
calls into a const effects-enabled trait. We'd simply suggest the
non-const trait bound in this case consistent to its fallback.
these ui changes are closer to what was there before const_trait_impl changes.
Co-authored-by: Urgau <3616612+Urgau@users.noreply.github.com>
When encountering

```rust
fn f<T>(a: T, b: T) -> std::cmp::Ordering {
    a.cmp(&b) //~ ERROR E0599
}
```

output

```
error[E0599]: no method named `cmp` found for type parameter `T` in the current scope
  --> $DIR/method-on-unbounded-type-param.rs:2:7
   |
LL | fn f<T>(a: T, b: T) -> std::cmp::Ordering {
   |      - method `cmp` not found for this type parameter
LL |     a.cmp(&b)
   |       ^^^ method cannot be called on `T` due to unsatisfied trait bounds
   |
   = help: items from traits can only be used if the type parameter is bounded by the trait
help: the following traits define an item `cmp`, perhaps you need to restrict type parameter `T` with one of them:
   |
LL | fn f<T: Ord>(a: T, b: T) -> std::cmp::Ordering {
   |       +++++
LL | fn f<T: Iterator>(a: T, b: T) -> std::cmp::Ordering {
   |       ++++++++++
```

Fix rust-lang#120186.
make matching on NaN a hard error, and remove the rest of illegal_floating_point_literal_pattern

These arms would never be hit anyway, so the pattern makes little sense. We have had a future-compat lint against float matches in general for a *long* time, so I hope we can get away with immediately making this a hard error.

This is part of implementing rust-lang/rfcs#3535.

Closes rust-lang#41620 by removing the lint.

rust-lang/reference#1456 updates the reference to match.
…wesleywiser

Use the same mir-opt bless targets on all platforms

This undoes some of the implementation in rust-lang#119035, but not the effect. Sorry for the churn, I've learned a lot about how all this works over the past few weeks.

The objective here is to make `x test mir-opt --bless` use the same set of targets on all platforms. It didn't do that from the start because bootstrap assumes that a target linker is available, so the availability of cross-linkers is how we ended up with `MIR_OPT_BLESS_TARGET_MAPPING` and poor support for blessing mir-opt tests from Aarch64 MacOS. This PR corrects that.

So I've adjusted the bless targets for mir-opt tests, as well as tweaked some of the logic in bootstrap about linker configuration so that we don't try to access the cache of cc/linker configuration when doing the mir-opt builds.

While working on that I realized that if I swapped from the `cargo rustc -p std` strategy to `cargo check` on the sysroot, I could use the existing code for check builds to bypass some linker logic. Sweet.

But just doing that doesn't work, because then mir-opt tests complain that they can't find an rlib for any of the standard library crates. That happens because nearly all the mir-opt tests are attempting to build `CrateType::Executable`. We already have all the MIR required for mir-opt tests from the rmeta files, but since rustc think we're trying to build an executable it demands we have access to all the upstream monomorphizations that only exist in rlibs, not the meta files in a MIR-only sysroot.

So to fix that, I've swapped all the mir-opt tests be passed `--crate-type=rlib`. That works, but leaves us with a few broken mir-opt tests which I've blessed or fixed up; we also lose MIR for some functions so I added `-Clink-dead-code` to paper over that. The inlining changes are because changing the crate-type perturbs the hashes that are compared here to sometimes let us do inlining even in a possibly-recursive call: https://github.com/rust-lang/rust/blob/4cb17b4e78e0540e49d2da884cc621a6bf6f47fa/compiler/rustc_mir_transform/src/inline.rs#L332-L341
match lowering: consistently lower bindings deepest-first

Currently when lowering match expressions to MIR, we do a funny little dance with the order of bindings. I attempt to explain it in the third commit: we handle refutable (i.e. needing a test) patterns differently than irrefutable ones. This leads to inconsistencies, as reported in rust-lang#120210. The reason we need a dance at all is for situations like:

```rust
fn foo1(x: NonCopyStruct) {
    let y @ NonCopyStruct { copy_field: z } = x;
    // the above should turn into
    let z = x.copy_field;
    let y = x;
}
```

Here the `y `@`` binding will move out of `x`, so we need to copy the field first.

I believe that the inconsistency came about when we fixed rust-lang#69971, and didn't notice that the fix didn't extend to refutable patterns. My guess then is that ordering bindings by "deepest-first, otherwise source order" is a sound choice. This PR implements that (at least I hope, match lowering is hard to follow 🥲).

Fixes rust-lang#120210

r? `@oli-obk` since you merged the original fix to rust-lang#69971
cc `@matthewjasper`
Actually abort in -Zpanic-abort-tests

When a test fails in panic=abort, it can be useful to have a debugger or other tooling hook into the `abort()` call for debugging. Doing this some other way would require it to hard code details of Rust's panic machinery.

There's no reason we couldn't have done this in the first place; using a single exit code for "success" or "failed" was just simpler. Now we are aware of the special exit codes for posix and windows platforms, logging a special error if an unrecognized code is used on those platforms, and falling back to just "failure" on other platforms.

This continues to account for `#[should_panic]` inside the test process itself, so there's no risk of misinterpreting a random call to `abort()` as an expected panic. Any exit code besides `TR_OK` is logged as a test failure.

As an added benefit, this would allow us to support panic=immediate_abort (but not `#[should_panic]`), without noise about unexpected exit codes when a test fails.
…r=compiler-errors

Reconstify `Add`

r? project-const-traits

I'm not happy with the ui test changes (or failures because I did not bless them and include the diffs in this PR). There is at least some bugs I need to look and try fix:

1. A third duplicated diagnostic when a consumer crate that does not have `effects` enabled has a trait selection error for an upstream const_trait trait. See tests/ui/ufcs/ufcs-qpath-self-mismatch.rs.
2. For some reason, making `Add` a const trait would stop us from suggesting `T: Add` when we try to add two `T`s without that bound. See tests/ui/suggestions/issue-97677.rs
…param, r=nnethercote

Account for unbounded type param receiver in suggestions

When encountering

```rust
fn f<T>(a: T, b: T) -> std::cmp::Ordering {
    a.cmp(&b) //~ ERROR E0599
}
```

output

```
error[E0599]: no method named `cmp` found for type parameter `T` in the current scope
  --> $DIR/method-on-unbounded-type-param.rs:2:7
   |
LL | fn f<T>(a: T, b: T) -> std::cmp::Ordering {
   |      - method `cmp` not found for this type parameter
LL |     a.cmp(&b)
   |       ^^^ method cannot be called on `T` due to unsatisfied trait bounds
   |
   = help: items from traits can only be used if the type parameter is bounded by the trait
help: the following traits define an item `cmp`, perhaps you need to restrict type parameter `T` with one of them:
   |
LL | fn f<T: Ord>(a: T, b: T) -> std::cmp::Ordering {
   |       +++++
LL | fn f<T: Iterator>(a: T, b: T) -> std::cmp::Ordering {
   |       ++++++++++
```

Fix rust-lang#120186.
…ame, r=Urgau,Nilstrieb

Suggest name value cfg when only value is used for check-cfg

Fixes rust-lang#120427
r? ````@Nilstrieb````
@rustbot rustbot added 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. labels Feb 3, 2024
@rustbot rustbot added 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 Feb 3, 2024
@matthiaskrgr
Copy link
Member Author

@bors r+ rollup=never p=107

@bors
Copy link
Contributor

bors commented Feb 3, 2024

📌 Commit 622dad4 has been approved by matthiaskrgr

It is now in the queue for this repository.

@bors
Copy link
Contributor

bors commented Feb 3, 2024

🌲 The tree is currently closed for pull requests below priority 100. This pull request will be tested once the tree is reopened.

@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 Feb 3, 2024
@rust-log-analyzer
Copy link
Collaborator

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

Click to see the possible cause of the failure (guessed by this bot)
GITHUB_ENV=/home/runner/work/_temp/_runner_file_commands/set_env_99f0afc7-1988-4461-9901-72b13c69c6d7
GITHUB_EVENT_NAME=pull_request
GITHUB_EVENT_PATH=/home/runner/work/_temp/_github_workflow/event.json
GITHUB_GRAPHQL_URL=https://api.github.com/graphql
GITHUB_HEAD_REF=rollup-3hkfqx4
GITHUB_JOB=pr
GITHUB_PATH=/home/runner/work/_temp/_runner_file_commands/add_path_99f0afc7-1988-4461-9901-72b13c69c6d7
GITHUB_REF=refs/pull/120622/merge
GITHUB_REF_NAME=120622/merge
GITHUB_REF_PROTECTED=false
---
#12 writing image sha256:1f33c8792b0f665892e90575f44839244f187fd3d592fdc1883839eec60eaad3 done
#12 naming to docker.io/library/rust-ci done
#12 DONE 10.1s
##[endgroup]
Setting extra environment values for docker:  --env ENABLE_GCC_CODEGEN=1 --env GCC_EXEC_PREFIX=/usr/lib/gcc/
[CI_JOB_NAME=x86_64-gnu-llvm-16]
##[group]Clock drift check
  local time: Sat Feb  3 20:42:50 UTC 2024
  network time: Sat, 03 Feb 2024 20:42:50 GMT
  network time: Sat, 03 Feb 2024 20:42:50 GMT
##[endgroup]
sccache: Starting the server...
##[group]Configure the build
configure: processing command line
configure: 
configure: build.configure-args := ['--build=x86_64-unknown-linux-gnu', '--llvm-root=/usr/lib/llvm-16', '--enable-llvm-link-shared', '--set', 'rust.thin-lto-import-instr-limit=10', '--set', 'change-id=99999999', '--enable-verbose-configure', '--enable-sccache', '--disable-manage-submodules', '--enable-locked-deps', '--enable-cargo-native-static', '--set', 'rust.codegen-units-std=1', '--set', 'dist.compression-profile=balanced', '--dist-compression-formats=xz', '--set', 'build.optimized-compiler-builtins', '--disable-dist-src', '--release-channel=nightly', '--enable-debug-assertions', '--enable-overflow-checks', '--enable-llvm-assertions', '--set', 'rust.verify-llvm-ir', '--set', 'rust.codegen-backends=llvm,cranelift,gcc', '--set', 'llvm.static-libstdcpp', '--enable-new-symbol-mangling']
configure: target.x86_64-unknown-linux-gnu.llvm-config := /usr/lib/llvm-16/bin/llvm-config
configure: llvm.link-shared     := True
configure: rust.thin-lto-import-instr-limit := 10
configure: change-id            := 99999999
---

---- [ui] tests/ui/ufcs/ufcs-qpath-self-mismatch.rs stdout ----
diff of stderr:

68 LL |     <i32 as Add<i32>>::add(1, 2i32);
70 
70 
- error[E0277]: cannot add `u32` to `i32`
-   --> $DIR/ufcs-qpath-self-mismatch.rs:4:5
-    |
- LL |     <i32 as Add<u32>>::add(1, 2);
-    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no implementation for `i32 + u32`
-    = help: the trait `Add<u32>` is not implemented for `i32`
-    = help: the trait `Add<u32>` is not implemented for `i32`
-    = help: the following other types implement trait `Add<Rhs>`:
-              <i32 as Add>
-              <i32 as Add<&i32>>
-              <&'a i32 as Add<i32>>
-              <&i32 as Add<&i32>>
- error: aborting due to 5 previous errors
+ error: aborting due to 4 previous errors
85 
86 Some errors have detailed explanations: E0277, E0308.
---
status: exit status: 1
command: RUSTC_ICE="0" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/ufcs/ufcs-qpath-self-mismatch.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" "--sysroot" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2" "--target=x86_64-unknown-linux-gnu" "--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/x86_64-unknown-linux-gnu/test/ui/ufcs/ufcs-qpath-self-mismatch" "-A" "unused" "-A" "internal_features" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/ufcs/ufcs-qpath-self-mismatch/auxiliary"
stdout: none
--- stderr -------------------------------
error[E0277]: cannot add `u32` to `i32`
   |
   |
LL |     <i32 as Add<u32>>::add(1, 2);
   |      ^^^ no implementation for `i32 + u32`
   = help: the trait `Add<u32>` is not implemented for `i32`
   = help: the trait `Add<u32>` is not implemented for `i32`
   = help: the following other types implement trait `Add<Rhs>`:
             <i32 as Add>
             <i32 as Add<&i32>>
             <&'a i32 as Add<i32>>
             <&i32 as Add<&i32>>

error[E0277]: cannot add `u32` to `i32`
   |
   |
LL |     <i32 as Add<u32>>::add(1, 2);
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no implementation for `i32 + u32`
   = help: the trait `Add<u32>` is not implemented for `i32`
   = help: the trait `Add<u32>` is not implemented for `i32`
   = help: the following other types implement trait `Add<Rhs>`:
             <i32 as Add>
             <i32 as Add<&i32>>
             <&'a i32 as Add<i32>>
             <&i32 as Add<&i32>>
error[E0308]: mismatched types
##[error]  --> /checkout/tests/ui/ufcs/ufcs-qpath-self-mismatch.rs:8:28
   |
   |
LL |     <i32 as Add<i32>>::add(1u32, 2);
   |     ---------------------- ^^^^ expected `i32`, found `u32`
   |     arguments to this function are incorrect
   |
help: the return type of this call is `u32` due to the type of the argument passed
  --> /checkout/tests/ui/ufcs/ufcs-qpath-self-mismatch.rs:8:5
  --> /checkout/tests/ui/ufcs/ufcs-qpath-self-mismatch.rs:8:5
   |
LL |     <i32 as Add<i32>>::add(1u32, 2);
   |                            |
   |                            this argument influences the return type of `Add`
note: method defined here
  --> /rustc/FAKE_PREFIX/library/core/src/ops/arith.rs:92:8
  --> /rustc/FAKE_PREFIX/library/core/src/ops/arith.rs:92:8
help: change the type of the numeric literal from `u32` to `i32`
   |
LL |     <i32 as Add<i32>>::add(1i32, 2);

error[E0308]: mismatched types
##[error]  --> /checkout/tests/ui/ufcs/ufcs-qpath-self-mismatch.rs:10:31
   |
   |
LL |     <i32 as Add<i32>>::add(1, 2u32);
   |     ----------------------    ^^^^ expected `i32`, found `u32`
   |     arguments to this function are incorrect
   |
help: the return type of this call is `u32` due to the type of the argument passed
  --> /checkout/tests/ui/ufcs/ufcs-qpath-self-mismatch.rs:10:5
  --> /checkout/tests/ui/ufcs/ufcs-qpath-self-mismatch.rs:10:5
   |
LL |     <i32 as Add<i32>>::add(1, 2u32);
   |                               |
   |                               this argument influences the return type of `Add`
note: method defined here
  --> /rustc/FAKE_PREFIX/library/core/src/ops/arith.rs:92:8
  --> /rustc/FAKE_PREFIX/library/core/src/ops/arith.rs:92:8
help: change the type of the numeric literal from `u32` to `i32`
   |
LL |     <i32 as Add<i32>>::add(1, 2i32);

error: aborting due to 4 previous errors

Some errors have detailed explanations: E0277, E0308.

@matthiaskrgr matthiaskrgr mentioned this pull request Feb 3, 2024
@matthiaskrgr matthiaskrgr deleted the rollup-3hkfqx4 branch March 16, 2024 18:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-testsuite Area: The testsuite used to check the correctness of rustc 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-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.