@@ -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,6 +575,9 @@ 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) ,
568582 }
569583 }
@@ -847,11 +861,7 @@ impl Rewrite for ast::Ty {
847861 rewrite_macro ( mac, None , context, shape, MacroPosition :: Expression )
848862 }
849863 ast:: TyKind :: ImplicitSelf => Some ( String :: from ( "" ) ) ,
850- ast:: TyKind :: ImplTrait ( _, ref it, ref captures) => {
851- // FIXME(precise_capturing): Implement formatting.
852- if captures. is_some ( ) {
853- return None ;
854- }
864+ ast:: TyKind :: ImplTrait ( _, ref it) => {
855865 // Empty trait is not a parser error.
856866 if it. is_empty ( ) {
857867 return Some ( "impl" . to_owned ( ) ) ;
@@ -935,7 +945,7 @@ fn rewrite_bare_fn(
935945fn is_generic_bounds_in_order ( generic_bounds : & [ ast:: GenericBound ] ) -> bool {
936946 let is_trait = |b : & ast:: GenericBound | match b {
937947 ast:: GenericBound :: Outlives ( ..) => false ,
938- ast:: GenericBound :: Trait ( ..) => true ,
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,7 +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) ,
982+ // We treat `use<>` like a trait bound here.
983+ ast:: GenericBound :: Trait ( ..) | ast:: GenericBound :: Use ( ..) => last_line_extendable ( s) ,
973984 } ;
974985
975986 // Whether a GenericBound item is a PathSegment segment that includes internal array
@@ -991,6 +1002,7 @@ fn join_bounds_inner(
9911002 }
9921003 }
9931004 }
1005+ ast:: GenericBound :: Use ( args, _) => args. len ( ) > 1 ,
9941006 _ => false ,
9951007 } ;
9961008
@@ -1114,8 +1126,7 @@ fn join_bounds_inner(
11141126
11151127pub ( crate ) fn opaque_ty ( ty : & Option < ptr:: P < ast:: Ty > > ) -> Option < & ast:: GenericBounds > {
11161128 ty. as_ref ( ) . and_then ( |t| match & t. kind {
1117- // FIXME(precise_capturing): Implement support here
1118- ast:: TyKind :: ImplTrait ( _, bounds, _) => Some ( bounds) ,
1129+ ast:: TyKind :: ImplTrait ( _, bounds) => Some ( bounds) ,
11191130 _ => None ,
11201131 } )
11211132}
0 commit comments