diff options
author | Philip Herron <herron.philip@googlemail.com> | 2024-09-20 17:49:36 +0100 |
---|---|---|
committer | CohenArthur <arthur.cohen@embecosm.com> | 2024-09-20 18:32:10 +0000 |
commit | 39eb3a44122ece56c88699b6262869910dd8dbcc (patch) | |
tree | 0a57183ebddf4689d3eca35bf870483934b91ebb /gcc/rust | |
parent | 5d703a35cae07de269119ad0eed3f1f7a4726046 (diff) | |
download | gcc-39eb3a44122ece56c88699b6262869910dd8dbcc.zip gcc-39eb3a44122ece56c88699b6262869910dd8dbcc.tar.gz gcc-39eb3a44122ece56c88699b6262869910dd8dbcc.tar.bz2 |
rust: negative polarity removes restrictions on validation of impl blocks
Negative polarity means we can just ignore if any trait items are not
implemented.
Fxies #3030
gcc/rust/ChangeLog:
* hir/rust-ast-lower-item.cc (ASTLoweringItem::visit): the polarity was reversed
* typecheck/rust-hir-type-check-item.cc: check the polarity
gcc/testsuite/ChangeLog:
* rust/compile/nr2/exclude: nr2 cant handle this
* rust/compile/issue-3030.rs: New test.
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
Diffstat (limited to 'gcc/rust')
-rw-r--r-- | gcc/rust/hir/rust-ast-lower-item.cc | 4 | ||||
-rw-r--r-- | gcc/rust/typecheck/rust-hir-type-check-item.cc | 3 |
2 files changed, 4 insertions, 3 deletions
diff --git a/gcc/rust/hir/rust-ast-lower-item.cc b/gcc/rust/hir/rust-ast-lower-item.cc index f3ad72c..cb07b26 100644 --- a/gcc/rust/hir/rust-ast-lower-item.cc +++ b/gcc/rust/hir/rust-ast-lower-item.cc @@ -690,8 +690,8 @@ ASTLoweringItem::visit (AST::TraitImpl &impl_block) } BoundPolarity polarity = impl_block.is_exclam () - ? BoundPolarity::RegularBound - : BoundPolarity::NegativeBound; + ? BoundPolarity::NegativeBound + : BoundPolarity::RegularBound; HIR::ImplBlock *hir_impl_block = new HIR::ImplBlock ( mapping, std::move (impl_items), std::move (generic_params), std::unique_ptr<HIR::Type> (impl_type), diff --git a/gcc/rust/typecheck/rust-hir-type-check-item.cc b/gcc/rust/typecheck/rust-hir-type-check-item.cc index 669a482..c1e8107 100644 --- a/gcc/rust/typecheck/rust-hir-type-check-item.cc +++ b/gcc/rust/typecheck/rust-hir-type-check-item.cc @@ -734,7 +734,8 @@ TypeCheckItem::validate_trait_impl_block ( bool impl_block_missing_trait_items = !specified_bound.is_error () && trait_reference->size () != trait_item_refs.size (); - if (impl_block_missing_trait_items) + if (impl_block_missing_trait_items + && impl_block.get_polarity () == BoundPolarity::RegularBound) { // filter the missing impl_items std::vector<std::reference_wrapper<const TraitItemReference>> |