use rustc::hir::def_id::DefId;
use rustc::hir;
use rustc::lint::*;
+use rustc::{declare_lint, lint_array};
+use if_chain::if_chain;
use rustc::ty::{self, Ty};
use syntax::codemap::Span;
use crate::utils::paths;
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NewWithoutDefault {
fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx hir::Item) {
- if let hir::ItemImpl(_, _, _, _, None, _, ref items) = item.node {
+ if let hir::ItemKind::Impl(_, _, _, _, None, _, ref items) = item.node {
for assoc_item in items {
if let hir::AssociatedItemKind::Method { has_self: false } = assoc_item.kind {
let impl_item = cx.tcx.hir.impl_item(assoc_item.id);
return;
}
if let hir::ImplItemKind::Method(ref sig, _) = impl_item.node {
- let name = impl_item.name;
+ let name = impl_item.ident.name;
let id = impl_item.id;
- if sig.constness == hir::Constness::Const {
+ if sig.header.constness == hir::Constness::Const {
// can't be implemented by default
return;
}
- if impl_item.generics.params.iter().any(|gen| gen.is_type_param()) {
+ if impl_item.generics.params.iter().any(|gen| match gen.kind {
+ hir::GenericParamKind::Type { .. } => true,
+ _ => false
+ }) {
// when the result of `new()` depends on a type parameter we should not require
// an
// impl of `Default`