// we need to setup with apropriate bounds
HIR::TypePath &bound_path
= *associated->get_impl_block ()->get_trait_ref ().get ();
-
- // generate an implicit HIR Type we can apply to the predicate
- HirId implicit_id = mappings->get_next_hir_id ();
- context->insert_implicit_type (implicit_id, impl_block_ty);
-
- Analysis::NodeMapping mappings (expr_mappings.get_crate_num (),
- expr_mappings.get_nodeid (),
- implicit_id,
- expr_mappings.get_local_defid ());
- HIR::TypePath *implicit_self_bound
- = new HIR::TypePath (mappings, {},
- Linemap::predeclared_location (), false);
-
- TyTy::TypeBoundPredicate predicate
- = get_predicate_from_bound (bound_path, implicit_self_bound);
- impl_block_ty
- = associated->setup_associated_types (prev_segment, predicate);
+ const auto &trait_ref = *TraitResolver::Resolve (bound_path);
+ rust_assert (!trait_ref.is_error ());
+
+ const auto &predicate
+ = impl_block_ty->lookup_predicate (trait_ref.get_defid ());
+ if (!predicate.is_error ())
+ impl_block_ty
+ = associated->setup_associated_types (prev_segment,
+ predicate);
}
}
SubstitutionArg::SubstitutionArg (const SubstitutionParamMapping *param,
BaseType *argument)
: param (param), argument (argument)
-{}
+{
+ if (param != nullptr)
+ original_param = param->get_param_ty ();
+}
SubstitutionArg::SubstitutionArg (const SubstitutionArg &other)
- : param (other.param), argument (other.argument)
+ : param (other.param), original_param (other.original_param),
+ argument (other.argument)
{}
SubstitutionArg &
{
param = other.param;
argument = other.argument;
+ original_param = other.original_param;
+
return *this;
}
return param;
}
+const ParamType *
+SubstitutionArg::get_param_ty () const
+{
+ return original_param;
+}
+
SubstitutionArg
SubstitutionArg::error ()
{
std::string
SubstitutionArg::as_string () const
{
- return param->as_string ()
+ return original_param->as_string ()
+ (argument != nullptr ? ":" + argument->as_string () : "");
}
{
for (auto &mapping : mappings)
{
- const SubstitutionParamMapping *param = mapping.get_param_mapping ();
- const ParamType *p = param->get_param_ty ();
-
+ const ParamType *p = mapping.get_param_ty ();
if (p->get_symbol ().compare (param_to_find->get_symbol ()) == 0)
{
*argument = mapping;
const SubstitutionParamMapping *get_param_mapping () const;
+ const ParamType *get_param_ty () const;
+
static SubstitutionArg error ();
bool is_error () const;
private:
const SubstitutionParamMapping *param;
+ const ParamType *original_param;
BaseType *argument;
};