Rustfmt support for negative bounds, test

This commit is contained in:
Michael Goulet 2023-04-26 22:37:36 +00:00
parent 8e330f9d5b
commit 8ed5d5de3d
2 changed files with 17 additions and 2 deletions

View File

@ -552,8 +552,12 @@ fn rewrite(&self, context: &RewriteContext<'_>, shape: Shape) -> Option<String>
ast::TraitBoundModifier::MaybeConstMaybe => poly_trait_ref ast::TraitBoundModifier::MaybeConstMaybe => poly_trait_ref
.rewrite(context, shape.offset_left(8)?) .rewrite(context, shape.offset_left(8)?)
.map(|s| format!("~const ?{}", s)), .map(|s| format!("~const ?{}", s)),
rustc_ast::TraitBoundModifier::Negative ast::TraitBoundModifier::Negative => poly_trait_ref
| rustc_ast::TraitBoundModifier::MaybeConstNegative => None, .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 }) rewrite.map(|s| if has_paren { format!("({})", s) } else { s })
} }

View File

@ -0,0 +1,11 @@
fn negative()
where
i32: !Copy,
{
}
fn maybe_const_negative()
where
i32: ~const !Copy,
{
}