@@ -175,6 +175,17 @@ impl<'a> Rewrite for SegmentParam<'a> {
175175 }
176176}
177177
178+ impl Rewrite for ast:: PreciseCapturingArg {
179+ fn rewrite ( & self , context : & RewriteContext < ' _ > , shape : Shape ) -> Option < String > {
180+ match self {
181+ ast:: PreciseCapturingArg :: Lifetime ( lt) => lt. rewrite ( context, shape) ,
182+ ast:: PreciseCapturingArg :: Arg ( p, _) => {
183+ rewrite_path ( context, PathContext :: Type , & None , p, shape)
184+ }
185+ }
186+ }
187+ }
188+
178189impl Rewrite for ast:: AssocItemConstraint {
179190 fn rewrite ( & self , context : & RewriteContext < ' _ > , shape : Shape ) -> Option < String > {
180191 use ast:: AssocItemConstraintKind :: { Bound , Equality } ;
@@ -562,9 +573,10 @@ impl Rewrite for ast::GenericBound {
562573 . map ( |s| format ! ( "{constness}{asyncness}{polarity}{s}" ) )
563574 . map ( |s| if has_paren { format ! ( "({})" , s) } else { s } )
564575 }
576+ ast:: GenericBound :: Use ( ref args, span) => {
577+ overflow:: rewrite_with_angle_brackets ( context, "use" , args. iter ( ) , shape, span)
578+ }
565579 ast:: GenericBound :: Outlives ( ref lifetime) => lifetime. rewrite ( context, shape) ,
566- // FIXME(precise_capturing): Should implement formatting before stabilization.
567- ast:: GenericBound :: Use ( ..) => None ,
568580 }
569581 }
570582}
@@ -929,9 +941,7 @@ fn rewrite_bare_fn(
929941fn is_generic_bounds_in_order ( generic_bounds : & [ ast:: GenericBound ] ) -> bool {
930942 let is_trait = |b : & ast:: GenericBound | match b {
931943 ast:: GenericBound :: Outlives ( ..) => false ,
932- ast:: GenericBound :: Trait ( ..) => true ,
933- // FIXME(precise_capturing): This ordering fn should be reworked.
934- ast:: GenericBound :: Use ( ..) => false ,
944+ ast:: GenericBound :: Trait ( ..) | ast:: GenericBound :: Use ( ..) => true ,
935945 } ;
936946 let is_lifetime = |b : & ast:: GenericBound | !is_trait ( b) ;
937947 let last_trait_index = generic_bounds. iter ( ) . rposition ( is_trait) ;
@@ -965,9 +975,8 @@ fn join_bounds_inner(
965975 let generic_bounds_in_order = is_generic_bounds_in_order ( items) ;
966976 let is_bound_extendable = |s : & str , b : & ast:: GenericBound | match b {
967977 ast:: GenericBound :: Outlives ( ..) => true ,
968- ast:: GenericBound :: Trait ( ..) => last_line_extendable ( s) ,
969- // FIXME(precise_capturing): This ordering fn should be reworked.
970- ast:: GenericBound :: Use ( ..) => true ,
978+ // We treat `use<>` like a trait bound here.
979+ ast:: GenericBound :: Trait ( ..) | ast:: GenericBound :: Use ( ..) => last_line_extendable ( s) ,
971980 } ;
972981
973982 // Whether a GenericBound item is a PathSegment segment that includes internal array
@@ -989,6 +998,7 @@ fn join_bounds_inner(
989998 }
990999 }
9911000 }
1001+ ast:: GenericBound :: Use ( args, _) => args. len ( ) > 1 ,
9921002 _ => false ,
9931003 } ;
9941004
0 commit comments