structurally_resolved_type,
};
use middle::traits;
-use middle::ty::{self, Ty};
+use middle::ty::{self, Ty, HasTypeFlags};
use syntax::ast;
use syntax::ast_util;
use syntax::parse::token;
fcx.write_nil(expr.id);
} else {
// error types are considered "builtin"
- assert!(!ty::type_is_error(lhs_ty) || !ty::type_is_error(rhs_ty));
+ assert!(!lhs_ty.references_error() || !rhs_ty.references_error());
span_err!(tcx.sess, lhs_expr.span, E0368,
"binary assignment operation `{}=` cannot be applied to types `{}` and `{}`",
ast_util::binop_to_string(op.node),
}
let tcx = fcx.tcx();
- if !ty::expr_is_lval(tcx, lhs_expr) {
- span_err!(tcx.sess, lhs_expr.span, E0067, "illegal left-hand side expression");
+ if !tcx.expr_is_lval(lhs_expr) {
+ span_err!(tcx.sess, lhs_expr.span, E0067, "invalid left-hand side expression");
}
fcx.require_expr_have_sized_type(lhs_expr, traits::AssignmentLhsSized);
// traits, because their return type is not bool. Perhaps this
// should change, but for now if LHS is SIMD we go down a
// different path that bypassess all traits.
- if ty::type_is_simd(fcx.tcx(), lhs_ty) {
+ if lhs_ty.is_simd(fcx.tcx()) {
check_expr_coercable_to_type(fcx, rhs_expr, lhs_ty);
let rhs_ty = fcx.resolve_type_vars_if_possible(fcx.expr_ty(lhs_expr));
let return_ty = enforce_builtin_binop_types(fcx, lhs_expr, lhs_ty, rhs_expr, rhs_ty, op);
match BinOpCategory::from(op) {
BinOpCategory::Shortcircuit => {
// && and || are a simple case.
- demand::suptype(fcx, lhs_expr.span, ty::mk_bool(tcx), lhs_ty);
- check_expr_coercable_to_type(fcx, rhs_expr, ty::mk_bool(tcx));
- fcx.write_ty(expr.id, ty::mk_bool(tcx));
+ demand::suptype(fcx, lhs_expr.span, tcx.mk_bool(), lhs_ty);
+ check_expr_coercable_to_type(fcx, rhs_expr, tcx.mk_bool());
+ fcx.write_ty(expr.id, tcx.mk_bool());
}
_ => {
// Otherwise, we always treat operators as if they are
// can't pin this down to a specific impl.
let rhs_ty = fcx.resolve_type_vars_if_possible(rhs_ty);
if
- !ty::type_is_ty_var(lhs_ty) &&
- !ty::type_is_ty_var(rhs_ty) &&
+ !lhs_ty.is_ty_var() && !rhs_ty.is_ty_var() &&
is_builtin_binop(fcx.tcx(), lhs_ty, rhs_ty, op)
{
let builtin_return_ty =
let tcx = fcx.tcx();
match BinOpCategory::from(op) {
BinOpCategory::Shortcircuit => {
- demand::suptype(fcx, lhs_expr.span, ty::mk_bool(tcx), lhs_ty);
- demand::suptype(fcx, rhs_expr.span, ty::mk_bool(tcx), rhs_ty);
- ty::mk_bool(tcx)
+ demand::suptype(fcx, lhs_expr.span, tcx.mk_bool(), lhs_ty);
+ demand::suptype(fcx, rhs_expr.span, tcx.mk_bool(), rhs_ty);
+ tcx.mk_bool()
}
BinOpCategory::Shift => {
// For integers, the shift amount can be of any integral
// type. For simd, the type must match exactly.
- if ty::type_is_simd(tcx, lhs_ty) {
+ if lhs_ty.is_simd(tcx) {
demand::suptype(fcx, rhs_expr.span, lhs_ty, rhs_ty);
}
demand::suptype(fcx, rhs_expr.span, lhs_ty, rhs_ty);
// if this is simd, result is same as lhs, else bool
- if ty::type_is_simd(tcx, lhs_ty) {
- let unit_ty = ty::simd_type(tcx, lhs_ty);
+ if lhs_ty.is_simd(tcx) {
+ let unit_ty = lhs_ty.simd_type(tcx);
debug!("enforce_builtin_binop_types: lhs_ty={:?} unit_ty={:?}",
lhs_ty,
unit_ty);
- if !ty::type_is_integral(unit_ty) {
+ if !unit_ty.is_integral() {
tcx.sess.span_err(
lhs_expr.span,
&format!("binary comparison operation `{}` not supported \
lhs_ty
}
} else {
- ty::mk_bool(tcx)
+ tcx.mk_bool()
}
}
}
Ok(return_ty) => return_ty,
Err(()) => {
// error types are considered "builtin"
- if !ty::type_is_error(lhs_ty) {
+ if !lhs_ty.references_error() {
span_err!(fcx.tcx().sess, lhs_expr.span, E0369,
"binary operation `{}` cannot be applied to type `{}`",
ast_util::binop_to_string(op.node),
// HACK(eddyb) Fully qualified path to work around a resolve bug.
let method_call = ::middle::ty::MethodCall::expr(expr.id);
- fcx.inh.method_map.borrow_mut().insert(method_call, method);
+ fcx.inh.tables.borrow_mut().method_map.insert(method_call, method);
// extract return type for method; all late bound regions
// should have been instantiated by now
- let ret_ty = ty::ty_fn_ret(method_ty);
- Ok(ty::no_late_bound_regions(fcx.tcx(), &ret_ty).unwrap().unwrap())
+ let ret_ty = method_ty.fn_ret();
+ Ok(fcx.tcx().no_late_bound_regions(&ret_ty).unwrap().unwrap())
}
None => {
Err(())
}
BinOpCategory::Shift => {
- ty::type_is_error(lhs) || ty::type_is_error(rhs) ||
- ty::type_is_integral(lhs) && ty::type_is_integral(rhs) ||
- ty::type_is_simd(cx, lhs) && ty::type_is_simd(cx, rhs)
+ lhs.references_error() || rhs.references_error() ||
+ lhs.is_integral() && rhs.is_integral() ||
+ lhs.is_simd(cx) && rhs.is_simd(cx)
}
BinOpCategory::Math => {
- ty::type_is_error(lhs) || ty::type_is_error(rhs) ||
- ty::type_is_integral(lhs) && ty::type_is_integral(rhs) ||
- ty::type_is_floating_point(lhs) && ty::type_is_floating_point(rhs) ||
- ty::type_is_simd(cx, lhs) && ty::type_is_simd(cx, rhs)
+ lhs.references_error() || rhs.references_error() ||
+ lhs.is_integral() && rhs.is_integral() ||
+ lhs.is_floating_point() && rhs.is_floating_point() ||
+ lhs.is_simd(cx) && rhs.is_simd(cx)
}
BinOpCategory::Bitwise => {
- ty::type_is_error(lhs) || ty::type_is_error(rhs) ||
- ty::type_is_integral(lhs) && ty::type_is_integral(rhs) ||
- ty::type_is_floating_point(lhs) && ty::type_is_floating_point(rhs) ||
- ty::type_is_simd(cx, lhs) && ty::type_is_simd(cx, rhs) ||
- ty::type_is_bool(lhs) && ty::type_is_bool(rhs)
+ lhs.references_error() || rhs.references_error() ||
+ lhs.is_integral() && rhs.is_integral() ||
+ lhs.is_floating_point() && rhs.is_floating_point() ||
+ lhs.is_simd(cx) && rhs.is_simd(cx) ||
+ lhs.is_bool() && rhs.is_bool()
}
BinOpCategory::Comparison => {
- ty::type_is_error(lhs) || ty::type_is_error(rhs) ||
- ty::type_is_scalar(lhs) && ty::type_is_scalar(rhs) ||
- ty::type_is_simd(cx, lhs) && ty::type_is_simd(cx, rhs)
+ lhs.references_error() || rhs.references_error() ||
+ lhs.is_scalar() && rhs.is_scalar() ||
+ lhs.is_simd(cx) && rhs.is_simd(cx)
}
}
}
-