From c533a11ae05bae53e4421810f7108aac697ded4e Mon Sep 17 00:00:00 2001 From: Philip Herron Date: Tue, 18 Jul 2023 12:12:22 +0100 Subject: 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 --- gcc/rust/util/rust-hir-map.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gcc/rust/util/rust-hir-map.cc') 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); } -- cgit v1.1