From f120c71775994e4fb94941cbc5539f6d5ffddced Mon Sep 17 00:00:00 2001 From: Andrew Cann Date: Fri, 19 Aug 2016 14:12:37 +0800 Subject: [PATCH] Tidy. Rename variables. --- src/librustc_typeck/check/_match.rs | 6 +++--- src/librustc_typeck/check/mod.rs | 26 +++++++++++++------------- src/librustc_typeck/check/op.rs | 3 ++- 3 files changed, 18 insertions(+), 17 deletions(-) diff --git a/src/librustc_typeck/check/_match.rs b/src/librustc_typeck/check/_match.rs index 5e7c499671c..763e92b69ba 100644 --- a/src/librustc_typeck/check/_match.rs +++ b/src/librustc_typeck/check/_match.rs @@ -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(<); + let ty = self.check_expr(<); // 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 diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 2a12b7055d4..a8c8a10dc56 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -3241,19 +3241,19 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { base_expr: &'gcx Option>) -> 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 { diff --git a/src/librustc_typeck/check/op.rs b/src/librustc_typeck/check/op.rs index af7e12bd48d..411bd7e7b5c 100644 --- a/src/librustc_typeck/check/op.rs +++ b/src/librustc_typeck/check/op.rs @@ -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 {