+use matches::matches;
use rustc::hir;
use rustc::lint::*;
+use rustc::{declare_lint, lint_array};
+use if_chain::if_chain;
use rustc::ty::{self, Ty};
use rustc::hir::def::Def;
use std::borrow::Cow;
if let hir::ImplItemKind::Method(ref sig, id) = implitem.node;
if let Some(first_arg_ty) = sig.decl.inputs.get(0);
if let Some(first_arg) = iter_input_pats(&sig.decl, cx.tcx.hir.body(id)).next();
- if let hir::ItemImpl(_, _, _, _, None, ref self_ty, _) = item.node;
+ if let hir::ItemKind::Impl(_, _, _, _, None, ref self_ty, _) = item.node;
then {
if cx.access_levels.is_exported(implitem.id) {
// check missing trait implementations
_ => {},
}
hir::map::NodeStmt(stmt) => {
- if let hir::StmtDecl(ref decl, _) = stmt.node {
- if let hir::DeclLocal(ref loc) = decl.node {
+ if let hir::StmtKind::Decl(ref decl, _) = stmt.node {
+ if let hir::DeclKind::Local(ref loc) = decl.node {
if let hir::PatKind::Ref(..) = loc.pat.node {
// let ref y = *x borrows x, let ref y = x.clone() does not
return;
cx, fold_args, hir::BinOpKind::And, "all", true
),
ast::LitKind::Int(0, _) => check_fold_with_op(
- cx, fold_args, hir::BinOpKindAdd, "sum", false
+ cx, fold_args, hir::BinOpKind::Add, "sum", false
),
ast::LitKind::Int(1, _) => check_fold_with_op(
cx, fold_args, hir::BinOpKind::Mul, "product", false
return true;
}
match ty.node {
- hir::TyRptr(_, ref mt_ty) => {
+ hir::TyKind::Rptr(_, ref mt_ty) => {
let mutability_match = if self == SelfKind::Ref {
mt_ty.mutbl == hir::MutImmutable
} else {
fn is_ty(ty: &hir::Ty, self_ty: &hir::Ty) -> bool {
match (&ty.node, &self_ty.node) {
(
- &hir::TyPath(hir::QPath::Resolved(_, ref ty_path)),
- &hir::TyPath(hir::QPath::Resolved(_, ref self_ty_path)),
+ &hir::TyKind::Path(hir::QPath::Resolved(_, ref ty_path)),
+ &hir::TyKind::Path(hir::QPath::Resolved(_, ref self_ty_path)),
) => ty_path
.segments
.iter()
}
fn single_segment_ty(ty: &hir::Ty) -> Option<&hir::PathSegment> {
- if let hir::TyPath(ref path) = ty.node {
+ if let hir::TyKind::Path(ref path) = ty.node {
single_segment_path(path)
} else {
None
impl OutType {
fn matches(self, cx: &LateContext, ty: &hir::FunctionRetTy) -> bool {
- let is_unit = |ty: &hir::Ty| SpanlessEq::new(cx).eq_ty_kind(&ty.node, &hir::TyTup(vec![].into()));
+ let is_unit = |ty: &hir::Ty| SpanlessEq::new(cx).eq_ty_kind(&ty.node, &hir::TyKind::Tup(vec![].into()));
match (self, ty) {
(OutType::Unit, &hir::DefaultReturn(_)) => true,
(OutType::Unit, &hir::Return(ref ty)) if is_unit(ty) => true,
(OutType::Bool, &hir::Return(ref ty)) if is_bool(ty) => true,
(OutType::Any, &hir::Return(ref ty)) if !is_unit(ty) => true,
- (OutType::Ref, &hir::Return(ref ty)) => matches!(ty.node, hir::TyRptr(_, _)),
+ (OutType::Ref, &hir::Return(ref ty)) => matches!(ty.node, hir::TyKind::Rptr(_, _)),
_ => false,
}
}
}
fn is_bool(ty: &hir::Ty) -> bool {
- if let hir::TyPath(ref p) = ty.node {
+ if let hir::TyKind::Path(ref p) = ty.node {
match_qpath(p, &["bool"])
} else {
false