@@ -338,6 +338,34 @@ pub fn compare_impl_method<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
338
338
} ;
339
339
340
340
let ( impl_err_span, trait_err_span) = match terr {
341
+ TypeError :: Mutability => {
342
+ if let Some ( trait_m_node_id) = tcx. map . as_local_node_id ( trait_m. def_id ) {
343
+ let trait_m_iter = match tcx. map . expect_trait_item ( trait_m_node_id) . node {
344
+ TraitItem_ :: MethodTraitItem ( ref trait_m_sig, _) =>
345
+ trait_m_sig. decl . inputs . iter ( ) ,
346
+ _ => bug ! ( "{:?} is not a MethodTraitItem" , trait_m)
347
+ } ;
348
+
349
+ impl_m_iter. zip ( trait_m_iter) . find ( |& ( ref impl_arg, ref trait_arg) | {
350
+ match ( & impl_arg. ty . node , & trait_arg. ty . node ) {
351
+ ( & Ty_ :: TyRptr ( _, ref impl_mt) , & Ty_ :: TyRptr ( _, ref trait_mt) ) |
352
+ ( & Ty_ :: TyPtr ( ref impl_mt) , & Ty_ :: TyPtr ( ref trait_mt) ) =>
353
+ impl_mt. mutbl != trait_mt. mutbl ,
354
+ _ => false
355
+ }
356
+ } ) . map ( |( ref impl_arg, ref trait_arg) | {
357
+ match ( impl_arg. to_self ( ) , trait_arg. to_self ( ) ) {
358
+ ( Some ( impl_self) , Some ( trait_self) ) =>
359
+ ( impl_self. span , Some ( trait_self. span ) ) ,
360
+ ( None , None ) => ( impl_arg. ty . span , Some ( trait_arg. ty . span ) ) ,
361
+ _ => bug ! ( "impl and trait fns have different first args, \
362
+ impl: {:?}, trait: {:?}", impl_arg, trait_arg)
363
+ }
364
+ } ) . unwrap_or ( ( origin. span ( ) , tcx. map . span_if_local ( trait_m. def_id ) ) )
365
+ } else {
366
+ ( origin. span ( ) , tcx. map . span_if_local ( trait_m. def_id ) )
367
+ }
368
+ }
341
369
TypeError :: Sorts ( ExpectedFound { expected, found } ) => {
342
370
if let Some ( trait_m_node_id) = tcx. map . as_local_node_id ( trait_m. def_id ) {
343
371
let trait_m_iter = match tcx. map . expect_trait_item ( trait_m_node_id) . node {
0 commit comments