fixed renaming of rustc::middle::ty enums

This commit is contained in:
llogiq 2015-06-15 13:27:24 +02:00
parent 0e5b62c8d8
commit 9a3dcaabe8
3 changed files with 19 additions and 15 deletions

View File

@ -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,
}
}

View File

@ -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<Expr>]) -> 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 }
}

View File

@ -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. \