mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-11 07:34:18 +00:00
Merge pull request #106 from zmbush/nightly
Fix build for rustc 1.3.0-nightly (bf3c979ec 2015-06-30)
This commit is contained in:
commit
60ee6a4c06
4 changed files with 12 additions and 13 deletions
|
@ -5,8 +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, TypeVariants, expr_ty,
|
||||
mt, ty_to_def_id, impl_or_trait_item, MethodTraitItemId, ImplOrTraitItemId};
|
||||
use rustc::middle::ty::{self, TypeVariants, mt, MethodTraitItemId, ImplOrTraitItemId};
|
||||
use rustc::middle::def::{DefTy, DefStruct, DefTrait};
|
||||
use syntax::codemap::{Span, Spanned};
|
||||
use syntax::ast::*;
|
||||
|
@ -121,7 +120,7 @@ fn has_is_empty(cx: &Context, expr: &Expr) -> bool {
|
|||
fn is_is_empty(cx: &Context, id: &ImplOrTraitItemId) -> bool {
|
||||
if let &MethodTraitItemId(def_id) = id {
|
||||
if let ty::MethodTraitItem(ref method) =
|
||||
ty::impl_or_trait_item(cx.tcx, def_id) {
|
||||
cx.tcx.impl_or_trait_item(def_id) {
|
||||
method.name.as_str() == "is_empty"
|
||||
&& method.fty.sig.skip_binder().inputs.len() == 1
|
||||
} else { false }
|
||||
|
@ -136,12 +135,12 @@ fn has_is_empty(cx: &Context, expr: &Expr) -> bool {
|
|||
|iids| iids.iter().any(|i| is_is_empty(cx, i)))))
|
||||
}
|
||||
|
||||
let ty = &walk_ty(&expr_ty(cx.tcx, expr));
|
||||
let ty = &walk_ty(&cx.tcx.expr_ty(expr));
|
||||
match ty.sty {
|
||||
ty::TyTrait(_) => cx.tcx.trait_item_def_ids.borrow().get(
|
||||
&ty::ty_to_def_id(ty).expect("trait impl not found")).map_or(false,
|
||||
&ty.ty_to_def_id().expect("trait impl not found")).map_or(false,
|
||||
|ids| ids.iter().any(|i| is_is_empty(cx, i))),
|
||||
ty::TyProjection(_) => ty::ty_to_def_id(ty).map_or(false,
|
||||
ty::TyProjection(_) => ty.ty_to_def_id().map_or(false,
|
||||
|id| has_is_empty_impl(cx, &id)),
|
||||
ty::TyEnum(ref id, _) | ty::TyStruct(ref id, _) =>
|
||||
has_is_empty_impl(cx, id),
|
||||
|
|
|
@ -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};
|
||||
use rustc::middle::ty;
|
||||
use syntax::codemap::{Span, Spanned};
|
||||
|
||||
use types::span_note_and_lint;
|
||||
|
@ -79,7 +79,7 @@ impl LintPass for StrToStringPass {
|
|||
}
|
||||
|
||||
fn is_str(cx: &Context, expr: &ast::Expr) -> bool {
|
||||
match walk_ty(expr_ty(cx.tcx, expr)).sty {
|
||||
match walk_ty(cx.tcx.expr_ty(expr)).sty {
|
||||
ty::TyStr => true,
|
||||
_ => false
|
||||
}
|
||||
|
@ -167,7 +167,7 @@ impl LintPass for FloatCmp {
|
|||
}
|
||||
|
||||
fn is_float(cx: &Context, expr: &Expr) -> bool {
|
||||
if let ty::TyFloat(_) = walk_ty(expr_ty(cx.tcx, expr)).sty {
|
||||
if let ty::TyFloat(_) = walk_ty(cx.tcx.expr_ty(expr)).sty {
|
||||
true
|
||||
} else {
|
||||
false
|
||||
|
@ -268,5 +268,5 @@ 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::TyStr =
|
||||
walk_ty(expr_ty(cx.tcx, &*args[0])).sty { true } else { false }
|
||||
walk_ty(cx.tcx.expr_ty(&*args[0])).sty { true } else { false }
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use syntax::ptr::P;
|
||||
use syntax::ast::*;
|
||||
use rustc::lint::{Context, LintPass, LintArray, Lint};
|
||||
use rustc::middle::ty::{expr_ty, TypeVariants, mt, TyRef};
|
||||
use rustc::middle::ty::{TypeVariants, mt, TyRef};
|
||||
use syntax::codemap::{BytePos, ExpnInfo, Span};
|
||||
use utils::in_macro;
|
||||
|
||||
|
@ -43,7 +43,7 @@ fn check_expr_expd(cx: &Context, expr: &Expr, info: Option<&ExpnInfo>) {
|
|||
"Generally you want to avoid &mut &mut _ if possible.")
|
||||
}).unwrap_or_else(|| {
|
||||
if let TyRef(_, mt{ty: _, mutbl: MutMutable}) =
|
||||
expr_ty(cx.tcx, e).sty {
|
||||
cx.tcx.expr_ty(e).sty {
|
||||
cx.span_lint(MUT_MUT, expr.span,
|
||||
"This expression mutably borrows a mutable reference. \
|
||||
Consider reborrowing")
|
||||
|
|
|
@ -30,7 +30,7 @@ pub fn in_external_macro(cx: &Context, span: Span) -> bool {
|
|||
/// usage e.g. with
|
||||
/// `match_def_path(cx, id, &["core", "option", "Option"])`
|
||||
pub fn match_def_path(cx: &Context, def_id: DefId, path: &[&str]) -> bool {
|
||||
ty::with_path(cx.tcx, def_id, |iter| iter.map(|elem| elem.name())
|
||||
cx.tcx.with_path(def_id, |iter| iter.map(|elem| elem.name())
|
||||
.zip(path.iter()).all(|(nm, p)| &nm.as_str() == p))
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue