aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorPhilip Herron <philip.herron@embecosm.com>2021-11-05 10:54:19 +0000
committerPhilip Herron <philip.herron@embecosm.com>2021-11-05 11:12:51 +0000
commitb7520628b49d5516c517b70bb04043dd91dd2a5e (patch)
treea02399639a50bac77239bac77b147c83d7cacebd /gcc
parentd308ce83b9bb543849f474fcee8cad1c73bea6c1 (diff)
downloadgcc-b7520628b49d5516c517b70bb04043dd91dd2a5e.zip
gcc-b7520628b49d5516c517b70bb04043dd91dd2a5e.tar.gz
gcc-b7520628b49d5516c517b70bb04043dd91dd2a5e.tar.bz2
Add missing generic arguments to type-bound-predicate on trait-objects
Diffstat (limited to 'gcc')
-rw-r--r--gcc/rust/typecheck/rust-hir-type-check-type.cc19
1 files changed, 18 insertions, 1 deletions
diff --git a/gcc/rust/typecheck/rust-hir-type-check-type.cc b/gcc/rust/typecheck/rust-hir-type-check-type.cc
index ca7b91b..f1dbb6b 100644
--- a/gcc/rust/typecheck/rust-hir-type-check-type.cc
+++ b/gcc/rust/typecheck/rust-hir-type-check-type.cc
@@ -536,9 +536,26 @@ TypeCheckType::visit (HIR::TraitObjectType &type)
HIR::TypeParamBound &b = *bound.get ();
HIR::TraitBound &trait_bound = static_cast<HIR::TraitBound &> (b);
- TraitReference *trait = resolve_trait_path (trait_bound.get_path ());
+
+ auto &type_path = trait_bound.get_path ();
+ TraitReference *trait = resolve_trait_path (type_path);
TyTy::TypeBoundPredicate predicate (trait->get_mappings ().get_defid (),
trait_bound.get_locus ());
+ auto &final_seg = type_path.get_final_segment ();
+ if (final_seg->is_generic_segment ())
+ {
+ auto final_generic_seg
+ = static_cast<HIR::TypePathSegmentGeneric *> (final_seg.get ());
+ if (final_generic_seg->has_generic_args ())
+ {
+ HIR::GenericArgs &generic_args
+ = final_generic_seg->get_generic_args ();
+
+ // this is applying generic arguments to a trait
+ // reference
+ predicate.apply_generic_arguments (&generic_args);
+ }
+ }
if (predicate.is_object_safe (true, type.get_locus ()))
specified_bounds.push_back (std::move (predicate));