diff options
author | dave <dave@dmetwo.org> | 2023-11-15 12:28:27 -0600 |
---|---|---|
committer | P-E-P <32375388+P-E-P@users.noreply.github.com> | 2024-06-17 10:28:46 +0000 |
commit | 89c056bf3738ecbe41ef9545697937c3f4fbbd87 (patch) | |
tree | 4b33cc17c74b53021cdb4ba03e73614c698c4baa /gcc/rust | |
parent | 7fa14d4f64a1339fcecf9c73c8831c6db434a741 (diff) | |
download | gcc-89c056bf3738ecbe41ef9545697937c3f4fbbd87.zip gcc-89c056bf3738ecbe41ef9545697937c3f4fbbd87.tar.gz gcc-89c056bf3738ecbe41ef9545697937c3f4fbbd87.tar.bz2 |
Fix optional trait parsing
gcc/rust/ChangeLog:
* typecheck/rust-hir-type-check-item.cc (TypeCheckItem::visit): Check for ?Trait in visitor
gcc/testsuite/ChangeLog:
* rust/compile/issue-2725.rs: New test.
Signed-off-by: Dave Evans <dave@dmetwo.org>
Diffstat (limited to 'gcc/rust')
-rw-r--r-- | gcc/rust/typecheck/rust-hir-type-check-item.cc | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/gcc/rust/typecheck/rust-hir-type-check-item.cc b/gcc/rust/typecheck/rust-hir-type-check-item.cc index 39eb736c53..669a482 100644 --- a/gcc/rust/typecheck/rust-hir-type-check-item.cc +++ b/gcc/rust/typecheck/rust-hir-type-check-item.cc @@ -609,6 +609,24 @@ TypeCheckItem::visit (HIR::Module &module) void TypeCheckItem::visit (HIR::Trait &trait) { + if (trait.has_type_param_bounds ()) + { + for (auto &tp_bound : trait.get_type_param_bounds ()) + { + if (tp_bound.get ()->get_bound_type () + == HIR::TypeParamBound::BoundType::TRAITBOUND) + { + HIR::TraitBound &tb + = static_cast<HIR::TraitBound &> (*tp_bound.get ()); + if (tb.get_polarity () == BoundPolarity::AntiBound) + { + rust_error_at (tb.get_locus (), + "%<?Trait%> is not permitted in supertraits"); + } + } + } + } + TraitReference *trait_ref = TraitResolver::Resolve (trait); if (trait_ref->is_error ()) { |