aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc')
-rw-r--r--gcc/rust/typecheck/rust-hir-type-check-item.cc18
-rw-r--r--gcc/testsuite/rust/compile/issue-2725.rs3
2 files changed, 21 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 317d167..68e2069 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 ())
{
diff --git a/gcc/testsuite/rust/compile/issue-2725.rs b/gcc/testsuite/rust/compile/issue-2725.rs
new file mode 100644
index 0000000..a344bc8
--- /dev/null
+++ b/gcc/testsuite/rust/compile/issue-2725.rs
@@ -0,0 +1,3 @@
+#[lang = "sized"]
+pub trait Sized {}
+trait Trait: ?Sized {} // { dg-error ".?Trait. is not permitted in supertraits" }