diff options
| author | Dylan DPC <99973273+Dylan-DPC@users.noreply.github.com> | 2023-05-04 00:17:23 +0530 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-05-04 00:17:23 +0530 |
| commit | 80df4ab403cbdaf0fc7a8301d8490ee60d7063bf (patch) | |
| tree | 9c49bfac0499b037a7b2e35ea6c374962a1e2249 /src/tools/rustfmt | |
| parent | 32f3ddb902e03b7ac23de3e677ff27bc97eff0d6 (diff) | |
| parent | 6fca051b76342f8c21ec85fb9a77103b7c05adb9 (diff) | |
| download | rust-80df4ab403cbdaf0fc7a8301d8490ee60d7063bf.tar.gz rust-80df4ab403cbdaf0fc7a8301d8490ee60d7063bf.zip | |
Rollup merge of #110791 - compiler-errors:negative-bounds, r=oli-obk
Implement negative bounds for internal testing purposes Implements partial support the `!` negative polarity on trait bounds. This is incomplete, but should allow us to at least be able to play with the feature. Not even gonna consider them as a public-facing feature, but I'm implementing them because would've been nice to have in UI tests, for example in #110671.
Diffstat (limited to 'src/tools/rustfmt')
| -rw-r--r-- | src/tools/rustfmt/src/types.rs | 6 | ||||
| -rw-r--r-- | src/tools/rustfmt/tests/target/negative-bounds.rs | 11 |
2 files changed, 17 insertions, 0 deletions
diff --git a/src/tools/rustfmt/src/types.rs b/src/tools/rustfmt/src/types.rs index 01e2fb6e61e..f548388ed8b 100644 --- a/src/tools/rustfmt/src/types.rs +++ b/src/tools/rustfmt/src/types.rs @@ -552,6 +552,12 @@ impl Rewrite for ast::GenericBound { ast::TraitBoundModifier::MaybeConstMaybe => poly_trait_ref .rewrite(context, shape.offset_left(8)?) .map(|s| format!("~const ?{}", s)), + 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/src/tools/rustfmt/tests/target/negative-bounds.rs b/src/tools/rustfmt/tests/target/negative-bounds.rs new file mode 100644 index 00000000000..4fb35cccf66 --- /dev/null +++ b/src/tools/rustfmt/tests/target/negative-bounds.rs @@ -0,0 +1,11 @@ +fn negative() +where + i32: !Copy, +{ +} + +fn maybe_const_negative() +where + i32: ~const !Copy, +{ +} |
