@@ -175,6 +175,17 @@ impl<'a> Rewrite for SegmentParam<'a> {
175
175
}
176
176
}
177
177
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
+
178
189
impl Rewrite for ast:: AssocItemConstraint {
179
190
fn rewrite ( & self , context : & RewriteContext < ' _ > , shape : Shape ) -> Option < String > {
180
191
use ast:: AssocItemConstraintKind :: { Bound , Equality } ;
@@ -562,9 +573,10 @@ impl Rewrite for ast::GenericBound {
562
573
. map ( |s| format ! ( "{constness}{asyncness}{polarity}{s}" ) )
563
574
. map ( |s| if has_paren { format ! ( "({})" , s) } else { s } )
564
575
}
576
+ ast:: GenericBound :: Use ( ref args, span) => {
577
+ overflow:: rewrite_with_angle_brackets ( context, "use" , args. iter ( ) , shape, span)
578
+ }
565
579
ast:: GenericBound :: Outlives ( ref lifetime) => lifetime. rewrite ( context, shape) ,
566
- // FIXME(precise_capturing): Should implement formatting before stabilization.
567
- ast:: GenericBound :: Use ( ..) => None ,
568
580
}
569
581
}
570
582
}
@@ -929,9 +941,7 @@ fn rewrite_bare_fn(
929
941
fn is_generic_bounds_in_order ( generic_bounds : & [ ast:: GenericBound ] ) -> bool {
930
942
let is_trait = |b : & ast:: GenericBound | match b {
931
943
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 ,
935
945
} ;
936
946
let is_lifetime = |b : & ast:: GenericBound | !is_trait ( b) ;
937
947
let last_trait_index = generic_bounds. iter ( ) . rposition ( is_trait) ;
@@ -965,9 +975,8 @@ fn join_bounds_inner(
965
975
let generic_bounds_in_order = is_generic_bounds_in_order ( items) ;
966
976
let is_bound_extendable = |s : & str , b : & ast:: GenericBound | match b {
967
977
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) ,
971
980
} ;
972
981
973
982
// Whether a GenericBound item is a PathSegment segment that includes internal array
@@ -989,6 +998,7 @@ fn join_bounds_inner(
989
998
}
990
999
}
991
1000
}
1001
+ ast:: GenericBound :: Use ( args, _) => args. len ( ) > 1 ,
992
1002
_ => false ,
993
1003
} ;
994
1004
0 commit comments