@@ -159,8 +159,8 @@ impl<'tcx> Relate<'tcx> for ty::FnSig<'tcx> {
159
159
if a. c_variadic != b. c_variadic {
160
160
return Err ( TypeError :: VariadicMismatch ( expected_found (
161
161
relation,
162
- & a. c_variadic ,
163
- & b. c_variadic ,
162
+ a. c_variadic ,
163
+ b. c_variadic ,
164
164
) ) ) ;
165
165
}
166
166
let unsafety = relation. relate ( a. unsafety , b. unsafety ) ?;
@@ -200,7 +200,7 @@ impl<'tcx> Relate<'tcx> for ast::Unsafety {
200
200
b : ast:: Unsafety ,
201
201
) -> RelateResult < ' tcx , ast:: Unsafety > {
202
202
if a != b {
203
- Err ( TypeError :: UnsafetyMismatch ( expected_found ( relation, & a, & b) ) )
203
+ Err ( TypeError :: UnsafetyMismatch ( expected_found ( relation, a, b) ) )
204
204
} else {
205
205
Ok ( a)
206
206
}
@@ -213,7 +213,7 @@ impl<'tcx> Relate<'tcx> for abi::Abi {
213
213
a : abi:: Abi ,
214
214
b : abi:: Abi ,
215
215
) -> 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) ) ) }
217
217
}
218
218
}
219
219
@@ -226,8 +226,8 @@ impl<'tcx> Relate<'tcx> for ty::ProjectionTy<'tcx> {
226
226
if a. item_def_id != b. item_def_id {
227
227
Err ( TypeError :: ProjectionMismatched ( expected_found (
228
228
relation,
229
- & a. item_def_id ,
230
- & b. item_def_id ,
229
+ a. item_def_id ,
230
+ b. item_def_id ,
231
231
) ) )
232
232
} else {
233
233
let substs = relation. relate ( a. substs , b. substs ) ?;
@@ -245,8 +245,8 @@ impl<'tcx> Relate<'tcx> for ty::ExistentialProjection<'tcx> {
245
245
if a. item_def_id != b. item_def_id {
246
246
Err ( TypeError :: ProjectionMismatched ( expected_found (
247
247
relation,
248
- & a. item_def_id ,
249
- & b. item_def_id ,
248
+ a. item_def_id ,
249
+ b. item_def_id ,
250
250
) ) )
251
251
} else {
252
252
let ty = relation. relate_with_variance ( ty:: Invariant , a. ty , b. ty ) ?;
@@ -264,7 +264,7 @@ impl<'tcx> Relate<'tcx> for ty::TraitRef<'tcx> {
264
264
) -> RelateResult < ' tcx , ty:: TraitRef < ' tcx > > {
265
265
// Different traits cannot be related.
266
266
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 ) ) )
268
268
} else {
269
269
let substs = relate_substs ( relation, None , a. substs , b. substs ) ?;
270
270
Ok ( ty:: TraitRef { def_id : a. def_id , substs } )
@@ -280,7 +280,7 @@ impl<'tcx> Relate<'tcx> for ty::ExistentialTraitRef<'tcx> {
280
280
) -> RelateResult < ' tcx , ty:: ExistentialTraitRef < ' tcx > > {
281
281
// Different traits cannot be related.
282
282
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 ) ) )
284
284
} else {
285
285
let substs = relate_substs ( relation, None , a. substs , b. substs ) ?;
286
286
Ok ( ty:: ExistentialTraitRef { def_id : a. def_id , substs } )
@@ -305,6 +305,7 @@ impl<'tcx> Relate<'tcx> for GeneratorWitness<'tcx> {
305
305
}
306
306
307
307
impl < ' tcx > Relate < ' tcx > for Ty < ' tcx > {
308
+ #[ inline]
308
309
fn relate < R : TypeRelation < ' tcx > > (
309
310
relation : & mut R ,
310
311
a : Ty < ' tcx > ,
@@ -421,7 +422,7 @@ pub fn super_relate_tys<R: TypeRelation<'tcx>>(
421
422
let sz_b = sz_b. try_eval_usize ( tcx, relation. param_env ( ) ) ;
422
423
match ( sz_a, sz_b) {
423
424
( 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) ,
425
426
) ) ,
426
427
_ => Err ( err) ,
427
428
}
@@ -440,9 +441,9 @@ pub fn super_relate_tys<R: TypeRelation<'tcx>>(
440
441
as_. iter ( ) . zip ( bs) . map ( |( a, b) | relation. relate ( a. expect_ty ( ) , b. expect_ty ( ) ) ) ,
441
442
) ?)
442
443
} 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 ( ) ) ) )
444
445
} else {
445
- Err ( TypeError :: Sorts ( expected_found ( relation, & a, & b) ) )
446
+ Err ( TypeError :: Sorts ( expected_found ( relation, a, b) ) )
446
447
}
447
448
}
448
449
@@ -471,7 +472,7 @@ pub fn super_relate_tys<R: TypeRelation<'tcx>>(
471
472
Ok ( tcx. mk_opaque ( a_def_id, substs) )
472
473
}
473
474
474
- _ => Err ( TypeError :: Sorts ( expected_found ( relation, & a, & b) ) ) ,
475
+ _ => Err ( TypeError :: Sorts ( expected_found ( relation, a, b) ) ) ,
475
476
}
476
477
}
477
478
@@ -521,10 +522,10 @@ pub fn super_relate_consts<R: TypeRelation<'tcx>>(
521
522
if a_instance == b_instance {
522
523
Ok ( ConstValue :: Scalar ( a_val) )
523
524
} else {
524
- Err ( TypeError :: ConstMismatch ( expected_found ( relation, & a, & b) ) )
525
+ Err ( TypeError :: ConstMismatch ( expected_found ( relation, a, b) ) )
525
526
}
526
527
} else {
527
- Err ( TypeError :: ConstMismatch ( expected_found ( relation, & a, & b) ) )
528
+ Err ( TypeError :: ConstMismatch ( expected_found ( relation, a, b) ) )
528
529
}
529
530
}
530
531
@@ -534,7 +535,7 @@ pub fn super_relate_consts<R: TypeRelation<'tcx>>(
534
535
if a_bytes == b_bytes {
535
536
Ok ( a_val)
536
537
} else {
537
- Err ( TypeError :: ConstMismatch ( expected_found ( relation, & a, & b) ) )
538
+ Err ( TypeError :: ConstMismatch ( expected_found ( relation, a, b) ) )
538
539
}
539
540
}
540
541
@@ -554,7 +555,7 @@ pub fn super_relate_consts<R: TypeRelation<'tcx>>(
554
555
555
556
Ok ( a_val)
556
557
} else {
557
- Err ( TypeError :: ConstMismatch ( expected_found ( relation, & a, & b) ) )
558
+ Err ( TypeError :: ConstMismatch ( expected_found ( relation, a, b) ) )
558
559
}
559
560
}
560
561
// FIXME(const_generics): There are probably some `TyKind`s
@@ -564,12 +565,12 @@ pub fn super_relate_consts<R: TypeRelation<'tcx>>(
564
565
DUMMY_SP ,
565
566
& format ! ( "unexpected consts: a: {:?}, b: {:?}" , a, b) ,
566
567
) ;
567
- Err ( TypeError :: ConstMismatch ( expected_found ( relation, & a, & b) ) )
568
+ Err ( TypeError :: ConstMismatch ( expected_found ( relation, a, b) ) )
568
569
}
569
570
}
570
571
}
571
572
572
- _ => Err ( TypeError :: ConstMismatch ( expected_found ( relation, & a, & b) ) ) ,
573
+ _ => Err ( TypeError :: ConstMismatch ( expected_found ( relation, a, b) ) ) ,
573
574
} ;
574
575
575
576
new_val. map ( ty:: ConstKind :: Value )
@@ -584,7 +585,7 @@ pub fn super_relate_consts<R: TypeRelation<'tcx>>(
584
585
relation. relate_with_variance ( ty:: Variance :: Invariant , a_substs, b_substs) ?;
585
586
Ok ( ty:: ConstKind :: Unevaluated ( a_def_id, substs, a_promoted) )
586
587
}
587
- _ => Err ( TypeError :: ConstMismatch ( expected_found ( relation, & a, & b) ) ) ,
588
+ _ => Err ( TypeError :: ConstMismatch ( expected_found ( relation, a, b) ) ) ,
588
589
} ;
589
590
new_const_val. map ( |val| tcx. mk_const ( ty:: Const { val, ty : a. ty } ) )
590
591
}
@@ -607,7 +608,7 @@ impl<'tcx> Relate<'tcx> for &'tcx ty::List<ty::ExistentialPredicate<'tcx>> {
607
608
b_v. sort_by ( |a, b| a. stable_cmp ( tcx, b) ) ;
608
609
b_v. dedup ( ) ;
609
610
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) ) ) ;
611
612
}
612
613
613
614
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>> {
616
617
( Trait ( a) , Trait ( b) ) => Ok ( Trait ( relation. relate ( a, b) ?) ) ,
617
618
( Projection ( a) , Projection ( b) ) => Ok ( Projection ( relation. relate ( a, b) ?) ) ,
618
619
( 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) ) ) ,
620
621
}
621
622
} ) ;
622
623
Ok ( tcx. mk_existential_predicates ( v) ?)
@@ -740,20 +741,14 @@ impl<'tcx> Relate<'tcx> for ty::ProjectionPredicate<'tcx> {
740
741
///////////////////////////////////////////////////////////////////////////
741
742
// Error handling
742
743
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 >
744
745
where
745
746
R : TypeRelation < ' tcx > ,
746
- T : Clone ,
747
747
{
748
748
expected_found_bool ( relation. a_is_expected ( ) , a, b)
749
749
}
750
750
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 > {
757
752
if a_is_expected {
758
753
ExpectedFound { expected : a, found : b }
759
754
} else {
0 commit comments