From 0352605f4ae03639dfdeb0c3b5e02c344807075c Mon Sep 17 00:00:00 2001 From: Philip Herron Date: Fri, 9 Jul 2021 13:40:36 +0100 Subject: 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. --- gcc/rust/typecheck/rust-hir-inherent-impl-overlap.h | 6 ++++++ gcc/rust/typecheck/rust-hir-path-probe.h | 20 ++++++++++++++++++++ 2 files changed, 26 insertions(+) (limited to 'gcc') 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 ()); -- cgit v1.1