mirror of
https://github.com/gcc-mirror/gcc.git
synced 2026-05-06 14:59:39 +02:00
gccrs: 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>
This commit is contained in:
@@ -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 ())
|
||||
{
|
||||
|
||||
3
gcc/testsuite/rust/compile/issue-2725.rs
Normal file
3
gcc/testsuite/rust/compile/issue-2725.rs
Normal file
@@ -0,0 +1,3 @@
|
||||
#[lang = "sized"]
|
||||
pub trait Sized {}
|
||||
trait Trait: ?Sized {} // { dg-error ".?Trait. is not permitted in supertraits" }
|
||||
Reference in New Issue
Block a user