From 9a3dcaabe8753ba7bdc687c4937d3ccb58d5d42f Mon Sep 17 00:00:00 2001 From: llogiq Date: Mon, 15 Jun 2015 13:27:24 +0200 Subject: [PATCH] fixed renaming of rustc::middle::ty enums --- src/len_zero.rs | 10 +++++----- src/misc.rs | 20 ++++++++++++-------- src/mut_mut.rs | 4 ++-- 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/src/len_zero.rs b/src/len_zero.rs index 5d97efdf02c0..0974e8f21e2a 100644 --- a/src/len_zero.rs +++ b/src/len_zero.rs @@ -5,7 +5,7 @@ use std::cell::RefCell; use syntax::ptr::P; use rustc::lint::{Context, LintPass, LintArray, Lint}; use rustc::util::nodemap::DefIdMap; -use rustc::middle::ty::{self, node_id_to_type, sty, ty_ptr, ty_rptr, expr_ty, +use rustc::middle::ty::{self, node_id_to_type, TypeVariants, expr_ty, mt, ty_to_def_id, impl_or_trait_item, MethodTraitItemId, ImplOrTraitItemId}; use rustc::middle::def::{DefTy, DefStruct, DefTrait}; use syntax::codemap::{Span, Spanned}; @@ -138,14 +138,14 @@ fn has_is_empty(cx: &Context, expr: &Expr) -> bool { let ty = &walk_ty(&expr_ty(cx.tcx, expr)); match ty.sty { - ty::ty_trait(_) => cx.tcx.trait_item_def_ids.borrow().get( + ty::TyTrait(_) => cx.tcx.trait_item_def_ids.borrow().get( &ty::ty_to_def_id(ty).expect("trait impl not found")).map_or(false, |ids| ids.iter().any(|i| is_is_empty(cx, i))), - ty::ty_projection(_) => ty::ty_to_def_id(ty).map_or(false, + ty::TyProjection(_) => ty::ty_to_def_id(ty).map_or(false, |id| has_is_empty_impl(cx, &id)), - ty::ty_enum(ref id, _) | ty::ty_struct(ref id, _) => + ty::TyEnum(ref id, _) | ty::TyStruct(ref id, _) => has_is_empty_impl(cx, id), - ty::ty_vec(..) => true, + ty::TyArray(..) => true, _ => false, } } diff --git a/src/misc.rs b/src/misc.rs index ec609fd26186..f2492cf187dd 100644 --- a/src/misc.rs +++ b/src/misc.rs @@ -4,7 +4,7 @@ use syntax::ast::*; use syntax::ast_util::{is_comparison_binop, binop_to_string}; use syntax::visit::{FnKind}; use rustc::lint::{Context, LintPass, LintArray, Lint, Level}; -use rustc::middle::ty::{self, expr_ty, ty_str, ty_ptr, ty_rptr, ty_float}; +use rustc::middle::ty::{self, expr_ty}; use syntax::codemap::{Span, Spanned}; use types::span_note_and_lint; @@ -12,7 +12,7 @@ use utils::match_path; pub fn walk_ty<'t>(ty: ty::Ty<'t>) -> ty::Ty<'t> { match ty.sty { - ty_ptr(ref tm) | ty_rptr(_, ref tm) => walk_ty(tm.ty), + ty::TyRef(_, ref tm) | ty::TyRawPtr(ref tm) => walk_ty(tm.ty), _ => ty } } @@ -79,10 +79,10 @@ impl LintPass for StrToStringPass { } fn is_str(cx: &Context, expr: &ast::Expr) -> bool { - match walk_ty(expr_ty(cx.tcx, expr)).sty { - ty_str => true, - _ => false - } + match walk_ty(expr_ty(cx.tcx, expr)).sty { + ty::TyStr => true, + _ => false + } } } } @@ -167,7 +167,11 @@ impl LintPass for FloatCmp { } fn is_float(cx: &Context, expr: &Expr) -> bool { - if let ty_float(_) = walk_ty(expr_ty(cx.tcx, expr)).sty { true } else { false } + if let ty::TyFloat(_) = walk_ty(expr_ty(cx.tcx, expr)).sty { + true + } else { + false + } } declare_lint!(pub PRECEDENCE, Warn, @@ -263,6 +267,6 @@ fn check_to_owned(cx: &Context, expr: &Expr, other_span: Span) { } fn is_str_arg(cx: &Context, args: &[P]) -> bool { - args.len() == 1 && if let ty_str = + args.len() == 1 && if let ty::TyStr = walk_ty(expr_ty(cx.tcx, &*args[0])).sty { true } else { false } } diff --git a/src/mut_mut.rs b/src/mut_mut.rs index 202b5600dbe4..fc5de44542fb 100644 --- a/src/mut_mut.rs +++ b/src/mut_mut.rs @@ -1,7 +1,7 @@ use syntax::ptr::P; use syntax::ast::*; use rustc::lint::{Context, LintPass, LintArray, Lint}; -use rustc::middle::ty::{expr_ty, sty, ty_ptr, ty_rptr, mt}; +use rustc::middle::ty::{expr_ty, TypeVariants, mt, TyRef}; use syntax::codemap::{BytePos, ExpnInfo, MacroFormat, Span}; use utils::in_macro; @@ -42,7 +42,7 @@ fn check_expr_expd(cx: &Context, expr: &Expr, info: Option<&ExpnInfo>) { cx.span_lint(MUT_MUT, expr.span, "Generally you want to avoid &mut &mut _ if possible.") }).unwrap_or_else(|| { - if let ty_rptr(_, mt{ty: _, mutbl: MutMutable}) = + if let TyRef(_, mt{ty: _, mutbl: MutMutable}) = expr_ty(cx.tcx, e).sty { cx.span_lint(MUT_MUT, expr.span, "This expression mutably borrows a mutable reference. \