debug!("sub_types failed: impl ty {:?}, trait ty {:?}",
impl_fty,
trait_fty);
- span_err!(tcx.sess, impl_m_span, E0053,
- "method `{}` has an incompatible type for trait: {}",
- trait_m.name,
- terr);
+ let trace = infer::TypeTrace::types(origin, false, impl_fty, trait_fty);
+ type_err!(infcx, trace, &terr, E0053,
+ "method `{}` has an incompatible type for trait",
+ trait_m.name).emit();
return
}
// Compute skolemized form of impl and trait const tys.
let impl_ty = impl_c.ty.subst(tcx, impl_to_skol_substs);
let trait_ty = trait_c.ty.subst(tcx, &trait_to_skol_substs);
+ let origin = TypeOrigin::Misc(impl_c_span);
let err = infcx.commit_if_ok(|_| {
- let origin = TypeOrigin::Misc(impl_c_span);
-
// There is no "body" here, so just pass dummy id.
let impl_ty =
assoc::normalize_associated_types_in(&infcx,
debug!("checking associated const for compatibility: impl ty {:?}, trait ty {:?}",
impl_ty,
trait_ty);
- span_err!(tcx.sess, impl_c_span, E0326,
+ let values = Some(infer::ValuePairs::Types(ExpectedFound {
+ expected: trait_ty,
+ found: impl_ty
+ }));
+ type_err!(infcx, origin, values, terr, E0326,
"implemented const `{}` has an incompatible type for \
- trait: {}",
- trait_c.name,
- terr);
+ trait", trait_c.name).emit();
}
});
}
impl Foo for Baz {
fn bar(&mut self, other: &Foo) {}
- //~^ ERROR method `bar` has an incompatible type for trait: values differ in mutability [E0053]
+ //~^ ERROR method `bar` has an incompatible type for trait
+ //~| expected type `fn(&mut Baz, &mut Foo)`
+ //~| found type `fn(&mut Baz, &Foo)`
}
fn main() {}
type Item = i32;
fn next(&mut self) -> Result<i32, i32> { Ok(7) }
//~^ ERROR method `next` has an incompatible type for trait
- //~| expected enum `std::option::Option`
- //~| found enum `std::result::Result` [E0053]
+ //~| expected enum `std::option::Option`, found enum `std::result::Result`
}
fn main() {}