rust-lang / rustc_codegen_cranelift

Cranelift based backend for rustc
Apache License 2.0
1.52k stars 94 forks source link

Support bivariant type parameters in assert_assignable #1331

Closed bjorn3 closed 1 year ago

bjorn3 commented 1 year ago

For example

https://github.com/rust-lang/rust/blob/65bd2a6a73d6a74fb1266a1d96b23de8810a5fb2/src/test/ui/mir/important-higher-ranked-regions.rs

// check-pass
// compile-flags: -Zvalidate-mir

// This test checks that bivariant parameters are handled correctly
// in the mir.
#![allow(coherence_leak_check)]
trait Trait {
    type Assoc;
}

struct Foo<T, U>(T)
where
    T: Trait<Assoc = U>;

impl Trait for for<'a> fn(&'a ()) {
    type Assoc = u32;
}
impl Trait for fn(&'static ()) {
    type Assoc = String;
}

fn foo(x: Foo<for<'a> fn(&'a ()), u32>) -> Foo<fn(&'static ()), String> {
    x
}

fn main() {}
bjorn3 commented 1 year ago

Looks like coherence_leak_check is a future compat lint. This may be impossible to happen in the future when the future compat lint gets turned into a hard error.

bjorn3 commented 1 year ago

Given that a future compat lints gets triggered first I'm going to close this. If this is reachable without hitting any future compat lints I will reopen.