aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/util
diff options
context:
space:
mode:
authorPhilip Herron <herron.philip@googlemail.com>2023-07-18 12:12:22 +0100
committerArthur Cohen <arthur.cohen@embecosm.com>2024-01-16 18:56:03 +0100
commitc533a11ae05bae53e4421810f7108aac697ded4e (patch)
tree6dbafe851429fa38d0286cd918ae0f1b5faf23f1 /gcc/rust/util
parent2b00b13d309f600fee94cc911a99362e0451cbaa (diff)
downloadgcc-c533a11ae05bae53e4421810f7108aac697ded4e.zip
gcc-c533a11ae05bae53e4421810f7108aac697ded4e.tar.gz
gcc-c533a11ae05bae53e4421810f7108aac697ded4e.tar.bz2
gccrs: Track trait bound polarity properly
Trait bounds can have three forms in Rust the regular trait bound, '!' the negative trait bound to enforice that this trait must not be implmented and '?' the anti trait bound to remove this bound. This patch extends our Polarity enum to include the Anti trait bound and updates the HIR lowering code to track this properly. Addresses #2443 gcc/rust/ChangeLog: * hir/rust-ast-lower-item.cc (ASTLoweringItem::visit): use new BoundPolarity enum * hir/rust-ast-lower-type.cc (ASTLoweringTypeBounds::visit): likewise * hir/rust-hir-dump.cc (BoundPolarityString): new helper (Dump::visit): update hir dump * hir/tree/rust-hir-item.h (class ImplBlock): likewise * hir/tree/rust-hir-type.h (class TraitBound): likewise * hir/tree/rust-hir.cc (TraitBound::as_string): fix as string * util/rust-common.h (enum Polarity): add new anti bound (enum BoundPolarity): likewise * util/rust-hir-map.cc (Mappings::Mappings): update naming Signed-off-by: Philip Herron <herron.philip@googlemail.com>
Diffstat (limited to 'gcc/rust/util')
-rw-r--r--gcc/rust/util/rust-common.h7
-rw-r--r--gcc/rust/util/rust-hir-map.cc2
2 files changed, 5 insertions, 4 deletions
diff --git a/gcc/rust/util/rust-common.h b/gcc/rust/util/rust-common.h
index ed1935d..763771d 100644
--- a/gcc/rust/util/rust-common.h
+++ b/gcc/rust/util/rust-common.h
@@ -37,10 +37,11 @@ enum Unsafety
Normal
};
-enum Polarity
+enum BoundPolarity
{
- Positive,
- Negative
+ RegularBound,
+ NegativeBound,
+ AntiBound,
};
enum AsyncConstStatus
diff --git a/gcc/rust/util/rust-hir-map.cc b/gcc/rust/util/rust-hir-map.cc
index 9df7fe9..c50836c 100644
--- a/gcc/rust/util/rust-hir-map.cc
+++ b/gcc/rust/util/rust-hir-map.cc
@@ -100,7 +100,7 @@ Mappings::Mappings ()
Analysis::NodeMapping node (0, 0, 0, 0);
builtinMarker
= new HIR::ImplBlock (node, {}, {}, nullptr, nullptr, HIR::WhereClause ({}),
- Positive,
+ BoundPolarity::RegularBound,
HIR::Visibility (HIR::Visibility::VisType::PUBLIC),
{}, {}, UNDEF_LOCATION);
}