@@ -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,9 +575,10 @@ 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
- // FIXME(precise_capturing): Should implement formatting before stabilization.
569
- ast::GenericBound::Use(..) => None,
570
582
}
571
583
}
572
584
}
@@ -933,9 +945,7 @@ fn rewrite_bare_fn(
933
945
fn is_generic_bounds_in_order(generic_bounds: &[ast::GenericBound]) -> bool {
934
946
let is_trait = |b: &ast::GenericBound| match b {
935
947
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,
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,9 +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),
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),
975
984
};
976
985
977
986
// Whether a GenericBound item is a PathSegment segment that includes internal array
@@ -993,6 +1002,7 @@ fn join_bounds_inner(
993
1002
}
994
1003
}
995
1004
}
1005
+ ast::GenericBound::Use(args, _) => args.len() > 1,
996
1006
_ => false,
997
1007
};
998
1008
0 commit comments