1 /// checks for attributes
3 use rustc::plugin::Registry;
7 use syntax::codemap::{Span, ExpnInfo};
8 use syntax::parse::token::InternedString;
11 declare_lint! { pub INLINE_ALWAYS, Warn,
12 "#[inline(always)] is usually a bad idea."}
18 impl LintPass for AttrPass {
19 fn get_lints(&self) -> LintArray {
20 lint_array!(INLINE_ALWAYS)
23 fn check_item(&mut self, cx: &Context, item: &Item) {
24 cx.sess().codemap().with_expn_info(item.span.expn_id,
25 |info| check_attrs(cx, info, &item.ident, &item.attrs))
28 fn check_impl_item(&mut self, cx: &Context, item: &ImplItem) {
29 cx.sess().codemap().with_expn_info(item.span.expn_id,
30 |info| check_attrs(cx, info, &item.ident, &item.attrs))
33 fn check_trait_item(&mut self, cx: &Context, item: &TraitItem) {
34 cx.sess().codemap().with_expn_info(item.span.expn_id,
35 |info| check_attrs(cx, info, &item.ident, &item.attrs))
39 fn check_attrs(cx: &Context, info: Option<&ExpnInfo>, ident: &Ident,
40 attrs: &[Attribute]) {
41 if in_macro(cx, info) { return; }
44 if let MetaList(ref inline, ref values) = attr.node.value.node {
45 if values.len() != 1 || inline != &"inline" { continue; }
46 if let MetaWord(ref always) = values[0].node {
47 if always != &"always" { continue; }
48 cx.span_lint(INLINE_ALWAYS, attr.span, &format!(
49 "You have declared #[inline(always)] on {}. This \
50 is usually a bad idea. Are you sure?",