aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2021-09-09 16:11:53 +0000
committerGitHub <noreply@github.com>2021-09-09 16:11:53 +0000
commite93393d007276a3335839741f45865bc05787869 (patch)
treebc0f64ed7eb4c784302c1c74af0303abfdfe585a /gcc
parent55f60bd6fe2db6831762e243577515824e2fca5c (diff)
parent0f85a9421349ff80329f7a6db4a70eff58bf49bc (diff)
downloadgcc-e93393d007276a3335839741f45865bc05787869.zip
gcc-e93393d007276a3335839741f45865bc05787869.tar.gz
gcc-e93393d007276a3335839741f45865bc05787869.tar.bz2
Merge #662
662: Add building blocks for super-traits r=philberty a=philberty Add name resolution and HIR lowering to trait-bounds Co-authored-by: Philip Herron <philip.herron@embecosm.com>
Diffstat (limited to 'gcc')
-rw-r--r--gcc/rust/hir/rust-ast-lower-item.h9
-rw-r--r--gcc/rust/resolve/rust-ast-resolve-item.h8
-rw-r--r--gcc/rust/typecheck/rust-hir-trait-resolve.h4
3 files changed, 21 insertions, 0 deletions
diff --git a/gcc/rust/hir/rust-ast-lower-item.h b/gcc/rust/hir/rust-ast-lower-item.h
index dfc2612..d5c56c0 100644
--- a/gcc/rust/hir/rust-ast-lower-item.h
+++ b/gcc/rust/hir/rust-ast-lower-item.h
@@ -579,6 +579,15 @@ public:
}
std::vector<std::unique_ptr<HIR::TypeParamBound>> type_param_bounds;
+ if (trait.has_type_param_bounds ())
+ {
+ for (auto &bound : trait.get_type_param_bounds ())
+ {
+ HIR::TypeParamBound *b = lower_bound (bound.get ());
+ type_param_bounds.push_back (
+ std::unique_ptr<HIR::TypeParamBound> (b));
+ }
+ }
std::vector<std::unique_ptr<HIR::TraitItem>> trait_items;
std::vector<HirId> trait_item_ids;
diff --git a/gcc/rust/resolve/rust-ast-resolve-item.h b/gcc/rust/resolve/rust-ast-resolve-item.h
index 2a2f956..87bf10e 100644
--- a/gcc/rust/resolve/rust-ast-resolve-item.h
+++ b/gcc/rust/resolve/rust-ast-resolve-item.h
@@ -593,6 +593,14 @@ public:
resolver->get_type_scope ().append_reference_for_def (
Self.get_id (), implicit_self->get_node_id ());
+ if (trait.has_type_param_bounds ())
+ {
+ for (auto &bound : trait.get_type_param_bounds ())
+ {
+ ResolveTypeBound::go (bound.get (), trait.get_node_id ());
+ }
+ }
+
for (auto &item : trait.get_trait_items ())
{
ResolveTraitItems::go (item.get (), Self);
diff --git a/gcc/rust/typecheck/rust-hir-trait-resolve.h b/gcc/rust/typecheck/rust-hir-trait-resolve.h
index 365994f..49aa2fa 100644
--- a/gcc/rust/typecheck/rust-hir-trait-resolve.h
+++ b/gcc/rust/typecheck/rust-hir-trait-resolve.h
@@ -113,6 +113,10 @@ private:
return tref;
}
+ // Check if there is a super-trait, and apply this bound to the Self
+ // TypeParam
+ // FIXME
+
TyTy::BaseType *self = nullptr;
std::vector<TyTy::SubstitutionParamMapping> substitutions;
for (auto &generic_param : trait_reference->get_generic_params ())