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

Closed
wants to merge 30 commits into from

Conversation

matthiaskrgr
Copy link
Member

Successful merges:

r? @ghost
@rustbot modify labels: rollup

Create a similar rollup

dianne and others added 30 commits January 20, 2025 16:03
The debug assertion ensuring that the pattern mutability cap holds
assumes the presence of Rule 3, so it now checks for that. I
considered going back to only tracking the mutability cap when Rule 3
is present, but since the mutability cap is used in Rule 5's
implementation too, the debug assertion would still need to check
which typing rules are present.

This also required some changes to tests:
- `ref_pat_eat_one_layer_2021.rs` had a test for Rule 3; I'll be
handling tests for earlier editions in a later commit, so as a stopgap
I've #[cfg]ed it out.
- One test case had to be moved from `well-typed-edition-2024.rs` to
`borrowck-errors.rs` in order to get borrowck to run on it and emit an
error.
These come directly from the "Compare" tab of Typing Rust Patterns,
though they had to be split across multiple files. They're not
comprehensive, but they do provide some previously-missing coverage and
are easier to check against the spec. Possibly they should be split up
some more, since `pattern-errors.rs` is getting a bit unwieldy, but I'm
not sure how best to go about that.
…back for inherited ref mutability mismatches

I think the diagnostic could use some work, but it's more helpful than
the alternative. The previous error was misleading, since it ignored the
inherited reference altogether.
…e pattern doesn't match the mutability of an inner reference

This is the `Deref(EatInner, FallbackToOuter)` rule in Typing Rust Patterns.
- Removes some excess parens

- Removes 3 duplicated tests
This serves two purposes.

First, they're additional tests that stable Rust behavior hasn't been
messed with. There's plenty of other pattern tests, so this is less
important, but these at least are targeted at what's being changed.

Second, this helps document exactly where the new rulesets agree and
disagree with stable pattern typing. This will be especially important
after the new rules for old editions are updated, since they need to be
strictly more permissive; any patterns well-typed on stable should also
be well-typed with the same resultant bindings on the (upcoming) new new
old-edition rules.

The unusual test ordering on `borrowck-errors.rs` and
`ref-binding-on-inh-ref-errors.rs` are to hopefully reduce how much
adding new tests will mess with line numbers in their stderr.
This doesn't (or at least shouldn't!) add, remove, or change any test
cases. I've grouped them by which rule variants they test.
…rules)

Since there are so many ways to write these, I've opted to only include
two sorts of test: simple tests that directly target the rules differing
between rulesets and nuanced tests that produce different errors under
different rulesets. I've also tried not to add any duplicate tests.

`well-typed-edition-2024.rs` already has tests disagreeing with stable,
so I've opted not to include any in this commit that are well-typed
under the new rules.
These are very bare-bones, only intended to provide some documentation
of what these feature gates are and aren't yet implementing.
…, r=Nadrieril

Match Ergonomics 2024: update edition 2024 behavior of feature gates

This updates the edition 2024 behavior of the feature gates `ref_pat_eat_one_layer_2024_structural` and `ref_pat_eat_one_layer_2024` to correspond to the left and right typing rules compared [here](https://nadrieril.github.io/typing-rust-patterns/?compare=true&opts2=AQEBAAABAQABAgIAAQEBAAEBAAABAAA%3D&opts1=AQEBAgEBAQEBAgIAAAAAAAAAAAAAAAA%3D&mode=rules&do_cmp=true&ty_d=3&style=SequentBindingMode), respectively. I'll implement the proposed new behavior for editions ≤ 2021 in another PR.

The tests are split up a bit awkwardly for practical reasons, but I've added new tests from 3 places:
- I got tests for where the typing rules differ from the "Compare" tab of the page linked above. These had to be split up based on where the errors are emitted and how rustfixable they are, so they've ended up in different files to keep tidy. Within each file, though, the order of the tests matches the order the typing differences appear in that comparison (as of when this was written).
- I used [this other comparison](https://nadrieril.github.io/typing-rust-patterns/?q=%5B%26mut+%26%28mut+x%29%5D%3A+%26mut+%5B%26CT%5D&compare=true&opts2=AQEBAgABAQEBAgIAAQEBAAEBAAABAAA%3D&opts1=AQEBAgEBAQEBAgIAAAAAAAAAAAAAAAA%3D&mode=compare&do_cmp=true&ty_d=3&style=SequentBindingMode) to test the `Deref(EatInner, FallbackToOuter)` rule of the left/"structural"/eat-inner ruleset. These are all in `well-typed-edition-2024.rs`.
- I added some select tests for cases where the new typing rules differ from current stable Rust. I had to be pickier about what I included here, but I tried to make sure each typing rule got some coverage. That said, my approach for these tests was a bit ad-hoc, so I may have missed something.

Relevant tracking issue: rust-lang#123076

r? `@ghost`
simplify `similar_tokens` from `Option<Vec<_>>` to `&[_]`

All uses immediately invoke contains, so maybe a further simplification is possible.
Manually walk into WF obligations in `BestObligation` proof tree visitor

When we encounter a `WellFormed` obligation in the `BestObligation` proof tree visitor, ignore the proof tree and call `wf::unnormalized_obligations` to derive well-formed obligations with the correct cause codes. This is to avoid having to replicate the somewhat delicate logic that `wf.rs` does to set up its obligation causes... Don't see a better way to do this.

vibes?? r? lcnr
Allow transmuting generic pattern types to and from their base

Pattern types always have the same size as their base type, so we can just ignore the pattern and look at the base type for figuring out whether transmuting is possible.
…jieyouxu

Fix a couple Emscripten tests

This fixes a couple Emscripten tests where the correct fix is more or less obvious. A couple UI tests are still broken with this PR:

- `tests/ui/abi/numbers-arithmetic/return-float.rs` (rust-lang#136197)
- `tests/ui/no_std/no-std-unwind-binary.rs` (haven't debugged yet)
- `tests/ui/test-attrs/test-passed.rs` (haven't debugged this either)

``@rustbot`` label +T-compiler +O-emscripten
…bzol

ci: refactor how directories are removed in free-disk-space disk
use impl Into<String> instead of explicit type args with bounds
@rustbot rustbot added A-compiletest Area: The compiletest test runner 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-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-infra Relevant to the infrastructure 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 Jan 30, 2025
@matthiaskrgr
Copy link
Member Author

@bors r+ rollup=never p=7

@bors
Copy link
Contributor

bors commented Jan 30, 2025

📌 Commit bfc7127 has been approved by matthiaskrgr

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 Jan 30, 2025
@matthiaskrgr
Copy link
Member Author

@bors p=5

@rust-log-analyzer
Copy link
Collaborator

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

Click to see the possible cause of the failure (guessed by this bot)
#21 exporting to docker image format
#21 sending tarball 27.6s done
#21 DONE 33.6s
##[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-18]
debug: `DISABLE_CI_RUSTC_IF_INCOMPATIBLE` configured.
---
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-18', '--enable-llvm-link-shared', '--set', 'rust.randomize-layout=true', '--set', 'rust.thin-lto-import-instr-limit=10', '--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', 'rust.lld=false', '--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-18/bin/llvm-config
configure: llvm.link-shared     := True
configure: rust.randomize-layout := True
configure: rust.thin-lto-import-instr-limit := 10
---

failures:

---- [ui] tests/ui/typeck/issue-114918/const-in-impl-fn-return-type.rs#next stdout ----
Saved the actual stderr to "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/typeck/issue-114918/const-in-impl-fn-return-type.next/const-in-impl-fn-return-type.next.stderr"

9    |
9    |
10 LL |     fn func<const N: u32>() -> [(); N];
11    |                                ^^^^^^^ expected `usize`, found `u32`
+    |
+    = note: the length of array `[(); N]` must be type `usize`
13 error: aborting due to 2 previous errors
14 



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 typeck/issue-114918/const-in-impl-fn-return-type.rs`

error in revision `next`: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/typeck/issue-114918/const-in-impl-fn-return-type.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/x86_64-unknown-linux-gnu/stage2" "--target=x86_64-unknown-linux-gnu" "--cfg" "next" "--check-cfg" "cfg(test,FALSE,current,next)" "--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/typeck/issue-114918/const-in-impl-fn-return-type.next" "-A" "unused" "-A" "internal_features" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-Znext-solver"
--- stderr -------------------------------
error[E0308]: mismatched types
##[error]  --> /checkout/tests/ui/typeck/issue-114918/const-in-impl-fn-return-type.rs:20:39
   |
   |
LL |     fn func<const N: u32>() -> [(); { () }] {

error: the constant `N` is not of type `usize`
##[error]  --> /checkout/tests/ui/typeck/issue-114918/const-in-impl-fn-return-type.rs:12:32
   |
   |
LL |     fn func<const N: u32>() -> [(); N];
   |                                ^^^^^^^ expected `usize`, found `u32`
   |
   = note: the length of array `[(); N]` must be type `usize`
error: aborting due to 2 previous errors

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

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-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-infra Relevant to the infrastructure 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.

10 participants