Files
rust/compiler/rustc_trait_selection
Jonathan Brouwer 12e214aa4f Rollup merge of #163576 - ShoyuVanilla:outlives-fast-path, r=lcnr
Fix `TypeOutlives` fast-path

> Oh, the fast path is scuffed here. So, I feel fairly confident that we can encounter cases where stalled_on is wrong due to region vars without there being a bug, as in, your change is correct and desirable, but this specific test is just a bug in the fast path:
>
> `<MaybeVerify as Service<?infer>>::Future: 'static` should simply not be considered stalled. What's the cost of either entirely removing this trivially_stalled_on fast path or fixing it to bail when encountering non-rigid aliases
>
> This change is correct. Please separately do a PR to fix the type-outlives fastpath 😊

_Originally posted by @lcnr in https://github.com/rust-lang/rust/issues/162782#issuecomment-5920951094_

The first perf-run result is for always returning `Outcome::NoFastPath` on any infer var and the second one is for the current HEAD.

We shouldn't stall the outlives goal if the goal contains a non-rigid alias even though the goal contains a non-region infer. Non-fast path will normalize that non-rigid alias and that make the evaluation progress, and I think in theory the fast path shouldn't make observable difference outside the solver.

I'm not entirely sure on disabling fast path only in the presence of non-rigid opaques instead of disabling it entirely for non-region infer, but..

- It's no-less-correct than the status quo
- It roughly matches the actual non-fast path:
  dba8825fe5/compiler/rustc_next_trait_solver/src/solve/mod.rs (L128-L129)
- The later has some perf impact hard to ignore for `typenum`

I couldn't conjure up any case fixed by this PR other than the one in https://github.com/rust-lang/rust/pull/162782 😅

r? lcnr
2026-10-02 16:08:11 +02:00
..
2026-09-23 14:27:49 +02:00