rust/compiler/rustc_hir_analysis
bors 7e19eef048 Auto merge of #140557 - compiler-errors:remove-wf-hack, r=lcnr
Remove manual WF hack

We do not need this hack anymore since we fixed the candidate selection problems with `Sized` bounds. We prefer built-in sized bounds now since #138176, which fixes the only regression this hack was intended to fix.

While this theoretically is broken for some code, for example, when there a param-env bound that shadows an impl or built-in trait, we don't see it in practice and IMO it's not worth the burden of having to maintain this wart in `compare_method_predicate_entailment`.

The code that regresses is, for example:

```rust
trait Bar<'a> {}

trait Foo<'a, T> {
    fn method(&self)
    where
        Self: Bar<'a>;
}

struct W<'a, T>(&'a T)
where
    Self: Bar<'a>;

impl<'a, 'b, T> Bar<'a> for W<'b, T> {}

impl<'a, 'b, T> Foo<'a, T> for W<'b, T> {
    fn method(&self) {}
}
```

Specifically, I don't believe this is really going to be encountered in practice. For this to fail, there must be a where clause in the *trait method* that would shadow an impl or built-in (non-`Sized`) candidate in the trait, and this shadowing would need to be encountered when solving a nested WF goal from the impl self type.

See #108544 for the original regression. Crater run is clean!

r? lcnr
2025-05-16 02:34:32 +00:00
..
src Auto merge of #140557 - compiler-errors:remove-wf-hack, r=lcnr 2025-05-16 02:34:32 +00:00
Cargo.toml Move inline_asm to typeck, properly handle aliases 2025-04-27 22:05:07 +00:00
messages.ftl Fix typos 2025-05-12 17:20:49 +00:00
README.md

For high-level intro to how type checking works in rustc, see the type checking chapter of the rustc dev guide.