Open
Description
This code from @jroesch fails to compile:
pub enum Mut {}
pub enum Imm {}
trait MutType<'v, T> {
type Output;
}
impl<'v, T: 'v> MutType<'v, T> for Mut {
type Output = &'v mut T;
}
impl<'v, T: 'v> MutType<'v, T> for Imm {
type Output = &'v T;
}
enum Lit {
Int(i32)
}
enum Expr {
Add(Box<Expr>, Box<Expr>),
Lit(Lit),
}
pub trait Visitor<'v, M> : Sized {
fn visit_expr(&mut self, expr: M::Output)
where M : MutType<'v, Expr>;
fn visit_lit(&mut self, lit: M::Output)
where M : MutType<'v, Lit>;
}
struct DummyV;
impl<'v> Visitor<'v, Imm> for DummyV {
fn visit_expr(&mut self, expr: &'v Expr) {
panic!()
}
fn visit_lit(&mut self, lit: &'v Lit) {
panic!()
}
}
fn main() {}
with the following error:
<anon>:38:5: 40:6 error: method `visit_expr` has an incompatible type for trait:
expected associated type,
found &-ptr [E0053]
<anon>:38 fn visit_expr(&mut self, expr: &'v Expr) {
<anon>:39 panic!()
<anon>:40 }
<anon>:38:5: 40:6 help: see the detailed explanation for E0053
<anon>:42:5: 44:6 error: method `visit_lit` has an incompatible type for trait:
expected associated type,
found &-ptr [E0053]
<anon>:42 fn visit_lit(&mut self, lit: &'v Lit) {
<anon>:43 panic!()
<anon>:44 }
<anon>:42:5: 44:6 help: see the detailed explanation for E0053
error: aborting due to 2 previous errors
playpen: application terminated with error code 101
Compilation failed.
but, I think, ought to work. Looks like a problem where we normalize without having all the where clauses from the method available. Lazy normalization would probably fix it.