1
Fork 0
This commit is contained in:
Oliver Schneider 2017-04-28 13:00:42 +02:00
parent 52dec9d20b
commit b8d577d82d
11 changed files with 12 additions and 12 deletions

View file

@ -149,7 +149,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AssignOps {
if_let_chain!{[ if_let_chain!{[
parent_impl != ast::CRATE_NODE_ID, parent_impl != ast::CRATE_NODE_ID,
let hir::map::Node::NodeItem(item) = cx.tcx.hir.get(parent_impl), let hir::map::Node::NodeItem(item) = cx.tcx.hir.get(parent_impl),
let hir::Item_::ItemImpl(_, _, _, Some(ref trait_ref), _, _) = item.node, let hir::Item_::ItemImpl(_, _, _, _, Some(ref trait_ref), _, _) = item.node,
trait_ref.path.def.def_id() == trait_id trait_ref.path.def.def_id() == trait_id
], { return; }} ], { return; }}
implements_trait($cx, $ty, trait_id, &[$rty], None) implements_trait($cx, $ty, trait_id, &[$rty], None)

View file

@ -72,7 +72,7 @@ impl LintPass for Derive {
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Derive { impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Derive {
fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item) { fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item) {
if let ItemImpl(_, _, _, Some(ref trait_ref), _, _) = item.node { if let ItemImpl(_, _, _, _, Some(ref trait_ref), _, _) = item.node {
let ty = cx.tcx.type_of(cx.tcx.hir.local_def_id(item.id)); let ty = cx.tcx.type_of(cx.tcx.hir.local_def_id(item.id));
let is_automatically_derived = is_automatically_derived(&*item.attrs); let is_automatically_derived = is_automatically_derived(&*item.attrs);

View file

@ -81,7 +81,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Functions {
use rustc::hir::map::Node::*; use rustc::hir::map::Node::*;
let is_impl = if let Some(NodeItem(item)) = cx.tcx.hir.find(cx.tcx.hir.get_parent_node(nodeid)) { let is_impl = if let Some(NodeItem(item)) = cx.tcx.hir.find(cx.tcx.hir.get_parent_node(nodeid)) {
matches!(item.node, hir::ItemImpl(_, _, _, Some(_), _, _) | hir::ItemDefaultImpl(..)) matches!(item.node, hir::ItemImpl(_, _, _, _, Some(_), _, _) | hir::ItemDefaultImpl(..))
} else { } else {
false false
}; };

View file

@ -67,7 +67,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LenZero {
match item.node { match item.node {
ItemTrait(_, _, _, ref trait_items) => check_trait_items(cx, item, trait_items), ItemTrait(_, _, _, ref trait_items) => check_trait_items(cx, item, trait_items),
ItemImpl(_, _, _, None, _, ref impl_items) => check_impl_items(cx, item, impl_items), ItemImpl(_, _, _, _, None, _, ref impl_items) => check_impl_items(cx, item, impl_items),
_ => (), _ => (),
} }
} }

View file

@ -642,7 +642,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
let hir::ImplItemKind::Method(ref sig, id) = implitem.node, let hir::ImplItemKind::Method(ref sig, id) = implitem.node,
let Some(first_arg_ty) = sig.decl.inputs.get(0), let Some(first_arg_ty) = sig.decl.inputs.get(0),
let Some(first_arg) = iter_input_pats(&sig.decl, cx.tcx.hir.body(id)).next(), let Some(first_arg) = iter_input_pats(&sig.decl, cx.tcx.hir.body(id)).next(),
let hir::ItemImpl(_, _, _, None, ref self_ty, _) = item.node, let hir::ItemImpl(_, _, _, _, None, ref self_ty, _) = item.node,
], { ], {
// check missing trait implementations // check missing trait implementations
for &(method_name, n_args, self_kind, out_type, trait_name) in &TRAIT_METHODS { for &(method_name, n_args, self_kind, out_type, trait_name) in &TRAIT_METHODS {

View file

@ -38,7 +38,7 @@ impl LintPass for Pass {
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass { impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item) { fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item) {
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

View file

@ -141,7 +141,7 @@ fn is_in_debug_impl(cx: &LateContext, expr: &Expr) -> bool {
if let Some(NodeImplItem(item)) = map.find(map.get_parent(expr.id)) { if let Some(NodeImplItem(item)) = map.find(map.get_parent(expr.id)) {
// `Debug` impl // `Debug` impl
if let Some(NodeItem(item)) = map.find(map.get_parent(item.id)) { if let Some(NodeItem(item)) = map.find(map.get_parent(item.id)) {
if let ItemImpl(_, _, _, Some(ref tr), _, _) = item.node { if let ItemImpl(_, _, _, _, Some(ref tr), _, _) = item.node {
return match_path_old(&tr.path, &["Debug"]); return match_path_old(&tr.path, &["Debug"]);
} }
} }

View file

@ -85,7 +85,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for PointerPass {
fn check_impl_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx ImplItem) { fn check_impl_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx ImplItem) {
if let ImplItemKind::Method(ref sig, _) = item.node { if let ImplItemKind::Method(ref sig, _) = item.node {
if let Some(NodeItem(it)) = cx.tcx.hir.find(cx.tcx.hir.get_parent(item.id)) { if let Some(NodeItem(it)) = cx.tcx.hir.find(cx.tcx.hir.get_parent(item.id)) {
if let ItemImpl(_, _, _, Some(_), _, _) = it.node { if let ItemImpl(_, _, _, _, Some(_), _, _) = it.node {
return; // ignore trait impls return; // ignore trait impls
} }
} }

View file

@ -28,7 +28,7 @@ impl LintPass for Serde {
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Serde { impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Serde {
fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item) { fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item) {
if let ItemImpl(_, _, _, Some(ref trait_ref), _, ref items) = item.node { if let ItemImpl(_, _, _, _, Some(ref trait_ref), _, ref items) = item.node {
let did = trait_ref.path.def.def_id(); let did = trait_ref.path.def.def_id();
if let Some(visit_did) = get_trait_def_id(cx, &paths::SERDE_DE_VISITOR) { if let Some(visit_did) = get_trait_def_id(cx, &paths::SERDE_DE_VISITOR) {
if did == visit_did { if did == visit_did {

View file

@ -74,7 +74,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypePass {
fn check_fn(&mut self, cx: &LateContext, _: FnKind, decl: &FnDecl, _: &Body, _: Span, id: NodeId) { fn check_fn(&mut self, cx: &LateContext, _: FnKind, decl: &FnDecl, _: &Body, _: Span, id: NodeId) {
// skip trait implementations, see #605 // skip trait implementations, see #605
if let Some(map::NodeItem(item)) = cx.tcx.hir.find(cx.tcx.hir.get_parent(id)) { if let Some(map::NodeItem(item)) = cx.tcx.hir.find(cx.tcx.hir.get_parent(id)) {
if let ItemImpl(_, _, _, Some(..), _, _) = item.node { if let ItemImpl(_, _, _, _, Some(..), _, _) = item.node {
return; return;
} }
} }

View file

@ -396,10 +396,10 @@ fn print_item(cx: &LateContext, item: &hir::Item) {
hir::ItemDefaultImpl(_, ref _trait_ref) => { hir::ItemDefaultImpl(_, ref _trait_ref) => {
println!("default impl"); println!("default impl");
}, },
hir::ItemImpl(_, _, _, Some(ref _trait_ref), _, _) => { hir::ItemImpl(_, _, _, _, Some(ref _trait_ref), _, _) => {
println!("trait impl"); println!("trait impl");
}, },
hir::ItemImpl(_, _, _, None, _, _) => { hir::ItemImpl(_, _, _, _, None, _, _) => {
println!("impl"); println!("impl");
}, },
} }