? func.get_decl ().get_return_type ()->get_locus ()
: func.get_locus ();
- TypeCheckBase::coercion_site (func.get_mappings ().get_hirid (),
- TyTy::TyWithLocation (expected_ret_tyty,
- fn_return_locus),
- TyTy::TyWithLocation (block_expr_ty),
- func.get_locus ());
+ coercion_site (func.get_mappings ().get_hirid (),
+ TyTy::TyWithLocation (expected_ret_tyty, fn_return_locus),
+ TyTy::TyWithLocation (block_expr_ty), func.get_locus ());
context->pop_return_type ();
}
#include "rust-hir-type-check-base.h"
#include "rust-casts.h"
-#include "rust-coercion.h"
#include "rust-hir-type-check-expr.h"
#include "rust-hir-type-check-implitem.h"
#include "rust-hir-type-check-item.h"
return repr;
}
-TyTy::BaseType *
-TypeCheckBase::coercion_site (HirId id, TyTy::TyWithLocation lhs,
- TyTy::TyWithLocation rhs, Location locus)
-{
- TyTy::BaseType *expected = lhs.get_ty ();
- TyTy::BaseType *expr = rhs.get_ty ();
-
- rust_debug ("coercion_site id={%u} expected={%s} expr={%s}", id,
- expected->debug_str ().c_str (), expr->debug_str ().c_str ());
-
- auto context = TypeCheckContext::get ();
- if (expected->get_kind () == TyTy::TypeKind::ERROR
- || expr->get_kind () == TyTy::TypeKind::ERROR)
- return expr;
-
- // can we autoderef it?
- auto result = TypeCoercionRules::Coerce (expr, expected, locus);
-
- // the result needs to be unified
- TyTy::BaseType *receiver = expr;
- if (!result.is_error ())
- {
- receiver = result.tyty;
- }
-
- rust_debug ("coerce_default_unify(a={%s}, b={%s})",
- receiver->debug_str ().c_str (), expected->debug_str ().c_str ());
- TyTy::BaseType *coerced
- = unify_site (id, lhs, TyTy::TyWithLocation (receiver, rhs.get_locus ()),
- locus);
- context->insert_autoderef_mappings (id, std::move (result.adjustments));
- return coerced;
-}
-
TyTy::BaseType *
TypeCheckBase::cast_site (HirId id, TyTy::TyWithLocation from,
TyTy::TyWithLocation to, Location cast_locus)
public:
virtual ~TypeCheckBase () {}
- static TyTy::BaseType *coercion_site (HirId id, TyTy::TyWithLocation lhs,
- TyTy::TyWithLocation rhs,
- Location coercion_locus);
-
static TyTy::BaseType *cast_site (HirId id, TyTy::TyWithLocation from,
TyTy::TyWithLocation to,
Location cast_locus);
#include "rust-hir-visitor.h"
#include "rust-name-resolver.h"
#include "rust-unify.h"
+#include "rust-coercion.h"
namespace Rust {
namespace Resolver {
true /*emit_error*/);
}
+TyTy::BaseType *
+coercion_site (HirId id, TyTy::TyWithLocation lhs, TyTy::TyWithLocation rhs,
+ Location locus)
+{
+ TyTy::BaseType *expected = lhs.get_ty ();
+ TyTy::BaseType *expr = rhs.get_ty ();
+
+ rust_debug ("coercion_site id={%u} expected={%s} expr={%s}", id,
+ expected->debug_str ().c_str (), expr->debug_str ().c_str ());
+
+ auto context = TypeCheckContext::get ();
+ if (expected->get_kind () == TyTy::TypeKind::ERROR
+ || expr->get_kind () == TyTy::TypeKind::ERROR)
+ return expr;
+
+ // can we autoderef it?
+ auto result = TypeCoercionRules::Coerce (expr, expected, locus);
+
+ // the result needs to be unified
+ TyTy::BaseType *receiver = expr;
+ if (!result.is_error ())
+ {
+ receiver = result.tyty;
+ }
+
+ rust_debug ("coerce_default_unify(a={%s}, b={%s})",
+ receiver->debug_str ().c_str (), expected->debug_str ().c_str ());
+ TyTy::BaseType *coerced
+ = unify_site (id, lhs, TyTy::TyWithLocation (receiver, rhs.get_locus ()),
+ locus);
+ context->insert_autoderef_mappings (id, std::move (result.adjustments));
+ return coerced;
+}
+
} // namespace Resolver
} // namespace Rust
unify_site (HirId id, TyTy::TyWithLocation lhs, TyTy::TyWithLocation rhs,
Location unify_locus);
+TyTy::BaseType *
+coercion_site (HirId id, TyTy::TyWithLocation lhs, TyTy::TyWithLocation rhs,
+ Location coercion_locus);
+
} // namespace Resolver
} // namespace Rust
}
HirId coercion_side_id = argument->get_mappings ().get_hirid ();
- auto res = Resolver::TypeCheckBase::coercion_site (
- coercion_side_id, TyWithLocation (field_tyty),
- TyWithLocation (arg, arg_locus), argument->get_locus ());
+ auto res = Resolver::coercion_site (coercion_side_id,
+ TyWithLocation (field_tyty),
+ TyWithLocation (arg, arg_locus),
+ argument->get_locus ());
if (res->get_kind () == TyTy::TypeKind::ERROR)
{
return;
: fn_param_pattern->get_locus ();
HirId coercion_side_id = argument->get_mappings ().get_hirid ();
- auto resolved_argument_type = Resolver::TypeCheckBase::coercion_site (
- coercion_side_id, TyWithLocation (param_ty, param_locus),
- TyWithLocation (argument_expr_tyty, arg_locus),
- argument->get_locus ());
+ auto resolved_argument_type
+ = Resolver::coercion_site (coercion_side_id,
+ TyWithLocation (param_ty, param_locus),
+ TyWithLocation (argument_expr_tyty,
+ arg_locus),
+ argument->get_locus ());
if (resolved_argument_type->get_kind () == TyTy::TypeKind::ERROR)
{
return;
return;
}
- auto resolved_argument_type = Resolver::TypeCheckBase::coercion_site (
+ auto resolved_argument_type = Resolver::coercion_site (
argument->get_mappings ().get_hirid (), TyWithLocation (fnparam),
TyWithLocation (argument_expr_tyty, arg_locus), argument->get_locus ());
if (resolved_argument_type->get_kind () == TyTy::TypeKind::ERROR)
auto argument_expr_tyty = argument.get_argument_type ();
HirId coercion_side_id = argument.get_mappings ().get_hirid ();
- auto resolved_argument_type = Resolver::TypeCheckBase::coercion_site (
+ auto resolved_argument_type = Resolver::coercion_site (
coercion_side_id, TyWithLocation (param_ty, param_locus),
TyWithLocation (argument_expr_tyty, arg_locus), arg_locus);
if (resolved_argument_type->get_kind () == TyTy::TypeKind::ERROR)