@@ -177,6 +177,17 @@ impl<'a> Rewrite for SegmentParam<'a> {
177177 }
178178}
179179
180+ impl Rewrite for ast:: PreciseCapturingArg {
181+ fn rewrite ( & self , context : & RewriteContext < ' _ > , shape : Shape ) -> Option < String > {
182+ match self {
183+ ast:: PreciseCapturingArg :: Lifetime ( lt) => lt. rewrite ( context, shape) ,
184+ ast:: PreciseCapturingArg :: Arg ( p, _) => {
185+ rewrite_path ( context, PathContext :: Type , & None , p, shape)
186+ }
187+ }
188+ }
189+ }
190+
180191impl Rewrite for ast:: AssocItemConstraint {
181192 fn rewrite ( & self , context : & RewriteContext < ' _ > , shape : Shape ) -> Option < String > {
182193 use ast:: AssocItemConstraintKind :: { Bound , Equality } ;
@@ -564,9 +575,10 @@ impl Rewrite for ast::GenericBound {
564575 . map ( |s| format ! ( "{constness}{asyncness}{polarity}{s}" ) )
565576 . map ( |s| if has_paren { format ! ( "({})" , s) } else { s } )
566577 }
578+ ast:: GenericBound :: Use ( ref args, span) => {
579+ overflow:: rewrite_with_angle_brackets ( context, "use" , args. iter ( ) , shape, span)
580+ }
567581 ast:: GenericBound :: Outlives ( ref lifetime) => lifetime. rewrite ( context, shape) ,
568- // FIXME(precise_capturing): Should implement formatting before stabilization.
569- ast:: GenericBound :: Use ( ..) => None ,
570582 }
571583 }
572584}
@@ -933,9 +945,7 @@ fn rewrite_bare_fn(
933945fn is_generic_bounds_in_order ( generic_bounds : & [ ast:: GenericBound ] ) -> bool {
934946 let is_trait = |b : & ast:: GenericBound | match b {
935947 ast:: GenericBound :: Outlives ( ..) => false ,
936- ast:: GenericBound :: Trait ( ..) => true ,
937- // FIXME(precise_capturing): This ordering fn should be reworked.
938- ast:: GenericBound :: Use ( ..) => false ,
948+ ast:: GenericBound :: Trait ( ..) | ast:: GenericBound :: Use ( ..) => true ,
939949 } ;
940950 let is_lifetime = |b : & ast:: GenericBound | !is_trait ( b) ;
941951 let last_trait_index = generic_bounds. iter ( ) . rposition ( is_trait) ;
@@ -969,9 +979,8 @@ fn join_bounds_inner(
969979 let generic_bounds_in_order = is_generic_bounds_in_order ( items) ;
970980 let is_bound_extendable = |s : & str , b : & ast:: GenericBound | match b {
971981 ast:: GenericBound :: Outlives ( ..) => true ,
972- ast:: GenericBound :: Trait ( ..) => last_line_extendable ( s) ,
973- // FIXME(precise_capturing): This ordering fn should be reworked.
974- ast:: GenericBound :: Use ( ..) => true ,
982+ // We treat `use<>` like a trait bound here.
983+ ast:: GenericBound :: Trait ( ..) | ast:: GenericBound :: Use ( ..) => last_line_extendable ( s) ,
975984 } ;
976985
977986 // Whether a GenericBound item is a PathSegment segment that includes internal array
@@ -993,6 +1002,7 @@ fn join_bounds_inner(
9931002 }
9941003 }
9951004 }
1005+ ast:: GenericBound :: Use ( args, _) => args. len ( ) > 1 ,
9961006 _ => false ,
9971007 } ;
9981008
0 commit comments