rust/compiler/rustc_trait_selection/src
bors d163e5e515 Auto merge of #123737 - compiler-errors:alias-wf, r=lcnr
Check alias args for WF even if they have escaping bound vars

#### What

This PR stops skipping arguments of aliases if they have escaping bound vars, instead recursing into them and only discarding the resulting obligations referencing bounds vars.

#### An example:

From the test:
```
trait Trait {
    type Gat<U: ?Sized>;
}

fn test<T>(f: for<'a> fn(<&'a T as Trait>::Gat<&'a [str]>)) where for<'a> &'a T: Trait {}
//~^ ERROR the size for values of type `[()]` cannot be known at compilation time

fn main() {}
```

We now prove that `str: Sized` in order for `&'a [str]` to be well-formed. We were previously unconditionally skipping over `&'a [str]` as it referenced a buond variable. We now recurse into it and instead only discard the `[str]: 'a` obligation because of the escaping bound vars.

#### Why?

This is a change that improves consistency about proving well-formedness earlier in the pipeline, which is necessary for future work on where-bounds in binders and correctly handling higher-ranked implied bounds. I don't expect this to fix any unsoundness.

#### What doesn't it fix?

Specifically, this doesn't check projection predicates' components are well-formed, because there are too many regressions: https://github.com/rust-lang/rust/pull/123737#issuecomment-2052198478
2024-07-03 03:48:06 +00:00
..
solve Rename a bunch of things 2024-06-21 12:32:05 -04:00
traits Auto merge of #123737 - compiler-errors:alias-wf, r=lcnr 2024-07-03 03:48:06 +00:00
errors.rs Use a dedicated type instead of a reference for the diagnostic context 2024-06-18 15:42:11 +00:00
infer.rs Add cycle errors to ScrubbedTraitError to remove a couple more calls to new_with_diagnostics 2024-06-03 09:27:52 -04:00
lib.rs Use tidy to sort crate attributes for all compiler crates. 2024-06-12 15:49:10 +10:00
regions.rs Add cycle errors to ScrubbedTraitError to remove a couple more calls to new_with_diagnostics 2024-06-03 09:27:52 -04:00
solve.rs Rename a bunch of things 2024-06-21 12:32:05 -04:00