From 8ed5d5de3d4e2cf94ddd00cee922d8533d23c1dd Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Wed, 26 Apr 2023 22:37:36 +0000 Subject: [PATCH] Rustfmt support for negative bounds, test --- src/types.rs | 8 ++++++-- tests/target/negative-bounds.rs | 11 +++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 tests/target/negative-bounds.rs diff --git a/src/types.rs b/src/types.rs index 9ebe38cc25f..f548388ed8b 100644 --- a/src/types.rs +++ b/src/types.rs @@ -552,8 +552,12 @@ fn rewrite(&self, context: &RewriteContext<'_>, shape: Shape) -> Option 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 }) } diff --git a/tests/target/negative-bounds.rs b/tests/target/negative-bounds.rs new file mode 100644 index 00000000000..4fb35cccf66 --- /dev/null +++ b/tests/target/negative-bounds.rs @@ -0,0 +1,11 @@ +fn negative() +where + i32: !Copy, +{ +} + +fn maybe_const_negative() +where + i32: ~const !Copy, +{ +}