Files
rust/tests
Jonathan Brouwer 13225fe579 Rollup merge of #160212 - Dnreikronos:traits/rigid_alias_liveness, r=adwinwhite
traits: Fix rigid alias liveness matching

Fixes rust-lang/rust#160206

The ICE happens while borrowck computes liveness for an opaque return type with an associated type bound. In the repro, that bound looks like `<impl Foo<'x> as Foo<'x>>::Out: 'static`. The query passes unnormalized item bounds to `extract_verify_if_eq`, which expects rigid aliases with the next solver, and hits its debug assertion.

Item-bound collection already maps higher-ranked GAT arguments to the GAT's identity parameters. That means this query can compare the bound's self type directly with the identity alias. A bound on a nested projection, like the associated type in the repro, doesn't match the opaque itself and gets skipped. It doesn't tell us that the opaque is `'static`.

For bounds that do match, we keep the outlives region unless it's still bound. For example, `for<'b> Self::Assoc<'b>: 'b` becomes a non higher ranker item bound `Self::Assoc<'param>: 'param`, so that param region still matters for liveness. With `for<'b> Self::Assoc: 'b`, the same associated type has to outlive every choice of `'b`, including `'static`. We handle that case directly.

I think this is a better fit for the query because it uses the work item-bound collection already did. It removes the matcher call from this path and keeps the shared matcher's rigidity checks intact. The separate call for function bounds stays, since it still needs to match against the alias's concrete arguments. There's no extra normalization in liveness.

The original repro covers the case that triggered the assertion: an item bound on a nested projection must be skipped when computing liveness for the opaque itself.
2026-09-17 16:50:47 +02:00
..