@@ -159,8 +159,8 @@ impl<'tcx> Relate<'tcx> for ty::FnSig<'tcx> {
159159 if a. c_variadic != b. c_variadic {
160160 return Err ( TypeError :: VariadicMismatch ( expected_found (
161161 relation,
162- & a. c_variadic ,
163- & b. c_variadic ,
162+ a. c_variadic ,
163+ b. c_variadic ,
164164 ) ) ) ;
165165 }
166166 let unsafety = relation. relate ( a. unsafety , b. unsafety ) ?;
@@ -200,7 +200,7 @@ impl<'tcx> Relate<'tcx> for ast::Unsafety {
200200 b : ast:: Unsafety ,
201201 ) -> RelateResult < ' tcx , ast:: Unsafety > {
202202 if a != b {
203- Err ( TypeError :: UnsafetyMismatch ( expected_found ( relation, & a, & b) ) )
203+ Err ( TypeError :: UnsafetyMismatch ( expected_found ( relation, a, b) ) )
204204 } else {
205205 Ok ( a)
206206 }
@@ -213,7 +213,7 @@ impl<'tcx> Relate<'tcx> for abi::Abi {
213213 a : abi:: Abi ,
214214 b : abi:: Abi ,
215215 ) -> RelateResult < ' tcx , abi:: Abi > {
216- if a == b { Ok ( a) } else { Err ( TypeError :: AbiMismatch ( expected_found ( relation, & a, & b) ) ) }
216+ if a == b { Ok ( a) } else { Err ( TypeError :: AbiMismatch ( expected_found ( relation, a, b) ) ) }
217217 }
218218}
219219
@@ -226,8 +226,8 @@ impl<'tcx> Relate<'tcx> for ty::ProjectionTy<'tcx> {
226226 if a. item_def_id != b. item_def_id {
227227 Err ( TypeError :: ProjectionMismatched ( expected_found (
228228 relation,
229- & a. item_def_id ,
230- & b. item_def_id ,
229+ a. item_def_id ,
230+ b. item_def_id ,
231231 ) ) )
232232 } else {
233233 let substs = relation. relate ( a. substs , b. substs ) ?;
@@ -245,8 +245,8 @@ impl<'tcx> Relate<'tcx> for ty::ExistentialProjection<'tcx> {
245245 if a. item_def_id != b. item_def_id {
246246 Err ( TypeError :: ProjectionMismatched ( expected_found (
247247 relation,
248- & a. item_def_id ,
249- & b. item_def_id ,
248+ a. item_def_id ,
249+ b. item_def_id ,
250250 ) ) )
251251 } else {
252252 let ty = relation. relate_with_variance ( ty:: Invariant , a. ty , b. ty ) ?;
@@ -264,7 +264,7 @@ impl<'tcx> Relate<'tcx> for ty::TraitRef<'tcx> {
264264 ) -> RelateResult < ' tcx , ty:: TraitRef < ' tcx > > {
265265 // Different traits cannot be related.
266266 if a. def_id != b. def_id {
267- Err ( TypeError :: Traits ( expected_found ( relation, & a. def_id , & b. def_id ) ) )
267+ Err ( TypeError :: Traits ( expected_found ( relation, a. def_id , b. def_id ) ) )
268268 } else {
269269 let substs = relate_substs ( relation, None , a. substs , b. substs ) ?;
270270 Ok ( ty:: TraitRef { def_id : a. def_id , substs } )
@@ -280,7 +280,7 @@ impl<'tcx> Relate<'tcx> for ty::ExistentialTraitRef<'tcx> {
280280 ) -> RelateResult < ' tcx , ty:: ExistentialTraitRef < ' tcx > > {
281281 // Different traits cannot be related.
282282 if a. def_id != b. def_id {
283- Err ( TypeError :: Traits ( expected_found ( relation, & a. def_id , & b. def_id ) ) )
283+ Err ( TypeError :: Traits ( expected_found ( relation, a. def_id , b. def_id ) ) )
284284 } else {
285285 let substs = relate_substs ( relation, None , a. substs , b. substs ) ?;
286286 Ok ( ty:: ExistentialTraitRef { def_id : a. def_id , substs } )
@@ -305,6 +305,7 @@ impl<'tcx> Relate<'tcx> for GeneratorWitness<'tcx> {
305305}
306306
307307impl < ' tcx > Relate < ' tcx > for Ty < ' tcx > {
308+ #[ inline]
308309 fn relate < R : TypeRelation < ' tcx > > (
309310 relation : & mut R ,
310311 a : Ty < ' tcx > ,
@@ -421,7 +422,7 @@ pub fn super_relate_tys<R: TypeRelation<'tcx>>(
421422 let sz_b = sz_b. try_eval_usize ( tcx, relation. param_env ( ) ) ;
422423 match ( sz_a, sz_b) {
423424 ( Some ( sz_a_val) , Some ( sz_b_val) ) => Err ( TypeError :: FixedArraySize (
424- expected_found ( relation, & sz_a_val, & sz_b_val) ,
425+ expected_found ( relation, sz_a_val, sz_b_val) ,
425426 ) ) ,
426427 _ => Err ( err) ,
427428 }
@@ -440,9 +441,9 @@ pub fn super_relate_tys<R: TypeRelation<'tcx>>(
440441 as_. iter ( ) . zip ( bs) . map ( |( a, b) | relation. relate ( a. expect_ty ( ) , b. expect_ty ( ) ) ) ,
441442 ) ?)
442443 } else if !( as_. is_empty ( ) || bs. is_empty ( ) ) {
443- Err ( TypeError :: TupleSize ( expected_found ( relation, & as_. len ( ) , & bs. len ( ) ) ) )
444+ Err ( TypeError :: TupleSize ( expected_found ( relation, as_. len ( ) , bs. len ( ) ) ) )
444445 } else {
445- Err ( TypeError :: Sorts ( expected_found ( relation, & a, & b) ) )
446+ Err ( TypeError :: Sorts ( expected_found ( relation, a, b) ) )
446447 }
447448 }
448449
@@ -471,7 +472,7 @@ pub fn super_relate_tys<R: TypeRelation<'tcx>>(
471472 Ok ( tcx. mk_opaque ( a_def_id, substs) )
472473 }
473474
474- _ => Err ( TypeError :: Sorts ( expected_found ( relation, & a, & b) ) ) ,
475+ _ => Err ( TypeError :: Sorts ( expected_found ( relation, a, b) ) ) ,
475476 }
476477}
477478
@@ -521,10 +522,10 @@ pub fn super_relate_consts<R: TypeRelation<'tcx>>(
521522 if a_instance == b_instance {
522523 Ok ( ConstValue :: Scalar ( a_val) )
523524 } else {
524- Err ( TypeError :: ConstMismatch ( expected_found ( relation, & a, & b) ) )
525+ Err ( TypeError :: ConstMismatch ( expected_found ( relation, a, b) ) )
525526 }
526527 } else {
527- Err ( TypeError :: ConstMismatch ( expected_found ( relation, & a, & b) ) )
528+ Err ( TypeError :: ConstMismatch ( expected_found ( relation, a, b) ) )
528529 }
529530 }
530531
@@ -534,7 +535,7 @@ pub fn super_relate_consts<R: TypeRelation<'tcx>>(
534535 if a_bytes == b_bytes {
535536 Ok ( a_val)
536537 } else {
537- Err ( TypeError :: ConstMismatch ( expected_found ( relation, & a, & b) ) )
538+ Err ( TypeError :: ConstMismatch ( expected_found ( relation, a, b) ) )
538539 }
539540 }
540541
@@ -554,7 +555,7 @@ pub fn super_relate_consts<R: TypeRelation<'tcx>>(
554555
555556 Ok ( a_val)
556557 } else {
557- Err ( TypeError :: ConstMismatch ( expected_found ( relation, & a, & b) ) )
558+ Err ( TypeError :: ConstMismatch ( expected_found ( relation, a, b) ) )
558559 }
559560 }
560561 // FIXME(const_generics): There are probably some `TyKind`s
@@ -564,12 +565,12 @@ pub fn super_relate_consts<R: TypeRelation<'tcx>>(
564565 DUMMY_SP ,
565566 & format ! ( "unexpected consts: a: {:?}, b: {:?}" , a, b) ,
566567 ) ;
567- Err ( TypeError :: ConstMismatch ( expected_found ( relation, & a, & b) ) )
568+ Err ( TypeError :: ConstMismatch ( expected_found ( relation, a, b) ) )
568569 }
569570 }
570571 }
571572
572- _ => Err ( TypeError :: ConstMismatch ( expected_found ( relation, & a, & b) ) ) ,
573+ _ => Err ( TypeError :: ConstMismatch ( expected_found ( relation, a, b) ) ) ,
573574 } ;
574575
575576 new_val. map ( ty:: ConstKind :: Value )
@@ -584,7 +585,7 @@ pub fn super_relate_consts<R: TypeRelation<'tcx>>(
584585 relation. relate_with_variance ( ty:: Variance :: Invariant , a_substs, b_substs) ?;
585586 Ok ( ty:: ConstKind :: Unevaluated ( a_def_id, substs, a_promoted) )
586587 }
587- _ => Err ( TypeError :: ConstMismatch ( expected_found ( relation, & a, & b) ) ) ,
588+ _ => Err ( TypeError :: ConstMismatch ( expected_found ( relation, a, b) ) ) ,
588589 } ;
589590 new_const_val. map ( |val| tcx. mk_const ( ty:: Const { val, ty : a. ty } ) )
590591}
@@ -607,7 +608,7 @@ impl<'tcx> Relate<'tcx> for &'tcx ty::List<ty::ExistentialPredicate<'tcx>> {
607608 b_v. sort_by ( |a, b| a. stable_cmp ( tcx, b) ) ;
608609 b_v. dedup ( ) ;
609610 if a_v. len ( ) != b_v. len ( ) {
610- return Err ( TypeError :: ExistentialMismatch ( expected_found ( relation, & a, & b) ) ) ;
611+ return Err ( TypeError :: ExistentialMismatch ( expected_found ( relation, a, b) ) ) ;
611612 }
612613
613614 let v = a_v. into_iter ( ) . zip ( b_v. into_iter ( ) ) . map ( |( ep_a, ep_b) | {
@@ -616,7 +617,7 @@ impl<'tcx> Relate<'tcx> for &'tcx ty::List<ty::ExistentialPredicate<'tcx>> {
616617 ( Trait ( a) , Trait ( b) ) => Ok ( Trait ( relation. relate ( a, b) ?) ) ,
617618 ( Projection ( a) , Projection ( b) ) => Ok ( Projection ( relation. relate ( a, b) ?) ) ,
618619 ( AutoTrait ( a) , AutoTrait ( b) ) if a == b => Ok ( AutoTrait ( a) ) ,
619- _ => Err ( TypeError :: ExistentialMismatch ( expected_found ( relation, & a, & b) ) ) ,
620+ _ => Err ( TypeError :: ExistentialMismatch ( expected_found ( relation, a, b) ) ) ,
620621 }
621622 } ) ;
622623 Ok ( tcx. mk_existential_predicates ( v) ?)
@@ -740,20 +741,14 @@ impl<'tcx> Relate<'tcx> for ty::ProjectionPredicate<'tcx> {
740741///////////////////////////////////////////////////////////////////////////
741742// Error handling
742743
743- pub fn expected_found < R , T > ( relation : & mut R , a : & T , b : & T ) -> ExpectedFound < T >
744+ pub fn expected_found < R , T > ( relation : & mut R , a : T , b : T ) -> ExpectedFound < T >
744745where
745746 R : TypeRelation < ' tcx > ,
746- T : Clone ,
747747{
748748 expected_found_bool ( relation. a_is_expected ( ) , a, b)
749749}
750750
751- pub fn expected_found_bool < T > ( a_is_expected : bool , a : & T , b : & T ) -> ExpectedFound < T >
752- where
753- T : Clone ,
754- {
755- let a = a. clone ( ) ;
756- let b = b. clone ( ) ;
751+ pub fn expected_found_bool < T > ( a_is_expected : bool , a : T , b : T ) -> ExpectedFound < T > {
757752 if a_is_expected {
758753 ExpectedFound { expected : a, found : b }
759754 } else {
0 commit comments