Commit Graph

245239 Commits

Author SHA1 Message Date
Michael Goulet
dcca9a12cd Record coroutine kind in generics 2024-02-07 16:18:31 +00:00
bors
d6c46a23ce Auto merge of #120060 - saethlin:mir-opt-bless-targets, r=wesleywiser
Use the same mir-opt bless targets on all platforms

This undoes some of the implementation in https://github.com/rust-lang/rust/pull/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: 4cb17b4e78/compiler/rustc_mir_transform/src/inline.rs (L332-L341)
2024-02-07 14:01:21 +00:00
bors
0809f78c19 Auto merge of #120527 - GnomedDev:atomicu32-handle, r=petrochenkov
Switch OwnedStore handle count to AtomicU32

This is already panics if overflowing a u32, so let's use the smaller int size to save a tiny bit of memory.
2024-02-07 11:57:50 +00:00
Ben Kimock
3c7a8b9d71 Fixup async_closure_shims mir-opt test 2024-02-06 23:40:58 -05:00
Ben Kimock
476f91cbf7 Don't call std_cargo to build mir-only sysroots 2024-02-06 23:36:06 -05:00
Ben Kimock
2116ed723d Tweak a few mir-opt tests instead of using -Clink-dead-code 2024-02-06 23:36:05 -05:00
Ben Kimock
4451bf4d67 Use a better set of targets for blessing mir-opt tests 2024-02-06 23:36:05 -05:00
bors
d4f6f9ee6a Auto merge of #118257 - mu001999:dead_code/trait, r=cjgillot
Make traits / trait methods detected by the dead code lint

Fixes #118139 and #41883
2024-02-07 03:33:39 +00:00
r0cky
c7519d42c2 Update tests 2024-02-07 10:42:01 +08:00
r0cky
40878ca6ea Make traits / trait methods detected by the dead code lint! 2024-02-07 10:22:16 +08:00
bors
586893c7b0 Auto merge of #120722 - matthiaskrgr:rollup-9o32280, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - #119939 (Improve 'generic param from outer item' error for `Self` and inside `static`/`const` items)
 - #120331 (pattern_analysis: use a plain `Vec` in `DeconstructedPat`)
 - #120396 (Account for unbounded type param receiver in suggestions)
 - #120423 (update indirect structural match lints to match RFC and to show up for dependencies)
 - #120435 (Suggest name value cfg when only value is used for check-cfg)
 - #120502 (Remove `ffi_returns_twice` feature)
 - #120507 (Account for non-overlapping unmet trait bounds in suggestion)
 - #120513 (Normalize type outlives obligations in NLL for new solver)
 - #120707 (Don't expect early-bound region to be local when reporting errors in RPITIT well-formedness)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-02-07 00:03:50 +00:00
Matthias Krüger
84114fea9e
Rollup merge of #120707 - compiler-errors:suitable-region, r=nnethercote
Don't expect early-bound region to be local when reporting errors in RPITIT well-formedness

The implicit lifetime in the example code gets replaced with `ReError`, which fails a `sub_regions` check in the lexical region solver. Error reporting ends up calling `is_suitable_region` on an early bound region in the *trait* definition. This causes an ICE because we `expect_local()`.

This is kind of a bad explanation, but this code just makes diagnostics reporting a bit more gracefully fallible. If the reviewer wants a thorough investigation of exactly where we get this region outlives obligation, I can write one up. Doesn't really seem worth it, though, imo.

Fixes #120638
Fixes #120648
2024-02-06 22:45:43 +01:00
Matthias Krüger
012ce8ae98
Rollup merge of #120513 - compiler-errors:normalize-regions-for-nll, r=lcnr
Normalize type outlives obligations in NLL for new solver

Normalize the type outlives assumptions and obligations in MIR borrowck. This should fix any of the lazy-norm-related MIR borrowck problems.

Also some cleanups from last PR:
1. Normalize obligations in a loop in lexical region resolution
2. Use `deeply_normalize_with_skipped_universes` in lexical resolution since we may have, e.g. `for<'a> Alias<'a>: 'b`.

r? lcnr
2024-02-06 22:45:43 +01:00
Matthias Krüger
af99946700
Rollup merge of #120507 - estebank:issue-108428, r=davidtwco
Account for non-overlapping unmet trait bounds in suggestion

When a method not found on a type parameter could have been provided by any
of multiple traits, suggest each trait individually, instead of a single
suggestion to restrict the type parameter with *all* of them.

Before:

```
error[E0599]: the method `cmp` exists for reference `&T`, but its trait bounds were not satisfied
  --> $DIR/method-on-unbounded-type-param.rs:5:10
   |
LL |     (&a).cmp(&b)
   |          ^^^ method cannot be called on `&T` due to unsatisfied trait bounds
   |
   = note: the following trait bounds were not satisfied:
           `T: Ord`
           which is required by `&T: Ord`
           `&T: Iterator`
           which is required by `&mut &T: Iterator`
           `T: Iterator`
           which is required by `&mut T: Iterator`
help: consider restricting the type parameters to satisfy the trait bounds
   |
LL | fn g<T>(a: T, b: T) -> std::cmp::Ordering where T: Iterator, T: Ord {
   |                                           +++++++++++++++++++++++++
```

After:

```
error[E0599]: the method `cmp` exists for reference `&T`, but its trait bounds were not satisfied
  --> $DIR/method-on-unbounded-type-param.rs:5:10
   |
LL |     (&a).cmp(&b)
   |          ^^^ method cannot be called on `&T` due to unsatisfied trait bounds
   |
   = note: the following trait bounds were not satisfied:
           `T: Ord`
           which is required by `&T: Ord`
           `&T: Iterator`
           which is required by `&mut &T: Iterator`
           `T: Iterator`
           which is required by `&mut T: Iterator`
   = 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 g<T: Ord>(a: T, b: T) -> std::cmp::Ordering {
   |       +++++
LL | fn g<T: Iterator>(a: T, b: T) -> std::cmp::Ordering {
   |       ++++++++++
```

Fix #108428.

Follow up to #120396, only last commit is relevant.
2024-02-06 22:45:42 +01:00
Matthias Krüger
59ba8024af
Rollup merge of #120502 - clubby789:remove-ffi-returns-twice, r=compiler-errors
Remove `ffi_returns_twice` feature

The [tracking issue](https://github.com/rust-lang/rust/issues/58314) and [RFC](https://github.com/rust-lang/rfcs/pull/2633) have been closed for a couple of years.

There is also an attribute gate in R-A which should be removed if this lands.
2024-02-06 22:45:42 +01:00
Matthias Krüger
0a4702d011
Rollup merge of #120435 - chenyukang:yukang-fix-120427-cfg-name, r=Urgau,Nilstrieb
Suggest name value cfg when only value is used for check-cfg

Fixes #120427
r? `````````````@Nilstrieb`````````````
2024-02-06 22:45:41 +01:00
Matthias Krüger
176c4ba5c3
Rollup merge of #120423 - RalfJung:indirect-structural-match, r=petrochenkov
update indirect structural match lints to match RFC and to show up for dependencies

This is a large step towards implementing https://github.com/rust-lang/rfcs/pull/3535.
We currently have five lints related to "the structural match situation":
- nontrivial_structural_match
- indirect_structural_match
- pointer_structural_match
- const_patterns_without_partial_eq
- illegal_floating_point_literal_pattern

This PR concerns the first 3 of them. (The 4th already is set up to show for dependencies, and the 5th is removed by https://github.com/rust-lang/rust/pull/116284.) nontrivial_structural_match is being removed as per the RFC; the other two are enabled to show up in dependencies.

Fixes https://github.com/rust-lang/rust/issues/73448 by removing the affected analysis.
2024-02-06 22:45:41 +01:00
Matthias Krüger
a0c3b87823
Rollup merge of #120396 - estebank:method-on-unbounded-type-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 #120186.
2024-02-06 22:45:40 +01:00
Matthias Krüger
ce32d4862b
Rollup merge of #120331 - Nadrieril:no-arena, r=compiler-errors
pattern_analysis: use a plain `Vec` in `DeconstructedPat`

The use of an arena-allocated slice in `DeconstructedPat` dates to when we needed the arena anyway for lifetime reasons. Now that we don't, I'm thinking that if `thir::Pat` can use plain old `Vec`s, maybe so can I.

r? ```@ghost```
2024-02-06 22:45:40 +01:00
Matthias Krüger
3c52832375
Rollup merge of #119939 - clubby789:static-const-generic-note, r=compiler-errors
Improve 'generic param from outer item' error for `Self` and inside `static`/`const` items

Fixes #109596
Fixes #119936
2024-02-06 22:45:39 +01:00
bors
256b6fb19a Auto merge of #117905 - RalfJung:no-const-mut, r=lcnr
revert stabilization of const_intrinsic_copy

`@rust-lang/wg-const-eval`  I don't know what we were thinking when we approved https://github.com/rust-lang/rust/pull/97276... const-eval isn't supposed to be able to mutate anything yet! It's also near impossible to actually call `copy` in const on stable since `&mut` expressions are generally unstable. However, there's one exception...

```rust
static mut INT: i32 = unsafe {
    let val = &mut [1]; // `&mut` on arrays is allowed in `static mut`
    (val as *mut [i32; 1]).copy_from(&[42], 1);
    val[0]
};

fn main() { unsafe {
    dbg!(INT);
} }
```

Inside `static mut`, we accept some `&mut` since ~forever, to make `static mut FOO: &mut [T] = &mut [...];` work. We reject any attempt to actually write to that mutable reference though... except for the `copy` functions.

I think we should revert stabilizing these functions that take `*mut`, and then re-stabilize them together with `ptr.write` once mutable references are stable.

(This will likely fail on PowerPC until https://github.com/rust-lang/stdarch/pull/1497 lands. But we'll need a crater run first anyway.)
2024-02-06 21:43:11 +00: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
Michael Goulet
d9cd0d4d11 Don't expect early-bound region to be local in RPITIT well-formedness 2024-02-06 16:01:54 +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