@@ -177,6 +177,17 @@ impl<'a> Rewrite for SegmentParam<'a> {
177
177
}
178
178
}
179
179
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
+
180
191
impl Rewrite for ast:: AssocItemConstraint {
181
192
fn rewrite ( & self , context : & RewriteContext < ' _ > , shape : Shape ) -> Option < String > {
182
193
use ast:: AssocItemConstraintKind :: { Bound , Equality } ;
@@ -564,6 +575,9 @@ impl Rewrite for ast::GenericBound {
564
575
. map ( |s| format ! ( "{constness}{asyncness}{polarity}{s}" ) )
565
576
. map ( |s| if has_paren { format ! ( "({})" , s) } else { s } )
566
577
}
578
+ ast:: GenericBound :: Use ( ref args, span) => {
579
+ overflow:: rewrite_with_angle_brackets ( context, "use" , args. iter ( ) , shape, span)
580
+ }
567
581
ast:: GenericBound :: Outlives ( ref lifetime) => lifetime. rewrite ( context, shape) ,
568
582
}
569
583
}
@@ -847,11 +861,7 @@ impl Rewrite for ast::Ty {
847
861
rewrite_macro ( mac, None , context, shape, MacroPosition :: Expression )
848
862
}
849
863
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) => {
855
865
// Empty trait is not a parser error.
856
866
if it. is_empty ( ) {
857
867
return Some ( "impl" . to_owned ( ) ) ;
@@ -935,7 +945,7 @@ fn rewrite_bare_fn(
935
945
fn is_generic_bounds_in_order ( generic_bounds : & [ ast:: GenericBound ] ) -> bool {
936
946
let is_trait = |b : & ast:: GenericBound | match b {
937
947
ast:: GenericBound :: Outlives ( ..) => false ,
938
- ast:: GenericBound :: Trait ( ..) => true ,
948
+ ast:: GenericBound :: Trait ( ..) | ast :: GenericBound :: Use ( .. ) => true ,
939
949
} ;
940
950
let is_lifetime = |b : & ast:: GenericBound | !is_trait ( b) ;
941
951
let last_trait_index = generic_bounds. iter ( ) . rposition ( is_trait) ;
@@ -969,7 +979,8 @@ fn join_bounds_inner(
969
979
let generic_bounds_in_order = is_generic_bounds_in_order ( items) ;
970
980
let is_bound_extendable = |s : & str , b : & ast:: GenericBound | match b {
971
981
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) ,
973
984
} ;
974
985
975
986
// Whether a GenericBound item is a PathSegment segment that includes internal array
@@ -991,6 +1002,7 @@ fn join_bounds_inner(
991
1002
}
992
1003
}
993
1004
}
1005
+ ast:: GenericBound :: Use ( args, _) => args. len ( ) > 1 ,
994
1006
_ => false ,
995
1007
} ;
996
1008
@@ -1114,8 +1126,7 @@ fn join_bounds_inner(
1114
1126
1115
1127
pub ( crate ) fn opaque_ty ( ty : & Option < ptr:: P < ast:: Ty > > ) -> Option < & ast:: GenericBounds > {
1116
1128
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) ,
1119
1130
_ => None ,
1120
1131
} )
1121
1132
}
0 commit comments