I don't think this was previously submitted as an issue, though it was mentioned on the Rust Internals forum.
trait Lf<'a> { type Type; }
struct F32;
impl<'a> Lf<'a> for F32 { type Type = f32; }
struct RefI32;
impl<'a> Lf<'a> for RefI32 { type Type = &'a i32; }
fn add_closure<T: for<'b> Lf<'b> + 'static>(v: &mut Vec<Box<for<'a> FnMut(<T as Lf<'a>>::Type)>>) {
v.push(Box::new(move |_| {
}));
}
fn main() {
// bug? compiler can't seem to deduce <F32 as Lf<'a>>::Type == f32 nor <RefI32 as Lf<'a>>::Type == &'a i32
let mut v1 = Vec::<Box<for<'a> FnMut(<F32 as Lf<'a>>::Type)>>::new();
let mut v2 = Vec::<Box<for<'a> FnMut(<RefI32 as Lf<'a>>::Type)>>::new();
add_closure::<F32>(&mut v1);
add_closure::<RefI32>(&mut v2);
}
This crashes both on stable and latest nightly.
error: internal compiler error: src/librustc/traits/codegen/mod.rs:55: Encountered error `OutputTypeParameterMismatch(Binder(<[closure@src/main.rs:10:21: 11:6] as std::ops::FnMut<(<F32 as Lf<'_>>::Type,)>>), Binder(<[closure@src/main.rs:10:21: 11:6] as std::ops::FnMut<(f32,)>>), Sorts(ExpectedFound { expected: f32, found: <F32 as Lf<'_>>::Type }))` selecting `Binder(<[closure@src/main.rs:10:21: 11:6] as std::ops::FnMut<(f32,)>>)` during codegen
thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:646:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
error: aborting due to previous error
Playground
I don't think this was previously submitted as an issue, though it was mentioned on the Rust Internals forum.
This crashes both on stable and latest nightly.
Playground