mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-24 05:33:27 +00:00
Update for latest Rust
This is mainly due to https://github.com/rust-lang/rust/commit/dead08cb33134
This commit is contained in:
parent
6edab5662d
commit
8adc42b5b4
12 changed files with 32 additions and 32 deletions
|
@ -307,7 +307,7 @@ fn fetch_int_literal(cx: &LateContext, lit: &Expr) -> Option<u128> {
|
||||||
cx.tcx.mir_const_qualif(def_id);
|
cx.tcx.mir_const_qualif(def_id);
|
||||||
cx.tcx.hir.body(cx.tcx.hir.body_owned_by(id))
|
cx.tcx.hir.body(cx.tcx.hir.body_owned_by(id))
|
||||||
} else {
|
} else {
|
||||||
cx.tcx.sess.cstore.item_body(cx.tcx, def_id)
|
cx.tcx.extern_const_body(def_id)
|
||||||
};
|
};
|
||||||
fetch_int_literal(cx, &body.value)
|
fetch_int_literal(cx, &body.value)
|
||||||
})
|
})
|
||||||
|
|
|
@ -297,7 +297,7 @@ impl<'c, 'cc> ConstEvalLateContext<'c, 'cc> {
|
||||||
self.tcx.mir_const_qualif(def_id);
|
self.tcx.mir_const_qualif(def_id);
|
||||||
self.tcx.hir.body(self.tcx.hir.body_owned_by(id))
|
self.tcx.hir.body(self.tcx.hir.body_owned_by(id))
|
||||||
} else {
|
} else {
|
||||||
self.tcx.sess.cstore.item_body(self.tcx, def_id)
|
self.tcx.extern_const_body(def_id)
|
||||||
};
|
};
|
||||||
let ret = cx.expr(&body.value);
|
let ret = cx.expr(&body.value);
|
||||||
if ret.is_some() {
|
if ret.is_some() {
|
||||||
|
|
|
@ -93,7 +93,7 @@ fn check_hash_peq<'a, 'tcx>(
|
||||||
) {
|
) {
|
||||||
if_let_chain! {[
|
if_let_chain! {[
|
||||||
match_path(&trait_ref.path, &paths::HASH),
|
match_path(&trait_ref.path, &paths::HASH),
|
||||||
let Some(peq_trait_def_id) = cx.tcx.lang_items.eq_trait()
|
let Some(peq_trait_def_id) = cx.tcx.lang_items().eq_trait()
|
||||||
], {
|
], {
|
||||||
// Look for the PartialEq implementations for `ty`
|
// Look for the PartialEq implementations for `ty`
|
||||||
cx.tcx.for_each_relevant_impl(peq_trait_def_id, ty, |impl_id| {
|
cx.tcx.for_each_relevant_impl(peq_trait_def_id, ty, |impl_id| {
|
||||||
|
|
|
@ -63,20 +63,20 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EqOp {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let (trait_id, requires_ref) = match op.node {
|
let (trait_id, requires_ref) = match op.node {
|
||||||
BiAdd => (cx.tcx.lang_items.add_trait(), false),
|
BiAdd => (cx.tcx.lang_items().add_trait(), false),
|
||||||
BiSub => (cx.tcx.lang_items.sub_trait(), false),
|
BiSub => (cx.tcx.lang_items().sub_trait(), false),
|
||||||
BiMul => (cx.tcx.lang_items.mul_trait(), false),
|
BiMul => (cx.tcx.lang_items().mul_trait(), false),
|
||||||
BiDiv => (cx.tcx.lang_items.div_trait(), false),
|
BiDiv => (cx.tcx.lang_items().div_trait(), false),
|
||||||
BiRem => (cx.tcx.lang_items.rem_trait(), false),
|
BiRem => (cx.tcx.lang_items().rem_trait(), false),
|
||||||
// don't lint short circuiting ops
|
// don't lint short circuiting ops
|
||||||
BiAnd | BiOr => return,
|
BiAnd | BiOr => return,
|
||||||
BiBitXor => (cx.tcx.lang_items.bitxor_trait(), false),
|
BiBitXor => (cx.tcx.lang_items().bitxor_trait(), false),
|
||||||
BiBitAnd => (cx.tcx.lang_items.bitand_trait(), false),
|
BiBitAnd => (cx.tcx.lang_items().bitand_trait(), false),
|
||||||
BiBitOr => (cx.tcx.lang_items.bitor_trait(), false),
|
BiBitOr => (cx.tcx.lang_items().bitor_trait(), false),
|
||||||
BiShl => (cx.tcx.lang_items.shl_trait(), false),
|
BiShl => (cx.tcx.lang_items().shl_trait(), false),
|
||||||
BiShr => (cx.tcx.lang_items.shr_trait(), false),
|
BiShr => (cx.tcx.lang_items().shr_trait(), false),
|
||||||
BiNe | BiEq => (cx.tcx.lang_items.eq_trait(), true),
|
BiNe | BiEq => (cx.tcx.lang_items().eq_trait(), true),
|
||||||
BiLt | BiLe | BiGe | BiGt => (cx.tcx.lang_items.ord_trait(), true),
|
BiLt | BiLe | BiGe | BiGt => (cx.tcx.lang_items().ord_trait(), true),
|
||||||
};
|
};
|
||||||
if let Some(trait_id) = trait_id {
|
if let Some(trait_id) = trait_id {
|
||||||
#[allow(match_same_arms)]
|
#[allow(match_same_arms)]
|
||||||
|
|
|
@ -1302,7 +1302,7 @@ fn get_error_type<'a>(cx: &LateContext, ty: Ty<'a>) -> Option<Ty<'a>> {
|
||||||
|
|
||||||
/// This checks whether a given type is known to implement Debug.
|
/// This checks whether a given type is known to implement Debug.
|
||||||
fn has_debug_impl<'a, 'b>(ty: Ty<'a>, cx: &LateContext<'b, 'a>) -> bool {
|
fn has_debug_impl<'a, 'b>(ty: Ty<'a>, cx: &LateContext<'b, 'a>) -> bool {
|
||||||
match cx.tcx.lang_items.debug_trait() {
|
match cx.tcx.lang_items().debug_trait() {
|
||||||
Some(debug) => implements_trait(cx, ty, debug, &[]),
|
Some(debug) => implements_trait(cx, ty, debug, &[]),
|
||||||
None => false,
|
None => false,
|
||||||
}
|
}
|
||||||
|
|
|
@ -497,7 +497,7 @@ fn check_to_owned(cx: &LateContext, expr: &Expr, other: &Expr) {
|
||||||
};
|
};
|
||||||
|
|
||||||
let other_ty = cx.tables.expr_ty_adjusted(other);
|
let other_ty = cx.tables.expr_ty_adjusted(other);
|
||||||
let partial_eq_trait_id = match cx.tcx.lang_items.eq_trait() {
|
let partial_eq_trait_id = match cx.tcx.lang_items().eq_trait() {
|
||||||
Some(id) => id,
|
Some(id) => id,
|
||||||
None => return,
|
None => return,
|
||||||
};
|
};
|
||||||
|
|
|
@ -75,7 +75,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessPassByValue {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Allows these to be passed by value.
|
// Allows these to be passed by value.
|
||||||
let fn_trait = need!(cx.tcx.lang_items.fn_trait());
|
let fn_trait = need!(cx.tcx.lang_items().fn_trait());
|
||||||
let asref_trait = need!(get_trait_def_id(cx, &paths::ASREF_TRAIT));
|
let asref_trait = need!(get_trait_def_id(cx, &paths::ASREF_TRAIT));
|
||||||
let borrow_trait = need!(get_trait_def_id(cx, &paths::BORROW_TRAIT));
|
let borrow_trait = need!(get_trait_def_id(cx, &paths::BORROW_TRAIT));
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
|
||||||
if_let_chain! {[
|
if_let_chain! {[
|
||||||
let ItemImpl(_, _, _, _, Some(ref trait_ref), _, ref impl_items) = item.node,
|
let ItemImpl(_, _, _, _, Some(ref trait_ref), _, ref impl_items) = item.node,
|
||||||
!is_automatically_derived(&*item.attrs),
|
!is_automatically_derived(&*item.attrs),
|
||||||
let Some(eq_trait) = cx.tcx.lang_items.eq_trait(),
|
let Some(eq_trait) = cx.tcx.lang_items().eq_trait(),
|
||||||
trait_ref.path.def.def_id() == eq_trait
|
trait_ref.path.def.def_id() == eq_trait
|
||||||
], {
|
], {
|
||||||
for impl_item in impl_items {
|
for impl_item in impl_items {
|
||||||
|
|
|
@ -40,7 +40,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ShouldAssertEq {
|
||||||
let ExprUnary(UnOp::UnNot, ref cond) = cond.node,
|
let ExprUnary(UnOp::UnNot, ref cond) = cond.node,
|
||||||
let ExprBinary(ref binop, ref expr1, ref expr2) = cond.node,
|
let ExprBinary(ref binop, ref expr1, ref expr2) = cond.node,
|
||||||
is_direct_expn_of(e.span, "assert").is_some(),
|
is_direct_expn_of(e.span, "assert").is_some(),
|
||||||
let Some(debug_trait) = cx.tcx.lang_items.debug_trait(),
|
let Some(debug_trait) = cx.tcx.lang_items().debug_trait(),
|
||||||
], {
|
], {
|
||||||
let debug = is_expn_of(e.span, "debug_assert").map_or("", |_| "debug_");
|
let debug = is_expn_of(e.span, "debug_assert").map_or("", |_| "debug_");
|
||||||
let sugg = match binop.node {
|
let sugg = match binop.node {
|
||||||
|
|
|
@ -151,7 +151,7 @@ fn check_ty(cx: &LateContext, ast_ty: &hir::Ty, is_local: bool) {
|
||||||
let hir_id = cx.tcx.hir.node_to_hir_id(ast_ty.id);
|
let hir_id = cx.tcx.hir.node_to_hir_id(ast_ty.id);
|
||||||
let def = cx.tables.qpath_def(qpath, hir_id);
|
let def = cx.tables.qpath_def(qpath, hir_id);
|
||||||
if let Some(def_id) = opt_def_id(def) {
|
if let Some(def_id) = opt_def_id(def) {
|
||||||
if Some(def_id) == cx.tcx.lang_items.owned_box() {
|
if Some(def_id) == cx.tcx.lang_items().owned_box() {
|
||||||
let last = last_path_segment(qpath);
|
let last = last_path_segment(qpath);
|
||||||
if_let_chain! {[
|
if_let_chain! {[
|
||||||
!last.parameters.parenthesized,
|
!last.parameters.parenthesized,
|
||||||
|
@ -209,7 +209,7 @@ fn check_ty(cx: &LateContext, ast_ty: &hir::Ty, is_local: bool) {
|
||||||
let def = cx.tables.qpath_def(qpath, hir_id);
|
let def = cx.tables.qpath_def(qpath, hir_id);
|
||||||
if_let_chain! {[
|
if_let_chain! {[
|
||||||
let Some(def_id) = opt_def_id(def),
|
let Some(def_id) = opt_def_id(def),
|
||||||
Some(def_id) == cx.tcx.lang_items.owned_box(),
|
Some(def_id) == cx.tcx.lang_items().owned_box(),
|
||||||
let QPath::Resolved(None, ref path) = *qpath,
|
let QPath::Resolved(None, ref path) = *qpath,
|
||||||
let [ref bx] = *path.segments,
|
let [ref bx] = *path.segments,
|
||||||
!bx.parameters.parenthesized,
|
!bx.parameters.parenthesized,
|
||||||
|
|
|
@ -360,12 +360,12 @@ fn print_item(cx: &LateContext, item: &hir::Item) {
|
||||||
}
|
}
|
||||||
match item.node {
|
match item.node {
|
||||||
hir::ItemExternCrate(ref _renamed_from) => {
|
hir::ItemExternCrate(ref _renamed_from) => {
|
||||||
if let Some(crate_id) = cx.tcx.sess.cstore.extern_mod_stmt_cnum(item.id) {
|
if let Some(crate_id) = cx.tcx.extern_mod_stmt_cnum(cx.tcx.hir.node_to_hir_id(item.id)) {
|
||||||
let source = cx.tcx.sess.cstore.used_crate_source(crate_id);
|
let source = cx.tcx.used_crate_source(crate_id);
|
||||||
if let Some(src) = source.dylib {
|
if let Some(ref src) = source.dylib {
|
||||||
println!("extern crate dylib source: {:?}", src.0);
|
println!("extern crate dylib source: {:?}", src.0);
|
||||||
}
|
}
|
||||||
if let Some(src) = source.rlib {
|
if let Some(ref src) = source.rlib {
|
||||||
println!("extern crate rlib source: {:?}", src.0);
|
println!("extern crate rlib source: {:?}", src.0);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -15,6 +15,7 @@ use std::borrow::Cow;
|
||||||
use std::env;
|
use std::env;
|
||||||
use std::mem;
|
use std::mem;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
use std::rc::Rc;
|
||||||
use syntax::ast::{self, LitKind};
|
use syntax::ast::{self, LitKind};
|
||||||
use syntax::attr;
|
use syntax::attr;
|
||||||
use syntax::codemap::{CompilerDesugaringKind, ExpnFormat, ExpnInfo, Span, DUMMY_SP};
|
use syntax::codemap::{CompilerDesugaringKind, ExpnFormat, ExpnInfo, Span, DUMMY_SP};
|
||||||
|
@ -277,18 +278,17 @@ pub fn match_path_ast(path: &ast::Path, segments: &[&str]) -> bool {
|
||||||
|
|
||||||
/// Get the definition associated to a path.
|
/// Get the definition associated to a path.
|
||||||
pub fn path_to_def(cx: &LateContext, path: &[&str]) -> Option<def::Def> {
|
pub fn path_to_def(cx: &LateContext, path: &[&str]) -> Option<def::Def> {
|
||||||
let cstore = &cx.tcx.sess.cstore;
|
|
||||||
|
|
||||||
let crates = cstore.crates();
|
let crates = cx.tcx.crates();
|
||||||
let krate = crates
|
let krate = crates
|
||||||
.iter()
|
.iter()
|
||||||
.find(|&&krate| cstore.crate_name(krate) == path[0]);
|
.find(|&&krate| cx.tcx.crate_name(krate) == path[0]);
|
||||||
if let Some(krate) = krate {
|
if let Some(krate) = krate {
|
||||||
let krate = DefId {
|
let krate = DefId {
|
||||||
krate: *krate,
|
krate: *krate,
|
||||||
index: CRATE_DEF_INDEX,
|
index: CRATE_DEF_INDEX,
|
||||||
};
|
};
|
||||||
let mut items = cstore.item_children(krate, cx.tcx.sess);
|
let mut items = cx.tcx.item_children(krate);
|
||||||
let mut path_it = path.iter().skip(1).peekable();
|
let mut path_it = path.iter().skip(1).peekable();
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
|
@ -297,13 +297,13 @@ pub fn path_to_def(cx: &LateContext, path: &[&str]) -> Option<def::Def> {
|
||||||
None => return None,
|
None => return None,
|
||||||
};
|
};
|
||||||
|
|
||||||
for item in &mem::replace(&mut items, vec![]) {
|
for item in mem::replace(&mut items, Rc::new(vec![])).iter() {
|
||||||
if item.ident.name == *segment {
|
if item.ident.name == *segment {
|
||||||
if path_it.peek().is_none() {
|
if path_it.peek().is_none() {
|
||||||
return Some(item.def);
|
return Some(item.def);
|
||||||
}
|
}
|
||||||
|
|
||||||
items = cstore.item_children(item.def.def_id(), cx.tcx.sess);
|
items = cx.tcx.item_children(item.def.def_id());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue