Skip to content

Commit

Permalink
Rustfmt support for negative bounds, test
Browse files Browse the repository at this point in the history
  • Loading branch information
compiler-errors committed May 2, 2023
1 parent 03469c3 commit 6fca051
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/tools/rustfmt/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -552,8 +552,12 @@ impl Rewrite for ast::GenericBound {
ast::TraitBoundModifier::MaybeConstMaybe => poly_trait_ref
.rewrite(context, shape.offset_left(8)?)
.map(|s| format!("~const ?{}", s)),
rustc_ast::TraitBoundModifier::Negative
| rustc_ast::TraitBoundModifier::MaybeConstNegative => None,
ast::TraitBoundModifier::Negative => poly_trait_ref
.rewrite(context, shape.offset_left(1)?)
.map(|s| format!("!{}", s)),
ast::TraitBoundModifier::MaybeConstNegative => poly_trait_ref
.rewrite(context, shape.offset_left(8)?)
.map(|s| format!("~const !{}", s)),
};
rewrite.map(|s| if has_paren { format!("({})", s) } else { s })
}
Expand Down
11 changes: 11 additions & 0 deletions src/tools/rustfmt/tests/target/negative-bounds.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
fn negative()
where
i32: !Copy,
{
}

fn maybe_const_negative()
where
i32: ~const !Copy,
{
}

0 comments on commit 6fca051

Please sign in to comment.