Skip to content

higher-ranked goals in trait goal candidate selection #120

Open
@lcnr

Description

@lcnr

This compiles with the old solver but currently fails with next:

trait Leak<'a> {}
impl Leak<'_> for Box<u32> {}
impl Leak<'static> for Box<u16> {}

fn impls_leak<T: for<'a> Leak<'a>>() {}
fn direct() {
    // The `Box<u16>` impls fails the leak check,
    // meaning that we apply the `Box<u32>` impl.
    impls_leak::<Box<_>>();
    //[next]~^ ERROR type annotations needed
}

cc rust-lang/rust#119820 which got reverted in rust-lang/rust#127568

We originally intended to never consider the placeholders from higher ranked goals while computing their candidates. However, this resulted in some undesirable breakage and we'll instead have to support this with the next solver before stabilization.

I currently hope to support this by adding OR region bounds and removing ParamEnv preference by returning guidance instead, discussed in https://hackmd.io/-IMJ8e0iTBqvL6X1XuiRdw#Leak-check

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

Status

in progress

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions