Commit Graph

251402 Commits

Author SHA1 Message Date
lcnr
2b67f0104a check FnDef return type for WF 2024-04-04 01:55:29 +01:00
bors
4fd4797c26 Auto merge of #123429 - matthiaskrgr:rollup-4emw4e9, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #121595 (Better reporting on generic argument mismatchs)
 - #122619 (Fix some unsoundness with PassMode::Cast ABI)
 - #122964 (Rename `expose_addr` to `expose_provenance`)
 - #123291 (Move some tests)
 - #123301 (pattern analysis: fix union handling)
 - #123395 (More postfix match fixes)
 - #123419 (rustc_index: Add a `ZERO` constant to index types)
 - #123421 (Fix target name in NetBSD platform-support doc)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-04-03 20:19:51 +00:00
Matthias Krüger
65398c46b8
Rollup merge of #123421 - taiki-e:netbsd-doc, r=Nilstrieb
Fix target name in NetBSD platform-support doc

NetBSD platform-support doc currently mentions `amd64-unknown-netbsd`, but it is not a valid target name (the correct name is `x86_64-unknown-netbsd`).

ceab6128fa/src/doc/rustc/src/platform-support/netbsd.md (L16)

```console
$ rustc --print target-list | grep netbsd
aarch64-unknown-netbsd
aarch64_be-unknown-netbsd
armv6-unknown-netbsd-eabihf
armv7-unknown-netbsd-eabihf
i586-unknown-netbsd
i686-unknown-netbsd
mipsel-unknown-netbsd
powerpc-unknown-netbsd
riscv64gc-unknown-netbsd
sparc64-unknown-netbsd
x86_64-unknown-netbsd
```
2024-04-03 22:11:02 +02:00
Matthias Krüger
25b0e84170
Rollup merge of #123419 - petrochenkov:zeroindex, r=compiler-errors
rustc_index: Add a `ZERO` constant to index types

It is commonly used.
2024-04-03 22:11:02 +02:00
Matthias Krüger
202509b427
Rollup merge of #123395 - compiler-errors:postfix-matches-fixes-2, r=petrochenkov
More postfix match fixes

These affect diagnostics only, as far as I can tell. I'm too lazy to come up with UI tests, but I could be convinced otherwise.

Specifically, I think changing the precedence computation actually doesn't change anything, but tweaking `contains_exterior_struct_lit` does mean that some diagnostics will begin parenthesizing `S {}.match {}`.
2024-04-03 22:11:01 +02:00
Matthias Krüger
5f74403c8e
Rollup merge of #123301 - Nadrieril:unions, r=compiler-errors
pattern analysis: fix union handling

Little known fact: rust supports union patterns. Exhaustiveness handles them soundly but reports nonsensical missing patterns. This PR fixes the reported patterns and documents what we're doing.

r? `@compiler-errors`
2024-04-03 22:11:01 +02:00
Matthias Krüger
0c8c18fcc6
Rollup merge of #123291 - c410-f3r:testsssssss, r=petrochenkov
Move some tests

r? `@petrochenkov`
2024-04-03 22:11:01 +02:00
Matthias Krüger
80d592cc24
Rollup merge of #122964 - joboet:pointer_expose, r=Amanieu
Rename `expose_addr` to `expose_provenance`

`expose_addr` is a bad name, an address is just a number and cannot be exposed. The operation is actually about the provenance of the pointer.

This PR thus changes the name of the method to `expose_provenance` without changing its return type. There is sufficient precedence for returning a useful value from an operation that does something else without the name indicating such, e.g. [`Option::insert`](https://doc.rust-lang.org/nightly/std/option/enum.Option.html#method.insert) and [`MaybeUninit::write`](https://doc.rust-lang.org/nightly/std/mem/union.MaybeUninit.html#method.write).

Returning the address is merely convenient, not a fundamental part of the operation. This is implied by the fact that integers do not have provenance since
```rust
let addr = ptr.addr();
ptr.expose_provenance();
let new = ptr::with_exposed_provenance(addr);
```
must behave exactly like
```rust
let addr = ptr.expose_provenance();
let new = ptr::with_exposed_provenance(addr);
```
as the result of `ptr.expose_provenance()` and `ptr.addr()` is the same integer. Therefore, this PR removes the `#[must_use]` annotation on the function and updates the documentation to reflect the important part.

~~An alternative name would be `expose_provenance`. I'm not at all opposed to that, but it makes a stronger implication than we might want that the provenance of the pointer returned by `ptr::with_exposed_provenance`[^1] is the same as that what was exposed, which is not yet specified as such IIUC. IMHO `expose` does not make that connection.~~

A previous version of this PR suggested `expose` as name, libs-api [decided on](https://github.com/rust-lang/rust/pull/122964#issuecomment-2033194319) `expose_provenance` to keep the symmetry with `with_exposed_provenance`.

CC `@RalfJung`
r? libs-api

[^1]: I'm using the new name for `from_exposed_addr` suggested by #122935 here.
2024-04-03 22:11:00 +02:00
Matthias Krüger
bc8415b9e6
Rollup merge of #122619 - erikdesjardins:cast, r=compiler-errors
Fix some unsoundness with PassMode::Cast ABI

Fixes #122617

Reviewable commit-by-commit. More info in each commit message.
2024-04-03 22:11:00 +02:00
Matthias Krüger
32c8c5cb7e
Rollup merge of #121595 - strottos:issue_116615, r=compiler-errors
Better reporting on generic argument mismatchs

This allows better reporting as per issue #116615 .

If you have a function:
```
fn foo(a: T, b: T) {}
```
and call it like so:
```
foo(1, 2.)
```
it'll give improved error reported similar to the following:
```
error[E0308]: mismatched types
 --> generic-mismatch-reporting-issue-116615.rs:6:12
  |
6 |     foo(1, 2.);
  |     --- -  ^^ expected integer, found floating-point number
  |     |   |
  |     |   expected argument `b` to be an integer because that argument needs to match the type of this parameter
  |     arguments to this function are incorrect
  |
note: function defined here
 --> generic-mismatch-reporting-issue-116615.rs:1:4
  |
1 | fn foo<T>(a: T, b: T) {}
  |    ^^^ -  ----  ----
  |        |  |     |
  |        |  |     this parameter needs to match the integer type of `a`
  |        |  `b` needs to match the type of this parameter
  |        `a` and `b` all reference this parameter T
```

Open question, do we need to worry about error message translation into other languages? Not sure what the status of that is in Rust.

NB: Needs some checking over and some tests have altered that need sanity checking, but overall this is starting to get somewhere now. Will take out of draft PR status when this has been done, raising now to allow feedback at this stage, probably 90% ready.
2024-04-03 22:10:59 +02:00
bors
98efd808e1 Auto merge of #123415 - petrochenkov:parenting, r=compiler-errors
hir: Drop owner's own item-local id (zero) from parenting tables

I expect this to be a common case.
2024-04-03 18:18:44 +00:00
Taiki Endo
6edb021fd3 Fix target name in NetBSD platform-support doc 2024-04-04 01:31:04 +09:00
bors
703dc9ce64 Auto merge of #123416 - matthiaskrgr:rollup-j85wj05, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #123209 (Add section to sanitizer doc for `-Zexternal-clangrt`)
 - #123342 (x.py test: remove no-op --skip flag)
 - #123382 (Assert `FnDef` kind)
 - #123386 (Set `CARGO` instead of `PATH` for Rust Clippy)
 - #123393 (rustc_ast: Update `P<T>` docs to reflect mutable status.)
 - #123394 (Postfix match fixes)
 - #123412 (Output URLs of CI artifacts to GitHub summary)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-04-03 16:16:52 +00:00
Vadim Petrochenkov
b40ea03f8a rustc_index: Add a ZERO constant to index types
It is commonly used.
2024-04-03 19:06:22 +03:00
Matthias Krüger
658c8f7367
Rollup merge of #123412 - Kobzol:ci-artifacts-in-summary, r=Mark-Simulacrum
Output URLs of CI artifacts to GitHub summary

I often want to download CI artifacts published from our workflows (I suspect others might do the same), but it's a bit annoying to extract their links from the CI logs currently. This PR also outputs URLs to them to the GitHub Actions summaries.

r? `@Mark-Simulacrum`
2024-04-03 17:15:50 +02:00
Matthias Krüger
deb48aa0f5
Rollup merge of #123394 - compiler-errors:postfix-match-fixes, r=estebank
Postfix match fixes

1. Don't ice on `expr as Ty.match {}`
2. Fix the suggestion span for non-exhaustive matches to add `_ => todo!(),`

Fixes #123383
2024-04-03 17:15:50 +02:00
Matthias Krüger
0c11f13a57
Rollup merge of #123393 - aDotInTheVoid:ast-p-docs, r=Nilstrieb
rustc_ast: Update `P<T>` docs to reflect mutable status.

`P<T>` has implemented `DerefMut` since #54277. While this was lamented at the time [1], rustc now relies on it extensively via the many implementors of MutVisitor [2].

Updates the docs to reflect that `P<T>` is fundamentally mutable, and a few other cleanups to make them nicer to browse.

[1]: https://github.com/rust-lang/rust/pull/54277#discussion_r257181754
[2]: https://doc.rust-lang.org/1.77.1/nightly-rustc/rustc_ast/mut_visit/trait.MutVisitor.html#implementors

r? `@Nilstrieb`
2024-04-03 17:15:49 +02:00
Matthias Krüger
29c72ce183
Rollup merge of #123386 - Rajveer100:branch-for-issue-123227, r=onur-ozkan
Set `CARGO` instead of `PATH` for Rust Clippy

Resolves #123227

Previously, clippy was using `cargo` from `PATH`, but since [PR](https://github.com/rust-lang/rust-clippy/pull/11944), it now prioritises checking `CARGO` first.
2024-04-03 17:15:49 +02:00
Matthias Krüger
94c402733d
Rollup merge of #123382 - compiler-errors:assert-fndef-kind, r=fmease
Assert `FnDef` kind

Only found one bug, where we were using the variant def id rather than its ctor def id to make the `FnDef` for a `type_of`

r? fmease
2024-04-03 17:15:48 +02:00
Matthias Krüger
f7c34c03be
Rollup merge of #123342 - RalfJung:noskip, r=onur-ozkan
x.py test: remove no-op --skip flag

None of the test commands seems to do anything with this flag, so we might as well remove it.
2024-04-03 17:15:48 +02:00
Matthias Krüger
1bde86b18b
Rollup merge of #123209 - ObsidianMinor:doc/external-clangrt, r=michaelwoerister
Add section to sanitizer doc for `-Zexternal-clangrt`

After spending a week looking for answers to how to do the very thing this flag lets me do, it felt appropriate to document it where I would've expected it to be.
2024-04-03 17:15:47 +02:00
Vadim Petrochenkov
44b3602478 hir: Drop owner's own item-local id (zero) from parenting tables 2024-04-03 17:33:34 +03:00
joboet
989660c3e6
rename expose_addr to expose_provenance 2024-04-03 16:00:38 +02:00
Jakub Beránek
508530dbc5 Output URLs of CI artifacts to GitHub summary 2024-04-03 15:33:40 +02:00
bors
ceab6128fa Auto merge of #123390 - tgross35:f16-f128-libs-basic-impls-bootstrap, r=jhpratt
Put basic impls for f16 and f128 behind cfg(not(bootstrap))

We will lose `f16` and `f128` in the beta compiler after the revert for <https://github.com/rust-lang/rust/issues/123282> lands. Change what was added in <https://github.com/rust-lang/rust/pull/123085> to be behind `#[cfg(not(bootstrap))]` to account for this.
2024-04-03 12:32:34 +00:00
Rajveer
66dee4a9aa Set CARGO instead of PATH for Rust Clippy
Resolves #123227
2024-04-03 17:17:40 +05:30
bors
99c42d2340 Auto merge of #123322 - matthewjasper:remove-mir-unsafeck, r=lcnr,compiler-errors
Remove MIR unsafe check

Now that THIR unsafeck is enabled by default in stable I think we can remove MIR unsafeck entirely. This PR also removes safety information from MIR.
2024-04-03 10:30:34 +00:00
Matthew Jasper
a277c901d9 Remove MIR unsafe check
This also remove safety information from MIR.
2024-04-03 08:50:12 +00:00
Alona Enraght-Moony
5075931290 rustc_ast: Update P<T> docs to reflect mutable status.
`P<T>` has implemented `DerefMut` since #54277. While this was lamented
at the time [1], rustc now relies on it extensively via the many
implementors of MutVisitor [2].

Updates the docs to reflect that `P<T>` is fundamentally mutable, and a
few other cleanups to make them nicer to browse.

[1]: https://github.com/rust-lang/rust/pull/54277#discussion_r257181754
[2]: https://doc.rust-lang.org/1.77.1/nightly-rustc/rustc_ast/mut_visit/trait.MutVisitor.html#implementors
2024-04-03 08:41:03 +00:00
bors
c7491b9733 Auto merge of #123402 - workingjubilee:rollup-0j5ihn6, r=workingjubilee
Rollup of 4 pull requests

Successful merges:

 - #122411 ( Provide cabi_realloc on wasm32-wasip2 by default )
 - #123349 (Fix capture analysis for by-move closure bodies)
 - #123359 (Link against libc++abi and libunwind as well when building LLVM wrappers on AIX)
 - #123388 (use a consistent style for links)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-04-03 08:28:48 +00:00
Jubilee
0c0d88864a
Rollup merge of #123388 - tshepang:consistency, r=jhpratt
use a consistent style for links
2024-04-02 23:44:29 -07:00
Jubilee
04a7a559fc
Rollup merge of #123359 - bzEq:aix-libc++abi, r=cuviper
Link against libc++abi and libunwind as well when building LLVM wrappers on AIX

Unlike `libc++.so` on Linux which is a linker script
```ld
INPUT(libc++.so.1 -lc++abi -lunwind)
```
AIX linker doesn't support such script, so `c++abi` and `unwind` have to be specified explicitly.
2024-04-02 23:44:29 -07:00
Jubilee
f700fb24f3
Rollup merge of #123349 - compiler-errors:async-closure-captures, r=oli-obk
Fix capture analysis for by-move closure bodies

The check we were doing to figure out if a coroutine was borrowing from its parent coroutine-closure was flat-out wrong -- a misunderstanding of mine of the way that `tcx.closure_captures` represents its captures.

Fixes #123251 (the miri/ui test I added should more than cover that issue)

r? `@oli-obk` -- I recognize that this PR may be underdocumented, so please ask me what I should explain further.
2024-04-02 23:44:29 -07:00
Jubilee
abb0393595
Rollup merge of #122411 - alexcrichton:wasm32-wasip2-cabi-realloc, r=m-ou-se
Provide cabi_realloc on wasm32-wasip2 by default

This commit provides a component model intrinsic in the standard library
by default on the `wasm32-wasip2` target. This intrinsic is not
required by the component model itself but is quite common to use, for
example it's needed if a wasm module receives a string or a list.

The intention of this commit is to provide an overridable definition in
the standard library through a weak definition of this function. That
means that downstream crates can provide their own customized and more
specific versions if they'd like, but the standard library's version
should suffice for general-purpose use.
2024-04-02 23:44:28 -07:00
bors
76cf07d5df Auto merge of #122225 - DianQK:nits-120268, r=cjgillot
Rename `UninhabitedEnumBranching` to `UnreachableEnumBranching`

Per [#120268](https://github.com/rust-lang/rust/pull/120268#discussion_r1517492060), I rename `UninhabitedEnumBranching` to `UnreachableEnumBranching` .

I solved some nits to add some comments.

I adjusted the workaround restrictions. This should be useful for `a <= b` and `if let Some/Ok(v)`. For enum with few variants, `early-tailduplication` should not cause compile time overhead.

r? RalfJung
2024-04-03 06:22:23 +00:00
bors
8938f887d3 Auto merge of #123398 - weihanglo:update-cargo, r=weihanglo
Update cargo

8 commits in a59aba136aab5510c16b0750a36cbd9916f91796..0637083df5bbdcc951845f0d2eff6999cdb6d30a
2024-03-28 21:21:41 +0000 to 2024-04-02 23:55:05 +0000
- chore(deps): update compatible (rust-lang/cargo#13674)
- Maintain sorting of dependency features (rust-lang/cargo#13682)
- Update `der` crate (rust-lang/cargo#13692)
- fix: bash completion fallback in `nounset` mode (rust-lang/cargo#13686)
- CI: Update macos images to macos-13 (rust-lang/cargo#13685)
- chore(deps): update rust crate opener to 0.7.0 (rust-lang/cargo#13679)
- Remove useless parameters (rust-lang/cargo#13678)
- chore(deps): update rust crate supports-unicode to v3 (rust-lang/cargo#13680)

r? ghost
2024-04-03 04:14:41 +00:00
bors
b688d53a17 Auto merge of #123396 - jhpratt:rollup-oa54mh1, r=jhpratt
Rollup of 5 pull requests

Successful merges:

 - #122865 (Split hir ty lowerer's error reporting code in check functions to mod errors.)
 - #122935 (rename ptr::from_exposed_addr -> ptr::with_exposed_provenance)
 - #123182 (Avoid expanding to unstable internal method)
 - #123203 (Add `Context::ext`)
 - #123380 (Improve bootstrap comments)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-04-03 02:13:07 +00:00
Weihang Lo
c6348a9768
Update cargo 2024-04-02 21:38:06 -04:00
Aaron Loyd
382459e047 Add section to sanitizer doc for -Zexternal-clangrt
After spending a week looking for answers to how to do the very thing
this flag lets me do, it felt appropriate to document it where I would've
expected it to be.
2024-04-02 19:51:20 -05:00
Jacob Pratt
f756095571
Rollup merge of #123380 - Nilstrieb:bomments, r=clubby789
Improve bootstrap comments

Rewrote a comment I found hard to understand, added some more.
2024-04-02 20:37:41 -04:00
Jacob Pratt
9c1c0bfcb2
Rollup merge of #123203 - jkarneges:context-ext, r=Amanieu
Add `Context::ext`

This change enables `Context` to carry arbitrary extension data via a single `&mut dyn Any` field.

```rust
#![feature(context_ext)]

impl Context {
    fn ext(&mut self) -> &mut dyn Any;
}

impl ContextBuilder {
    fn ext(self, data: &'a mut dyn Any) -> Self;

    fn from(cx: &'a mut Context<'_>) -> Self;
    fn waker(self, waker: &'a Waker) -> Self;
}
```

Basic usage:

```rust
struct MyExtensionData {
    executor_name: String,
}

let mut ext = MyExtensionData {
    executor_name: "foo".to_string(),
};

let mut cx = ContextBuilder::from_waker(&waker).ext(&mut ext).build();

if let Some(ext) = cx.ext().downcast_mut::<MyExtensionData>() {
    println!("{}", ext.executor_name);
}
```

Currently, `Context` only carries a `Waker`, but there is interest in having it carry other kinds of data. Examples include [LocalWaker](https://github.com/rust-lang/rust/issues/118959), [a reactor interface](https://github.com/rust-lang/libs-team/issues/347), and [multiple arbitrary values by type](https://docs.rs/context-rs/latest/context_rs/). There is also a general practice in the ecosystem of sharing data between executors and futures via thread-locals or globals that would arguably be better shared via `Context`, if it were possible.

The `ext` field would provide a low friction (to stabilization) solution to enable experimentation. It would enable experimenting with what kinds of data we want to carry as well as with what data structures we may want to use to carry such data.

Dedicated fields for specific kinds of data could still be added directly on `Context` when we have sufficient experience or understanding about the problem they are solving, such as with `LocalWaker`. The `ext` field would be for data for which we don't have such experience or understanding, and that could be graduated to dedicated fields once proven.

Both the provider and consumer of the extension data must be aware of the concrete type behind the `Any`. This means it is not possible for the field to carry an abstract interface. However, the field can carry a concrete type which in turn carries an interface. There are different ways one can imagine an interface-carrying concrete type to work, hence the benefit of being able to experiment with such data structures.

## Passing interfaces

Interfaces can be placed in a concrete type, such as a struct, and then that type can be casted to `Any`. However, one gotcha is `Any` cannot contain non-static references. This means one cannot simply do:

```rust
struct Extensions<'a> {
    interface1: &'a mut dyn Trait1,
    interface2: &'a mut dyn Trait2,
}

let mut ext = Extensions {
    interface1: &mut impl1,
    interface2: &mut impl2,
};

let ext: &mut dyn Any = &mut ext;
```

To work around this without boxing, unsafe code can be used to create a safe projection using accessors. For example:

```rust
pub struct Extensions {
    interface1: *mut dyn Trait1,
    interface2: *mut dyn Trait2,
}

impl Extensions {
    pub fn new<'a>(
        interface1: &'a mut (dyn Trait1 + 'static),
        interface2: &'a mut (dyn Trait2 + 'static),
        scratch: &'a mut MaybeUninit<Self>,
    ) -> &'a mut Self {
        scratch.write(Self {
            interface1,
            interface2,
        })
    }

    pub fn interface1(&mut self) -> &mut dyn Trait1 {
        unsafe { self.interface1.as_mut().unwrap() }
    }

    pub fn interface2(&mut self) -> &mut dyn Trait2 {
        unsafe { self.interface2.as_mut().unwrap() }
    }
}

let mut scratch = MaybeUninit::uninit();
let ext: &mut Extensions = Extensions::new(&mut impl1, &mut impl2, &mut scratch);

// ext can now be casted to `&mut dyn Any` and back, and used safely
let ext: &mut dyn Any = ext;
```

## Context inheritance

Sometimes when futures poll other futures they want to provide their own `Waker` which requires creating their own `Context`. Unfortunately, polling sub-futures with a fresh `Context` means any properties on the original `Context` won't get propagated along to the sub-futures. To help with this, some additional methods are added to `ContextBuilder`.

Here's how to derive a new `Context` from another, overriding only the `Waker`:

```rust
let mut cx = ContextBuilder::from(parent_cx).waker(&new_waker).build();
```
2024-04-02 20:37:40 -04:00
Jacob Pratt
e41d7e7aaf
Rollup merge of #123182 - jhpratt:fix-decodable-derive, r=davidtwco
Avoid expanding to unstable internal method

Fixes #123156

Rather than expanding to `std::rt::begin_panic`, the expansion is now to `unreachable!()`. The resulting behavior is identical. A test that previously triggered the same error as #123156 has been added to ensure it does not regress.

r? compiler
2024-04-02 20:37:40 -04:00
Jacob Pratt
e9ef8e1efa
Rollup merge of #122935 - RalfJung:with-exposed-provenance, r=Amanieu
rename ptr::from_exposed_addr -> ptr::with_exposed_provenance

As discussed on [Zulip](https://rust-lang.zulipchat.com/#narrow/stream/136281-t-opsem/topic/To.20expose.20or.20not.20to.20expose/near/427757066).

The old name, `from_exposed_addr`, makes little sense as it's not the address that is exposed, it's the provenance. (`ptr.expose_addr()` stays unchanged as we haven't found a better option yet. The intended interpretation is "expose the provenance and return the address".)

The new name nicely matches `ptr::without_provenance`.
2024-04-02 20:37:39 -04:00
Jacob Pratt
0697ee9af5
Rollup merge of #122865 - surechen:refactor_astconv_error_report_20240321, r=lcnr
Split hir ty lowerer's error reporting code in check functions to mod errors.

Move some error report codes to mod `astconv/errors.rs`

r? `@lcnr`
2024-04-02 20:37:39 -04:00
bors
40f743da23 Auto merge of #122791 - compiler-errors:make-coinductive-always, r=lcnr
Make inductive cycles always ambiguous

 This makes inductive cycles always result in ambiguity rather than be treated like a stack-dependent error.

This has some  interactions with specialization, and so breaks a few UI tests that I don't agree should've ever worked in the first place, and also breaks a handful of crates in a way that I don't believe is a problem.

On the bright side, it puts us in a better spot when it comes to eventually enabling coinduction everywhere.

## Results

This was cratered in https://github.com/rust-lang/rust/pull/116494#issuecomment-2008657494, which boils down to two regressions:
* `lu_packets` - This code should have never compiled in the first place. More below.
* **ALL** other regressions are due to `commit_verify@0.11.0-beta.1` (edit: and `commit_verify@0.10.x`) - This actually seems to be fixed in version `0.11.0-beta.5`, which is the *most* up to date version, but it's still prerelease on crates.io so I don't think cargo ends up picking `beta.5` when building dependent crates.

### `lu_packets`

Firstly, this crate uses specialization, so I think it's automatically worth breaking. However, I've minimized [the regression](https://crater-reports.s3.amazonaws.com/pr-116494-3/try%23d614ed876e31a5f3ad1d0fbf848fcdab3a29d1d8/gh/lcdr.lu_packets/log.txt) to:

```rust
// Upstream crate
pub trait Serialize {}
impl Serialize for &() {}
impl<S> Serialize for &[S] where for<'a> &'a S: Serialize {}

// ----------------------------------------------------------------------- //

// Downstream crate
#![feature(specialization)]
#![allow(incomplete_features, unused)]

use upstream::Serialize;

trait Replica {
    fn serialize();
}

impl<T> Replica for T {
    default fn serialize() {}
}

impl<T> Replica for Option<T>
where
    for<'a> &'a T: Serialize,
{
    fn serialize() {}
}
```

Specifically this fails when computing the specialization graph for the `downstream` crate.

The code ends up cycling on `&[?0]: Serialize` when we equate `&?0 = &[?1]` during impl matching, which ends up needing to prove `&[?1]: Serialize`, which since cycles are treated like ambiguity, ends up in a **fatal overflow**. For some reason this requires two crates, squashing them into one crate doesn't work.

Side-note: This code is subtly order dependent. When minimizing, I ended up having the code start failing on `nightly` very easily after removing and reordering impls. This seems to me all the more reason to remove this behavior altogether.

## Side-note: Item Bounds (edit: this was fixed independently in #121123)

Due to the changes in #120584 where we now consider an alias's item bounds *and* all the item bounds of the alias's nested self type aliases, I've had to add e6b64c6194 which is a hack to make sure we're not eagerly normalizing bounds that have nothing to do with the predicate we're trying to solve, and which result in.

This is fixed in a more principled way in #121123.

---

r? lcnr for an initial review
2024-04-03 00:09:44 +00:00
Michael Goulet
ec74a304bb Comments, comments, comments 2024-04-02 20:07:49 -04:00
Michael Goulet
a1a1f41027 Fix capture analysis for by-move closure bodies 2024-04-02 20:07:48 -04:00
Michael Goulet
4cb5643bd4 Fix contains_exterior_struct_lit 2024-04-02 19:40:18 -04:00
Michael Goulet
ab821aed0c Fix precedence of postfix match 2024-04-02 19:40:17 -04:00
Michael Goulet
bed8b70d67 Fix suggestions for match non-exhaustiveness 2024-04-02 19:06:28 -04:00