@@ -324,10 +324,10 @@ pub fn compare_impl_method<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
324324 debug ! ( "sub_types failed: impl ty {:?}, trait ty {:?}" ,
325325 impl_fty,
326326 trait_fty) ;
327- span_err ! ( tcx . sess , impl_m_span , E0053 ,
328- "method `{}` has an incompatible type for trait: {}" ,
329- trait_m . name ,
330- terr ) ;
327+ let trace = infer :: TypeTrace :: types ( origin , false , impl_fty , trait_fty ) ;
328+ type_err ! ( infcx , trace , & terr , E0053 ,
329+ "method `{}` has an incompatible type for trait" ,
330+ trait_m . name ) . emit ( ) ;
331331 return
332332 }
333333
@@ -437,10 +437,9 @@ pub fn compare_const_impl<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
437437 // Compute skolemized form of impl and trait const tys.
438438 let impl_ty = impl_c. ty . subst ( tcx, impl_to_skol_substs) ;
439439 let trait_ty = trait_c. ty . subst ( tcx, & trait_to_skol_substs) ;
440+ let origin = TypeOrigin :: Misc ( impl_c_span) ;
440441
441442 let err = infcx. commit_if_ok ( |_| {
442- let origin = TypeOrigin :: Misc ( impl_c_span) ;
443-
444443 // There is no "body" here, so just pass dummy id.
445444 let impl_ty =
446445 assoc:: normalize_associated_types_in ( & infcx,
@@ -473,11 +472,13 @@ pub fn compare_const_impl<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
473472 debug ! ( "checking associated const for compatibility: impl ty {:?}, trait ty {:?}" ,
474473 impl_ty,
475474 trait_ty) ;
476- span_err ! ( tcx. sess, impl_c_span, E0326 ,
475+ let values = Some ( infer:: ValuePairs :: Types ( ExpectedFound {
476+ expected : trait_ty,
477+ found : impl_ty
478+ } ) ) ;
479+ type_err ! ( infcx, origin, values, terr, E0326 ,
477480 "implemented const `{}` has an incompatible type for \
478- trait: {}",
479- trait_c. name,
480- terr) ;
481+ trait", trait_c. name) . emit ( ) ;
481482 }
482483 } ) ;
483484}
0 commit comments