factor out is_automatically_derived util fn

This commit is contained in:
Sebastian Ullrich
2016-10-29 21:13:41 -04:00
parent 8630376e71
commit 90f71be4e9
3 changed files with 12 additions and 18 deletions

View File

@@ -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")
}