diff options
| author | Matthias Krüger <476013+matthiaskrgr@users.noreply.github.com> | 2025-04-09 20:23:11 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-04-09 20:23:11 +0200 |
| commit | 584cd13924df508d2d5a6fda4e7333d3e0eeec43 (patch) | |
| tree | 4a98d80a39b0e868c75b4688e61e796c474b8a6b /compiler/rustc_interface/src | |
| parent | 4911635ec3838a14070edabeb28c51a6d634992c (diff) | |
| parent | f6faaee372c1f7fcf2b9ab49310ed07a94620722 (diff) | |
| download | rust-584cd13924df508d2d5a6fda4e7333d3e0eeec43.tar.gz rust-584cd13924df508d2d5a6fda4e7333d3e0eeec43.zip | |
Rollup merge of #139513 - compiler-errors:higher-ranked-proj, r=lcnr
Report higher-ranked trait error when higher-ranked projection goal fails in new solver
~~See HACK comment inline. Not actually sure if it should be marked as a *HACK*, b/c~~ it's kinda a legitimate case we want to care about unless we're going to make the proof tree visitor *smarter* about the leak check than the actual trait solver itself.
Encountered this while battling with `NiceRegionError`s in the old solver b/c I wondered what this code ended up giving us in the *new* solver as a comparison:
```rust
trait Foo {}
impl<T: FnOnce(&())> Foo for T {}
fn baz<T: Foo>() {}
fn main() {
baz::<fn(&'static ())>();
}
```
On master it's pretty bad:
```
error[E0271]: type mismatch resolving `<fn(&()) as FnOnce<(&(),)>>::Output == ()`
--> <source>:8:11
|
8 | baz::<fn(&'static ())>();
| ^^^^^^^^^^^^^^^ types differ
|
note: required for `fn(&'static ())` to implement `Foo`
--> <source>:3:22
|
3 | impl<T: FnOnce(&())> Foo for T {}
| ----------- ^^^ ^
| |
| unsatisfied trait bound introduced here
```
After this PR it's much better:
```
error[E0277]: the trait bound `fn(&'static ()): Foo` is not satisfied
--> /home/mgx/test.rs:8:11
|
8 | baz::<fn(&'static ())>();
| ^^^^^^^^^^^^^^^ the trait `for<'a> FnOnce(&'a ())` is not implemented for `fn(&'static ())`
|
= note: expected a closure with arguments `(&'static (),)`
found a closure with arguments `(&(),)`
note: required for `fn(&'static ())` to implement `Foo`
--> /home/mgx/test.rs:3:22
|
3 | impl<T: FnOnce(&())> Foo for T {}
| ----------- ^^^ ^
| |
| unsatisfied trait bound introduced here
note: required by a bound in `baz`
--> /home/mgx/test.rs:5:11
|
5 | fn baz<T: Foo>() {}
| ^^^ required by this bound in `baz`
```
r? lcnr
Diffstat (limited to 'compiler/rustc_interface/src')
0 files changed, 0 insertions, 0 deletions
