use rustc::lint::*;
+use rustc::{declare_lint, lint_array};
+use if_chain::if_chain;
use rustc::ty::{self, Ty};
use rustc::hir::*;
use syntax::codemap::Span;
-use utils::paths;
-use utils::{is_automatically_derived, is_copy, match_path, span_lint_and_then};
+use crate::utils::paths;
+use crate::utils::{is_automatically_derived, is_copy, match_path, span_lint_and_then};
/// **What it does:** Checks for deriving `Hash` but implementing `PartialEq`
-/// explicitly.
+/// explicitly or vice versa.
///
/// **Why is this bad?** The implementation of these traits must agree (for
/// example for use with `HashMap`) so it’s probably a bad idea to use a
/// ...
/// }
/// ```
-declare_lint! {
+declare_clippy_lint! {
pub DERIVE_HASH_XOR_EQ,
- Warn,
+ correctness,
"deriving `Hash` but implementing `PartialEq` explicitly"
}
/// nothing more than copy the object, which is what `#[derive(Copy, Clone)]`
/// gets you.
///
-/// **Known problems:** None.
+/// **Known problems:** Bounds of generic types are sometimes wrong: https://github.com/rust-lang/rust/issues/26925
///
/// **Example:**
/// ```rust
/// ..
/// }
/// ```
-declare_lint! {
+declare_clippy_lint! {
pub EXPL_IMPL_CLONE_ON_COPY,
- Warn,
+ pedantic,
"implementing `Clone` explicitly on `Copy` types"
}
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Derive {
fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item) {
- if let ItemImpl(_, _, _, _, Some(ref trait_ref), _, _) = item.node {
+ if let ItemKind::Impl(_, _, _, _, Some(ref trait_ref), _, _) = item.node {
let ty = cx.tcx.type_of(cx.tcx.hir.local_def_id(item.id));
let is_automatically_derived = is_automatically_derived(&*item.attrs);
}
}
for subst in substs {
- if let Some(subst) = subst.as_type() {
+ if let ty::subst::UnpackedKind::Type(subst) = subst.unpack() {
if let ty::TyParam(_) = subst.sty {
return;
}