Commit Graph

7 Commits

Author SHA1 Message Date
Matthias Krüger 16a231d8eb Rollup merge of #119071 - lcnr:overflowo, r=compiler-errors
-Znext-solver: adapt overflow rules to avoid breakage

Do not erase overflow constraints if they are from equating the impl header when normalizing[^1].

This should be the minimal change to not break crates depending on the old project behavior of "apply impl constraints while only lazily evaluating any nested goals".

Fixes https://github.com/rust-lang/trait-system-refactor-initiative/issues/70, see https://hackmd.io/ATf4hN0NRY-w2LIVgeFsVg for the reasoning behind this.

Only keeping constraints on overflow for `normalize-to` goals as that's the only thing needed for backcompat. It also allows us to not track the origin of root obligations. The issue with root goals would be something like the following:

```rust
trait Foo {}
trait Bar {}

trait FooBar {}
impl<T: Foo + Bar> FooBar for T {}

// These two should behave the same, rn we can drop constraints for both,
// but if we don't drop `Misc` goals we would only drop the constraints for
// `FooBar` unless we track origins of root obligations.
fn func1<T: Foo + Bar>() {}
fn func2<T: FooBaz>() {}
```

[^1]: mostly, the actual rules are slightly different

r? ``@compiler-errors``
2023-12-20 09:46:11 +01:00
Michael Goulet 132a2884ad Use alias-eq in structural normalization 2023-12-18 19:22:43 +00:00
lcnr 4a38442c90 dont discard overflow from normalizes-to goals 2023-12-18 09:01:54 +01:00
Michael Goulet 5b0b7cd8f9 Move type relations into submodule in rustc_infer 2023-12-15 18:13:40 +00:00
Michael Goulet 146e345d8b Opportunistically resolve region var in canonicalizer 2023-12-15 05:02:37 +00:00
Michael Goulet 929d632b54 Unconditionally register alias-relate in projection goal 2023-12-14 18:41:23 +00:00
lcnr 0947070871 consistently use "next solver" instead of "new solver" 2023-12-14 15:22:37 +01:00