2222//! constituents)
2323
2424use crate :: infer:: InferCtxt ;
25+ use crate :: traits:: DomainGoal ;
26+ use crate :: ty:: error:: TypeError ;
2527use crate :: ty:: fold:: { TypeFoldable , TypeVisitor } ;
2628use crate :: ty:: relate:: { self , Relate , RelateResult , TypeRelation } ;
2729use crate :: ty:: subst:: Kind ;
2830use crate :: ty:: { self , Ty , TyCtxt } ;
29- use crate :: ty:: error:: TypeError ;
30- use crate :: traits:: DomainGoal ;
3131use rustc_data_structures:: fx:: FxHashMap ;
3232
3333#[ derive( Copy , Clone , PartialEq , Eq , Hash , Debug ) ]
@@ -266,15 +266,17 @@ where
266266 fn relate_projection_ty (
267267 & mut self ,
268268 projection_ty : ty:: ProjectionTy < ' tcx > ,
269- value_ty : ty:: Ty < ' tcx >
269+ value_ty : ty:: Ty < ' tcx > ,
270270 ) -> Ty < ' tcx > {
271271 use crate :: infer:: type_variable:: TypeVariableOrigin ;
272272 use crate :: traits:: WhereClause ;
273273 use syntax_pos:: DUMMY_SP ;
274274
275275 match value_ty. sty {
276276 ty:: Projection ( other_projection_ty) => {
277- let var = self . infcx . next_ty_var ( TypeVariableOrigin :: MiscVariable ( DUMMY_SP ) ) ;
277+ let var = self
278+ . infcx
279+ . next_ty_var ( TypeVariableOrigin :: MiscVariable ( DUMMY_SP ) ) ;
278280 self . relate_projection_ty ( projection_ty, var) ;
279281 self . relate_projection_ty ( other_projection_ty, var) ;
280282 var
@@ -285,9 +287,8 @@ where
285287 projection_ty,
286288 ty : value_ty,
287289 } ;
288- self . delegate . push_domain_goal (
289- DomainGoal :: Holds ( WhereClause :: ProjectionEq ( projection) )
290- ) ;
290+ self . delegate
291+ . push_domain_goal ( DomainGoal :: Holds ( WhereClause :: ProjectionEq ( projection) ) ) ;
291292 value_ty
292293 }
293294 }
@@ -297,20 +298,21 @@ where
297298 fn relate_ty_var (
298299 & mut self ,
299300 vid : ty:: TyVid ,
300- value_ty : Ty < ' tcx >
301+ value_ty : Ty < ' tcx > ,
301302 ) -> RelateResult < ' tcx , Ty < ' tcx > > {
302303 debug ! ( "relate_ty_var(vid={:?}, value_ty={:?})" , vid, value_ty) ;
303304
304305 match value_ty. sty {
305306 ty:: Infer ( ty:: TyVar ( value_vid) ) => {
306307 // Two type variables: just equate them.
307- self . infcx . type_variables . borrow_mut ( ) . equate ( vid, value_vid) ;
308+ self . infcx
309+ . type_variables
310+ . borrow_mut ( )
311+ . equate ( vid, value_vid) ;
308312 return Ok ( value_ty) ;
309313 }
310314
311- ty:: Projection ( projection_ty)
312- if D :: normalization ( ) == NormalizationStrategy :: Lazy =>
313- {
315+ ty:: Projection ( projection_ty) if D :: normalization ( ) == NormalizationStrategy :: Lazy => {
314316 return Ok ( self . relate_projection_ty ( projection_ty, self . infcx . tcx . mk_ty_var ( vid) ) ) ;
315317 }
316318
@@ -327,7 +329,10 @@ where
327329 assert ! ( !generalized_ty. has_infer_types( ) ) ;
328330 }
329331
330- self . infcx . type_variables . borrow_mut ( ) . instantiate ( vid, generalized_ty) ;
332+ self . infcx
333+ . type_variables
334+ . borrow_mut ( )
335+ . instantiate ( vid, generalized_ty) ;
331336
332337 // The generalized values we extract from `canonical_var_values` have
333338 // been fully instantiated and hence the set of scopes we have
@@ -348,7 +353,7 @@ where
348353 fn generalize_value < T : Relate < ' tcx > > (
349354 & mut self ,
350355 value : T ,
351- for_vid : ty:: TyVid
356+ for_vid : ty:: TyVid ,
352357 ) -> RelateResult < ' tcx , T > {
353358 let universe = self . infcx . probe_ty_var ( for_vid) . unwrap_err ( ) ;
354359
@@ -764,7 +769,9 @@ where
764769 drop ( variables) ;
765770 self . relate ( & u, & u)
766771 }
767- TypeVariableValue :: Unknown { universe : _universe } => {
772+ TypeVariableValue :: Unknown {
773+ universe : _universe,
774+ } => {
768775 if self . ambient_variance == ty:: Bivariant {
769776 // FIXME: we may need a WF predicate (related to #54105).
770777 }
@@ -779,17 +786,15 @@ where
779786 let u = self . tcx ( ) . mk_ty_var ( new_var_id) ;
780787 debug ! (
781788 "generalize: replacing original vid={:?} with new={:?}" ,
782- vid,
783- u
789+ vid, u
784790 ) ;
785791 return Ok ( u) ;
786792 }
787793 }
788794 }
789795 }
790796
791- ty:: Infer ( ty:: IntVar ( _) ) |
792- ty:: Infer ( ty:: FloatVar ( _) ) => {
797+ ty:: Infer ( ty:: IntVar ( _) ) | ty:: Infer ( ty:: FloatVar ( _) ) => {
793798 // No matter what mode we are in,
794799 // integer/floating-point types must be equal to be
795800 // relatable.
@@ -800,19 +805,16 @@ where
800805 if self . universe . cannot_name ( placeholder. universe ) {
801806 debug ! (
802807 "TypeGeneralizer::tys: root universe {:?} cannot name\
803- placeholder in universe {:?}",
804- self . universe,
805- placeholder. universe
808+ placeholder in universe {:?}",
809+ self . universe, placeholder. universe
806810 ) ;
807811 Err ( TypeError :: Mismatch )
808812 } else {
809813 Ok ( a)
810814 }
811815 }
812816
813- _ => {
814- relate:: super_relate_tys ( self , a, a)
815- }
817+ _ => relate:: super_relate_tys ( self , a, a) ,
816818 }
817819 }
818820
0 commit comments