Skip to content

Commit

Permalink
Fix rustfmt
Browse files Browse the repository at this point in the history
  • Loading branch information
compiler-errors committed Jun 6, 2024
1 parent ff8e9a0 commit a289b83
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
1 change: 1 addition & 0 deletions src/tools/rustfmt/src/spanned.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}
}
Expand Down
14 changes: 5 additions & 9 deletions src/tools/rustfmt/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,7 @@ impl Rewrite for ast::GenericBound {
.map(|s| if has_paren { format!("({})", s) } else { s })
}
ast::GenericBound::Outlives(ref lifetime) => lifetime.rewrite(context, shape),
ast::GenericBound::Use(..) => None,
}
}
}
Expand Down Expand Up @@ -843,11 +844,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());
Expand Down Expand Up @@ -930,7 +927,7 @@ fn rewrite_bare_fn(

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::Outlives(..) | ast::GenericBound::Use(..) => false,
ast::GenericBound::Trait(..) => true,
};
let is_lifetime = |b: &ast::GenericBound| !is_trait(b);
Expand Down Expand Up @@ -964,7 +961,7 @@ fn join_bounds_inner(

let generic_bounds_in_order = is_generic_bounds_in_order(items);
let is_bound_extendable = |s: &str, b: &ast::GenericBound| match b {
ast::GenericBound::Outlives(..) => true,
ast::GenericBound::Outlives(..) | ast::GenericBound::Use(..) => true,
ast::GenericBound::Trait(..) => last_line_extendable(s),
};

Expand Down Expand Up @@ -1110,8 +1107,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,
})
}
Expand Down

0 comments on commit a289b83

Please sign in to comment.