about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMichael Goulet <michael@errs.io>2024-06-16 22:21:47 -0400
committerMichael Goulet <michael@errs.io>2024-06-17 22:35:25 -0400
commitbd83649b1d1e7f29f825e71e2b81e12435b0cabc (patch)
tree324dc3dd999f6ef3ea226264142a2be34e4e4e1a
parent2e03130e112d86c693076ddba3f957542632d7e1 (diff)
downloadrust-bd83649b1d1e7f29f825e71e2b81e12435b0cabc.tar.gz
rust-bd83649b1d1e7f29f825e71e2b81e12435b0cabc.zip
Fix rustfmt
-rw-r--r--src/tools/rustfmt/src/spanned.rs1
-rw-r--r--src/tools/rustfmt/src/types.rs15
2 files changed, 9 insertions, 7 deletions
diff --git a/src/tools/rustfmt/src/spanned.rs b/src/tools/rustfmt/src/spanned.rs
index 4aaf7fdb27f..28911f8af1d 100644
--- a/src/tools/rustfmt/src/spanned.rs
+++ b/src/tools/rustfmt/src/spanned.rs
@@ -181,6 +181,7 @@ impl Spanned for ast::GenericBound {
         match *self {
             ast::GenericBound::Trait(ref ptr, _) => ptr.span,
             ast::GenericBound::Outlives(ref l) => l.ident.span,
+            ast::GenericBound::Use(_, span) => span,
         }
     }
 }
diff --git a/src/tools/rustfmt/src/types.rs b/src/tools/rustfmt/src/types.rs
index 7d14d9e727a..c2c192738c9 100644
--- a/src/tools/rustfmt/src/types.rs
+++ b/src/tools/rustfmt/src/types.rs
@@ -563,6 +563,8 @@ impl Rewrite for ast::GenericBound {
                     .map(|s| if has_paren { format!("({})", s) } else { s })
             }
             ast::GenericBound::Outlives(ref lifetime) => lifetime.rewrite(context, shape),
+            // FIXME(precise_capturing): Should implement formatting before stabilization.
+            ast::GenericBound::Use(..) => None,
         }
     }
 }
@@ -843,11 +845,7 @@ impl Rewrite for ast::Ty {
                 rewrite_macro(mac, None, context, shape, MacroPosition::Expression)
             }
             ast::TyKind::ImplicitSelf => Some(String::from("")),
-            ast::TyKind::ImplTrait(_, ref it, ref captures) => {
-                // FIXME(precise_capturing): Implement formatting.
-                if captures.is_some() {
-                    return None;
-                }
+            ast::TyKind::ImplTrait(_, ref it) => {
                 // Empty trait is not a parser error.
                 if it.is_empty() {
                     return Some("impl".to_owned());
@@ -932,6 +930,8 @@ fn is_generic_bounds_in_order(generic_bounds: &[ast::GenericBound]) -> bool {
     let is_trait = |b: &ast::GenericBound| match b {
         ast::GenericBound::Outlives(..) => false,
         ast::GenericBound::Trait(..) => true,
+        // FIXME(precise_capturing): This ordering fn should be reworked.
+        ast::GenericBound::Use(..) => false,
     };
     let is_lifetime = |b: &ast::GenericBound| !is_trait(b);
     let last_trait_index = generic_bounds.iter().rposition(is_trait);
@@ -966,6 +966,8 @@ fn join_bounds_inner(
     let is_bound_extendable = |s: &str, b: &ast::GenericBound| match b {
         ast::GenericBound::Outlives(..) => true,
         ast::GenericBound::Trait(..) => last_line_extendable(s),
+        // FIXME(precise_capturing): This ordering fn should be reworked.
+        ast::GenericBound::Use(..) => true,
     };
 
     // Whether a GenericBound item is a PathSegment segment that includes internal array
@@ -1110,8 +1112,7 @@ fn join_bounds_inner(
 
 pub(crate) fn opaque_ty(ty: &Option<ptr::P<ast::Ty>>) -> Option<&ast::GenericBounds> {
     ty.as_ref().and_then(|t| match &t.kind {
-        // FIXME(precise_capturing): Implement support here
-        ast::TyKind::ImplTrait(_, bounds, _) => Some(bounds),
+        ast::TyKind::ImplTrait(_, bounds) => Some(bounds),
         _ => None,
     })
 }