rust-lang / trait-system-refactor-initiative

The Rustc Trait System Refactor Initiative
21 stars 0 forks source link

leak check for param-env projection candidates #85

Closed lcnr closed 6 months ago

lcnr commented 7 months ago

in the old solver satisfies_trait_bound compiles while satisfies_projection_bound does not.

trait Trait<'a, 'b> {
    type Assoc;
}

trait TraitBound<'b> {}
impl<'b, T: for<'a> Trait<'a, 'b>> TraitBound<'b> for T {}

trait ProjectionBound<'b> {}
impl<'b, T: for<'a> Trait<'a, 'b, Assoc = usize>> ProjectionBound<'b> for T {}

impl<'a, T> Trait<'a, 'static> for T {
    type Assoc = usize;
}

fn trait_bound<'b, T: TraitBound<'b>>() {}
fn projection_bound<'b, T: ProjectionBound<'b>>() {}

fn satisfies_trait_bound<T: for<'b> Trait<'static, 'b>>() {
    trait_bound::<T>()
}

fn satisfies_projection_bound<T: for<'b> Trait<'static, 'b, Assoc = usize>>() {
    projection_bound::<T>()
}

fn main() {}
lcnr commented 6 months ago

can be closed. The behavior is now the same for the old and the new solver once https://github.com/rust-lang/rust/pull/119820 has been merged