aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorPhilip Herron <philip.herron@embecosm.com>2021-10-21 22:22:19 +0100
committerPhilip Herron <philip.herron@embecosm.com>2021-10-22 11:48:42 +0100
commitb3b37e2c5cda1eace7acf9dad6eb6568a90a4ea4 (patch)
treed26611c3195461c78145b092a29c452a97d2619d /gcc
parent243e5d800dc03f36025e72d275b79a2098dbb953 (diff)
downloadgcc-b3b37e2c5cda1eace7acf9dad6eb6568a90a4ea4.zip
gcc-b3b37e2c5cda1eace7acf9dad6eb6568a90a4ea4.tar.gz
gcc-b3b37e2c5cda1eace7acf9dad6eb6568a90a4ea4.tar.bz2
Extract const helper method is_receiver_generic for path probes.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/rust/typecheck/rust-hir-path-probe.h19
1 files changed, 9 insertions, 10 deletions
diff --git a/gcc/rust/typecheck/rust-hir-path-probe.h b/gcc/rust/typecheck/rust-hir-path-probe.h
index 8ceec00..589b0d6 100644
--- a/gcc/rust/typecheck/rust-hir-path-probe.h
+++ b/gcc/rust/typecheck/rust-hir-path-probe.h
@@ -275,16 +275,7 @@ protected:
}
TyTy::BaseType *trait_item_tyty = trait_item_ref->get_tyty ();
-
- // we cannot auto setup associated type mappings when our receiver is a
- // generic type bound
- const TyTy::BaseType *root = receiver->get_root ();
- bool receiver_is_type_param
- = root->get_kind () == TyTy::TypeKind::PARAM;
- bool receiver_is_dyn = root->get_kind () == TyTy::TypeKind::DYNAMIC;
- bool receiver_is_generic = receiver_is_type_param || receiver_is_dyn;
-
- if (impl != nullptr && !receiver_is_generic)
+ if (impl != nullptr && !is_reciever_generic ())
{
HirId impl_block_id = impl->get_mappings ().get_hirid ();
@@ -367,6 +358,14 @@ protected:
return union_set;
}
+ bool is_reciever_generic () const
+ {
+ const TyTy::BaseType *root = receiver->get_root ();
+ bool receiver_is_type_param = root->get_kind () == TyTy::TypeKind::PARAM;
+ bool receiver_is_dyn = root->get_kind () == TyTy::TypeKind::DYNAMIC;
+ return receiver_is_type_param || receiver_is_dyn;
+ }
+
const TyTy::BaseType *receiver;
const HIR::PathIdentSegment &search;
std::vector<PathProbeCandidate> candidates;