Commit graph

245196 commits

Author SHA1 Message Date
Nicholas Nethercote e55df623ea Remove an unchecked_claim_error_was_emitted call.
When `catch_fatal_errors` catches a `FatalErrorMarker`, it returns an
`ErrorGuaranteed` that is conjured out of thin air with
`unchecked_claim_error_was_emitted`. But that `ErrorGuaranteed` is never
used.

This commit changes it to instead conjure a `FatalError` out of thin
air. (A non-deprecated action!) This makes more sense because
`FatalError` and `FatalErrorMarker` are a natural pairing -- a
`FatalErrorMarker` is created by calling `FatalError::raise`, so this is
effectively getting back the original `FatalError`.

This requires a tiny change in `catch_with_exit_code`. The old result of
the `catch_fatal_errors` call there was
`Result<Result<(), ErrorGuaranteed>, ErrorGuaranteed>` which could be
`flatten`ed into `Result<(), ErrorGuaranteed>`. The new result of the
`catch_fatal_errors` calls is
`Result<Result<(), ErrorGuaranteed>, FatalError>`, which can't be
`flatten`ed but is still easily matched for the success case.
2024-02-07 18:57:38 +11:00
Nicholas Nethercote 8d1c20a539 Remove return value from emit_stashed_diagnostics.
It's never used.
2024-02-07 09:54:59 +11:00
bors 0d531351e8 Auto merge of #120715 - matthiaskrgr:rollup-sp1pp74, r=matthiaskrgr
Rollup of 12 pull requests

Successful merges:

 - #120520 (Some cleanups around diagnostic levels.)
 - #120575 (Simplify codegen diagnostic handling)
 - #120597 (Suggest `[tail @ ..]` on `[..tail]` and `[...tail]` where `tail` is unresolved)
 - #120602 (rustc_monomorphize: fix outdated comment in partition)
 - #120609 (hir: Stop keeping prefixes for most of `use` list stems)
 - #120631 (Emit a diagnostic for invalid target options)
 - #120632 (For E0223, suggest associated functions that are similar to the path)
 - #120670 (cleanup effect var handling)
 - #120673 (rustc_metadata: fix typo)
 - #120683 (miri: fix ICE with symbolic alignment check on extern static)
 - #120690 (Remove b-naber from the compiler review rotation)
 - #120713 (Make async closures test use async bound modifier)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-02-06 19:38:39 +00:00
Matthias Krüger d98a8a1185
Rollup merge of #120713 - compiler-errors:async-bounds-on-tests, r=fmease
Make async closures test use async bound modifier

Cosmetic change, separates the `AsyncFn` definitions from the tests.
2024-02-06 19:40:11 +01:00
Matthias Krüger 0ab3f01213
Rollup merge of #120690 - fmease:review-rotation-update, r=compiler-errors
Remove b-naber from the compiler review rotation

They have been inactive for over two months and occasionally S-waiting-on-review PRs didn't get reviewed for a while. I've stolen a few of them.

I've discussed this with `@b-naber` in private and they agreed to leave the review rotation for now.
Thank you very much for all the helpful PR reviews you did in the past! <3

r? compiler
2024-02-06 19:40:11 +01:00
Matthias Krüger 6908d3ec9e
Rollup merge of #120683 - RalfJung:symbolic-alignment-ice, r=oli-obk
miri: fix ICE with symbolic alignment check on extern static

Fixes https://github.com/rust-lang/miri/issues/3288. Also fixes [this example](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=38ee338ff10726be72bdd6efa3386763).

This could almost be a Miri PR, except for that typo fix in the validator. I started this as a rustc patch since I thought I need rustc changes, and now it'd be too annoying to turn this into a Miri PR...

r? `@oli-obk`
2024-02-06 19:40:10 +01:00
Matthias Krüger 054fa0b608
Rollup merge of #120673 - klensy:typo2, r=compiler-errors
rustc_metadata: fix typo
2024-02-06 19:40:10 +01:00
Matthias Krüger cee621203e
Rollup merge of #120670 - lcnr:effect-var-storage, r=fee1-dead
cleanup effect var handling

r? types
2024-02-06 19:40:09 +01:00
Matthias Krüger eae477d4e8
Rollup merge of #120632 - trevyn:issue-109195, r=oli-obk
For E0223, suggest associated functions that are similar to the path

e.g. for `String::from::utf8`, suggest `String::from_utf8`

Closes #109195
2024-02-06 19:40:09 +01:00
Matthias Krüger 8906977542
Rollup merge of #120631 - saethlin:invalid-target-ice, r=compiler-errors
Emit a diagnostic for invalid target options

This turns the ICE in https://github.com/rust-lang/rust/issues/120625 into a translatable diagnostic.
2024-02-06 19:40:08 +01:00
Matthias Krüger 3731acc714
Rollup merge of #120609 - petrochenkov:nousestem2, r=compiler-errors
hir: Stop keeping prefixes for most of `use` list stems

And make sure all other imports have non-empty resolution lists.

Addresses one of FIXMEs in https://github.com/rust-lang/rust/pull/120206.
2024-02-06 19:40:08 +01:00
Matthias Krüger 5a2cec2615
Rollup merge of #120602 - klensy:mono-comment, r=nnethercote
rustc_monomorphize: fix outdated comment in partition

`max_cgu_count` was removed in 51821515b3, but not comment (usage in `merge_codegen_units` was removed earlier).

r? `@nnethercote`
2024-02-06 19:40:07 +01:00
Matthias Krüger 89aa85d805
Rollup merge of #120597 - fmease:sugg-on-js-style-spread-op-in-pat, r=estebank
Suggest `[tail @ ..]` on `[..tail]` and `[...tail]` where `tail` is unresolved

Fixes #120591.
~~Will conflict with #120570~~ (rebased).

r? estebank or compiler
2024-02-06 19:40:07 +01:00
Matthias Krüger a3d3ccf098
Rollup merge of #120575 - nnethercote:simplify-codegen-diag-handling, r=estebank
Simplify codegen diagnostic handling

Some nice improvements. Details in the individual commit logs.

r? ````@estebank````
2024-02-06 19:40:06 +01:00
Matthias Krüger 5587be8164
Rollup merge of #120520 - nnethercote:rename-good-path, r=oli-obk
Some cleanups around diagnostic levels.

Plus some refactoring in and around diagnostic levels and emission. Details in the individual commit logs.

r? ````@oli-obk````
2024-02-06 19:40:06 +01:00
Michael Goulet f1308783b4 Make async closures test use async bound modifier 2024-02-06 17:41:48 +00:00
bors 4a2fe4491e Auto merge of #120361 - compiler-errors:async-closures, r=oli-obk
Rework support for async closures; allow them to return futures that borrow from the closure's captures

This PR implements a new lowering for async closures via `TyKind::CoroutineClosure` which handles the curious relationship between the closure and the coroutine that it returns.

I wrote up a bunch in [this hackmd](https://hackmd.io/`@compiler-errors/S1HvqQxca)` which will be copied to the dev guide after this PR lands, and hopefully left sufficient comments in the source code explaining why this change is as large as it is.

This also necessitates that they begin implementing the `AsyncFn`-family of traits, rather than the `Fn`-family of traits -- if you need `Fn` implementations, you should probably use the non-sugar `|| async {}` syntax instead.

Notably this PR does not yet implement `async Fn()` syntax sugar for bounds, but I expect to add those soon (**edit:** #120392). For now, users must use `AsyncFn()` traits directly, which necessitates adding the `async_fn_traits` feature gate as well. I will add this as a follow-up very soon.

r? oli-obk

This is based on top of #120322, but that PR is minimal.
2024-02-06 15:04:01 +00:00
bors 037f515caf Auto merge of #120368 - klensy:llvm-fixme, r=nikic
llvm-wrapper: remove llvm 12 hack

effectively reverts 9a8acea783

r? `@nikic`
2024-02-06 12:17:21 +00:00
klensy ca35cfb6de review 2024-02-06 12:44:40 +03:00
klensy 2a06b69ba2 llvm-wrapper: remove llvm 12 hack
effectively reverts 9a8acea783
2024-02-06 12:24:30 +03:00
Ralf Jung 25635b9a96 miri: fix ICE with symbolic alignment check on extern static 2024-02-06 10:17:42 +01:00
bors 94df917a74 Auto merge of #120509 - shepmaster:m1-runners-redux, r=jdno
Re-enable M1 runners on GitHub Actions

r? `@ghost`
2024-02-06 06:58:34 +00:00
bors ff95e52665 Auto merge of #120326 - tmandry:abort-in-tests, r=cuviper
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.
2024-02-06 04:15:41 +00:00
trevyn 0b6af718d8 Create helper maybe_report_similar_assoc_fn 2024-02-05 18:53:28 -08:00
Michael Goulet ed7fca1f88 Fudge coroutine argument for CoroutineKindShim in fn_sig_for_fn_abi 2024-02-06 02:53:06 +00:00
Oli Scherer 827bfe4154 Document async_fn_traits 2024-02-06 02:22:58 +00:00
Michael Goulet ca44416023 Fix drop shim for AsyncFnOnce closure, AsyncFnMut shim for AsyncFn closure 2024-02-06 02:22:58 +00:00
Michael Goulet c98d6994a3 More comments, final tweaks 2024-02-06 02:22:58 +00:00
Michael Goulet 37184e86ea Add some tests 2024-02-06 02:22:58 +00:00
Michael Goulet 881b6b5149 Bless tests, add comments 2024-02-06 02:22:58 +00:00
Michael Goulet 427896dd7e Construct body for by-move coroutine closure output 2024-02-06 02:22:58 +00:00
Michael Goulet fc4fff4038 Build a shim to call async closures with different AsyncFn trait kinds 2024-02-06 02:22:58 +00:00
Michael Goulet a82bae2172 Teach typeck/borrowck/solvers how to deal with async closures 2024-02-06 02:22:58 +00:00
Michael Goulet c567eddec2 Add CoroutineClosure to TyKind, AggregateKind, UpvarArgs 2024-02-06 02:22:58 +00:00
Michael Goulet a20421734b Make async closures directly lower to ClosureKind::CoroutineClosure 2024-02-06 02:22:58 +00:00
Michael Goulet b2bb51734c Make sure that async closures (and fns) only capture their parent callable's parameters by move, and nothing else 2024-02-06 02:22:57 +00:00
bors f3b9d47a46 Auto merge of #120392 - compiler-errors:async-bound-modifier, r=davidtwco,fmease
Introduce support for `async` bound modifier on `Fn*` traits

Adds `async` to the list of `TraitBoundModifiers`, which instructs AST lowering to map the trait to an async flavor of the trait. For now, this is only supported for `Fn*` to `AsyncFn*`, and I expect that this manual mapping via lang items will be replaced with a better system in the future.

The motivation for adding these bounds is to separate the users of async closures from the exact trait desugaring of their callable bounds. Instead of users needing to be concerned with the `AsyncFn` trait, they should be able to write `async Fn()` and it will desugar to whatever underlying trait we decide is best for the lowering of async closures.

Note: rustfmt support can be done in the rustfmt repo after a subtree sync.
2024-02-06 00:45:11 +00:00
León Orell Valerian Liehr d321437204
Remove b-naber from the compiler review rotation 2024-02-06 00:37:57 +01:00
bors f067fd6084 Auto merge of #120313 - Nadrieril:graceful-error, r=compiler-errors
pattern_analysis: Gracefully abort on type incompatibility

This leaves the option for a consumer of the crate to return `Err` instead of panicking on type error. rust-analyzer could use that (e.g. https://github.com/rust-lang/rust-analyzer/issues/15808).

Since the only use of `TypeCx::bug` is in `Constructor::is_covered_by`, it is tempting to return `false` instead of `Err()`, but that would cause "non-exhaustive match" false positives.

r? `@compiler-errors`
2024-02-05 21:36:25 +00:00
bors ea37e8091f Auto merge of #117372 - Amanieu:stdarch_update, r=Mark-Simulacrum
Update stdarch submodule

Splits up #27731 into multiple tracking issues.

Closes #27731
2024-02-05 15:41:40 +00:00
bors 86eaa892c0 Auto merge of #120671 - matthiaskrgr:rollup-spjnpno, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #113833 (`std::error::Error` -> Trait Implementations: lifetimes consistency improvement)
 - #115386 (PartialEq, PartialOrd: update and synchronize handling of transitive chains)
 - #116284 (make matching on NaN a hard error, and remove the rest of illegal_floating_point_literal_pattern)
 - #118960 (Add LocalWaker and ContextBuilder types to core, and LocalWake trait to alloc.)
 - #120384 (Use `<T, U>` for array/slice equality `impl`s)
 - #120518 (riscv only supports split_debuginfo=off for now)
 - #120657 (Remove unused struct)
 - #120661 (target: default to the medium code model on LoongArch targets)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-02-05 13:23:56 +00:00
klensy f32aa1aef9 rustc_metadata: fix typo 2024-02-05 14:20:15 +03:00
Nicholas Nethercote d9508a1fd2 Make Emitter::emit_diagnostic consuming.
All the other `emit`/`emit_diagnostic` methods were recently made
consuming (e.g. #119606), but this one wasn't. But it makes sense to.

Much of this is straightforward, and lots of `clone` calls are avoided.
There are a couple of tricky bits.
- `Emitter::primary_span_formatted` no longer takes a `Diagnostic` and
  returns a pair. Instead it takes the two fields from `Diagnostic` that
  it used (`span` and `suggestions`) as `&mut`, and modifies them. This
  is necessary to avoid the cloning of `diag.children` in two emitters.
- `from_errors_diagnostic` is rearranged so various uses of `diag` occur
  before the consuming `emit_diagnostic` call.
2024-02-05 21:27:01 +11:00
Matthias Krüger dc0b1f961a
Rollup merge of #120661 - xen0n:loong-medium-cmodel, r=heiher,Nilstrieb
target: default to the medium code model on LoongArch targets

The Rust LoongArch targets have been using the default LLVM code model so far, which is "small" in LLVM-speak and "normal" in LoongArch-speak. As [described][1] in the "Code Model" section of LoongArch ELF psABI spec v20231219, one can only make function calls as far as ±128MiB with the "normal" code model; this is insufficient for very large software containing Rust components that needs to be linked into the big text section, such as Chromium.

Because:

* we do not want to ask users to recompile std if they are to build such software,
* objects compiled with larger code models can be linked with those with smaller code models without problems, and
* the "medium" code model is comparable to the "small"/"normal" one performance-wise (same data access pattern; each function call becomes 2-insn long and indirect, but this may be relaxed back into the direct 1-insn form in a future LLVM version), but is able to perform function calls within ±128GiB,

it is better to just switch the targets to the "medium" code model, which is also "medium" in LLVM-speak.

[1]: https://github.com/loongson/la-abi-specs/blob/v2.30/laelf.adoc#code-models
2024-02-05 11:07:28 +01:00
Matthias Krüger 13ea09b22f
Rollup merge of #120657 - mu001999:clean, r=Nilstrieb
Remove unused struct

Detected by #118257
2024-02-05 11:07:28 +01:00
Matthias Krüger 540936ca99
Rollup merge of #120518 - kxxt:riscv-split-debug-info, r=compiler-errors
riscv only supports split_debuginfo=off for now

Disable packed/unpacked options for riscv linux/android. Other riscv targets already only have the off option.

The packed/unpacked options might be supported in the future. See upstream issue for more details:
https://github.com/llvm/llvm-project/issues/56642

Fixes #110224
2024-02-05 11:07:27 +01:00
Matthias Krüger 2624bfbc0d
Rollup merge of #120384 - wackbyte:array-equality-generics, r=Mark-Simulacrum
Use `<T, U>` for array/slice equality `impl`s

Makes the trait implementation documentation for arrays and slices appear more consistent.

[Example](https://doc.rust-lang.org/1.75.0/std/primitive.array.html): mixed `A`, `B`, and `U`.
![List of PartialEq implementations for arrays](https://github.com/wackbyte/rust/assets/29505620/823c010e-ee57-4de1-885b-a1cd6dcaf85f)

This change makes them all `U`.
2024-02-05 11:07:27 +01:00
Matthias Krüger 80e8c7e125
Rollup merge of #118960 - tvallotton:local_waker, r=Mark-Simulacrum
Add LocalWaker and ContextBuilder types to core, and LocalWake trait to alloc.

Implementation for  #118959.
2024-02-05 11:07:26 +01:00
Matthias Krüger ed27148812
Rollup merge of #116284 - RalfJung:no-nan-match, r=cjgillot
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 https://github.com/rust-lang/rfcs/pull/3535.

Closes https://github.com/rust-lang/rust/issues/41620 by removing the lint.

https://github.com/rust-lang/reference/pull/1456 updates the reference to match.
2024-02-05 11:07:26 +01:00
Matthias Krüger fd8ea25882
Rollup merge of #115386 - RalfJung:partial-eq-chain, r=dtolnay
PartialEq, PartialOrd: update and synchronize handling of transitive chains

It was brought up in https://internals.rust-lang.org/t/total-equality-relations-as-std-eq-rhs/19232 that we currently have a gap in our `PartialEq` rules, which this PR aims to close:

> For example, with PartialEq's conditions you may have a = b = c = d ≠ a (where a and c are of type A, b and d are of type B).

The second commit fixes https://github.com/rust-lang/rust/issues/87067 by updating PartialOrd to handle the requirements the same way PartialEq does.
2024-02-05 11:07:25 +01:00