factor out is_automatically_derived util fn
This commit is contained in:
@@ -4,7 +4,8 @@
|
||||
|
||||
use rustc::lint::*;
|
||||
use rustc::hir;
|
||||
use syntax::ast::{Attribute, MetaItemKind};
|
||||
use syntax::ast::Attribute;
|
||||
use syntax::attr;
|
||||
|
||||
/// **What it does:** Dumps every ast/hir node which has the `#[clippy_dump]` attribute
|
||||
///
|
||||
@@ -128,10 +129,7 @@ impl LateLintPass for Pass {
|
||||
}
|
||||
|
||||
fn has_attr(attrs: &[Attribute]) -> bool {
|
||||
attrs.iter().any(|attr| match attr.node.value.node {
|
||||
MetaItemKind::Word(ref word) => word == "clippy_dump",
|
||||
_ => false,
|
||||
})
|
||||
attr::contains_name(attrs, "clippy_dump")
|
||||
}
|
||||
|
||||
fn print_decl(cx: &LateContext, decl: &hir::Decl) {
|
||||
|
||||
@@ -14,6 +14,7 @@ use std::env;
|
||||
use std::mem;
|
||||
use std::str::FromStr;
|
||||
use syntax::ast::{self, LitKind};
|
||||
use syntax::attr;
|
||||
use syntax::codemap::{ExpnFormat, ExpnInfo, MultiSpan, Span, DUMMY_SP};
|
||||
use syntax::errors::DiagnosticBuilder;
|
||||
use syntax::ptr::P;
|
||||
@@ -761,3 +762,8 @@ pub fn is_refutable(cx: &LateContext, pat: &Pat) -> bool {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Checks for the `#[automatically_derived]` attribute all `#[derive]`d implementations have.
|
||||
pub fn is_automatically_derived(attrs: &[ast::Attribute]) -> bool {
|
||||
attr::contains_name(attrs, "automatically_derived")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user