@@ -180,35 +180,22 @@ impl<'tcx> Relate<'tcx> for ty::FnSig<'tcx> {
180180 -> RelateResult < ' tcx , ty:: FnSig < ' tcx > >
181181 where R : TypeRelation < ' a , ' gcx , ' tcx > , ' gcx : ' a +' tcx , ' tcx : ' a
182182 {
183- if a. variadic != b. variadic {
183+ if a. variadic ( ) != b. variadic ( ) {
184184 return Err ( TypeError :: VariadicMismatch (
185- expected_found ( relation, & a. variadic , & b. variadic ) ) ) ;
185+ expected_found ( relation, & a. variadic ( ) , & b. variadic ( ) ) ) ) ;
186186 }
187187
188- let inputs = relate_arg_vecs ( relation,
189- & a. inputs ,
190- & b. inputs ) ?;
191- let output = relation. relate ( & a. output , & b. output ) ?;
188+ if a. inputs ( ) . len ( ) != b. inputs ( ) . len ( ) {
189+ return Err ( TypeError :: ArgCount ) ;
190+ }
192191
193- Ok ( ty:: FnSig { inputs : inputs,
194- output : output,
195- variadic : a. variadic } )
196- }
197- }
192+ let inputs = a. inputs ( ) . iter ( ) . zip ( b. inputs ( ) ) . map ( |( & a, & b) | {
193+ relation. relate_with_variance ( ty:: Contravariant , & a, & b)
194+ } ) . collect :: < Result < Vec < _ > , _ > > ( ) ?;
195+ let output = relation. relate ( & a. output ( ) , & b. output ( ) ) ?;
198196
199- fn relate_arg_vecs < ' a , ' gcx , ' tcx , R > ( relation : & mut R ,
200- a_args : & [ Ty < ' tcx > ] ,
201- b_args : & [ Ty < ' tcx > ] )
202- -> RelateResult < ' tcx , Vec < Ty < ' tcx > > >
203- where R : TypeRelation < ' a , ' gcx , ' tcx > , ' gcx : ' a +' tcx , ' tcx : ' a
204- {
205- if a_args. len ( ) != b_args. len ( ) {
206- return Err ( TypeError :: ArgCount ) ;
197+ Ok ( ty:: FnSig :: new ( inputs, output, a. variadic ( ) ) )
207198 }
208-
209- a_args. iter ( ) . zip ( b_args)
210- . map ( |( a, b) | relation. relate_with_variance ( ty:: Contravariant , a, b) )
211- . collect ( )
212199}
213200
214201impl < ' tcx > Relate < ' tcx > for ast:: Unsafety {
0 commit comments