Tidy. Rename variables.

This commit is contained in:
Andrew Cann 2016-08-19 14:12:37 +08:00
parent 1c3e8b0a1c
commit f120c71775
3 changed files with 18 additions and 17 deletions

View File

@ -37,11 +37,11 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
self.write_ty(pat.id, expected);
}
PatKind::Lit(ref lt) => {
let expr_t = self.check_expr(&lt);
let ty = self.check_expr(&lt);
// Byte string patterns behave the same way as array patterns
// They can denote both statically and dynamically sized byte arrays
let mut pat_ty = expr_t;
let mut pat_ty = ty;
if let hir::ExprLit(ref lt) = lt.node {
if let ast::LitKind::ByteStr(_) = lt.node {
let expected_ty = self.structurally_resolved_type(pat.span, expected);
@ -62,7 +62,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
// relation at all but rather that there exists a LUB (so
// that they can be compared). However, in practice,
// constants are always scalars or strings. For scalars
// subtyping is irrelevant, and for strings `expr_t` is
// subtyping is irrelevant, and for strings `ty` is
// type is `&'static str`, so if we say that
//
// &'static str <: expected

View File

@ -3241,19 +3241,19 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
base_expr: &'gcx Option<P<hir::Expr>>) -> Ty<'tcx>
{
// Find the relevant variant
let (variant, expr_t) = if let Some(variant_ty) = self.check_struct_path(path, expr.id,
expr.span) {
let (variant, struct_ty) = if let Some(variant_ty) = self.check_struct_path(path, expr.id,
expr.span) {
variant_ty
} else {
self.check_struct_fields_on_error(fields, base_expr);
return self.tcx().types.err;
};
self.check_expr_struct_fields(expr_t, path.span, variant, fields,
self.check_expr_struct_fields(struct_ty, path.span, variant, fields,
base_expr.is_none());
if let &Some(ref base_expr) = base_expr {
self.check_expr_has_type(base_expr, expr_t);
match expr_t.sty {
self.check_expr_has_type(base_expr, struct_ty);
match struct_ty.sty {
ty::TyStruct(adt, substs) => {
self.tables.borrow_mut().fru_field_types.insert(
expr.id,
@ -3270,8 +3270,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
}
}
}
self.require_type_is_sized(expr_t, expr.span, traits::StructInitializerSized);
expr_t
self.require_type_is_sized(struct_ty, expr.span, traits::StructInitializerSized);
struct_ty
}
@ -3881,15 +3881,15 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
hir::StmtExpr(ref expr, id) => {
node_id = id;
// Check with expected type of ()
let expr_t = self.check_expr_has_type(&expr, self.tcx.mk_nil());
saw_bot = saw_bot || self.type_var_diverges(expr_t);
saw_err = saw_err || expr_t.references_error();
let ty = self.check_expr_has_type(&expr, self.tcx.mk_nil());
saw_bot = saw_bot || self.type_var_diverges(ty);
saw_err = saw_err || ty.references_error();
}
hir::StmtSemi(ref expr, id) => {
node_id = id;
let expr_t = self.check_expr(&expr);
saw_bot |= self.type_var_diverges(expr_t);
saw_err |= expr_t.references_error();
let ty = self.check_expr(&expr);
saw_bot |= self.type_var_diverges(ty);
saw_err |= ty.references_error();
}
}
if saw_bot {

View File

@ -32,7 +32,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
self.check_overloaded_binop(expr, lhs_expr, lhs_ty, rhs_expr, op, IsAssign::Yes);
let rhs_ty = self.resolve_type_vars_with_obligations(rhs_ty);
let ty = if !lhs_ty.is_ty_var() && !rhs_ty.is_ty_var() && is_builtin_binop(lhs_ty, rhs_ty, op) {
let ty = if !lhs_ty.is_ty_var() && !rhs_ty.is_ty_var()
&& is_builtin_binop(lhs_ty, rhs_ty, op) {
self.enforce_builtin_binop_types(lhs_expr, lhs_ty, rhs_expr, rhs_ty, op);
self.tcx.mk_nil()
} else {