diff options
author | Philip Herron <philip.herron@embecosm.com> | 2021-07-09 13:40:36 +0100 |
---|---|---|
committer | Philip Herron <philip.herron@embecosm.com> | 2021-07-10 21:33:08 +0100 |
commit | 0352605f4ae03639dfdeb0c3b5e02c344807075c (patch) | |
tree | 530c886b7a862877104248a94b517195af73922a | |
parent | 213bc11225fcbb57e2fa6d949917bd2cf44e2477 (diff) | |
download | gcc-0352605f4ae03639dfdeb0c3b5e02c344807075c.zip gcc-0352605f4ae03639dfdeb0c3b5e02c344807075c.tar.gz gcc-0352605f4ae03639dfdeb0c3b5e02c344807075c.tar.bz2 |
Add path probe and impl overlapping updates for TypeAliases
With the desuagaring of AST::TraitImpl and AST::InherentImpl into a generic
HIR::ImplBlock we must ensure the existing passes can support TypeAliases
accordingly.
-rw-r--r-- | gcc/rust/typecheck/rust-hir-inherent-impl-overlap.h | 6 | ||||
-rw-r--r-- | gcc/rust/typecheck/rust-hir-path-probe.h | 20 |
2 files changed, 26 insertions, 0 deletions
diff --git a/gcc/rust/typecheck/rust-hir-inherent-impl-overlap.h b/gcc/rust/typecheck/rust-hir-inherent-impl-overlap.h index cbfe1df..0879360 100644 --- a/gcc/rust/typecheck/rust-hir-inherent-impl-overlap.h +++ b/gcc/rust/typecheck/rust-hir-inherent-impl-overlap.h @@ -37,6 +37,12 @@ public: return resolver.ok; } + void visit (HIR::TypeAlias &alias) override + { + ok = true; + result.assign (alias.get_new_type_name ()); + } + void visit (HIR::Function &function) override { ok = true; diff --git a/gcc/rust/typecheck/rust-hir-path-probe.h b/gcc/rust/typecheck/rust-hir-path-probe.h index e21bfc9..a10a562 100644 --- a/gcc/rust/typecheck/rust-hir-path-probe.h +++ b/gcc/rust/typecheck/rust-hir-path-probe.h @@ -65,6 +65,21 @@ public: item->accept_vis (*this); } + void visit (HIR::TypeAlias &alias) override + { + Identifier name = alias.get_new_type_name (); + if (search.as_string ().compare (name) == 0) + { + HirId tyid = alias.get_mappings ().get_hirid (); + TyTy::BaseType *ty = nullptr; + bool ok = context->lookup_type (tyid, &ty); + rust_assert (ok); + + PathProbeCandidate candidate{&alias, ty}; + candidates.push_back (std::move (candidate)); + } + } + void visit (HIR::ConstantItem &constant) override { Identifier name = constant.get_identifier (); @@ -122,6 +137,11 @@ public: query.as_string ().c_str ()); } + void visit (HIR::TypeAlias &alias) override + { + r.add_range (alias.get_locus ()); + } + void visit (HIR::ConstantItem &constant) override { r.add_range (constant.get_locus ()); |