diff --git a/clippy_lints/src/attrs.rs b/clippy_lints/src/attrs.rs index 2324693cd..06df8504d 100644 --- a/clippy_lints/src/attrs.rs +++ b/clippy_lints/src/attrs.rs @@ -15,7 +15,7 @@ use rustc::ty; use rustc::{declare_lint_pass, declare_tool_lint}; use rustc_errors::Applicability; use semver::Version; -use syntax::ast::{AttrStyle, Attribute, Lit, LitKind, MetaItemKind, NestedMetaItem}; +use syntax::ast::{AttrKind, AttrStyle, Attribute, Lit, LitKind, MetaItemKind, NestedMetaItem}; use syntax::source_map::Span; use syntax_pos::symbol::Symbol; @@ -417,11 +417,14 @@ fn check_attrs(cx: &LateContext<'_, '_>, span: Span, name: Name, attrs: &[Attrib } for attr in attrs { - if attr.is_sugared_doc { - return; - } + let attr_item = if let AttrKind::Normal(ref attr) = attr.kind { + attr + } else { + continue; + }; + if attr.style == AttrStyle::Outer { - if attr.tokens.is_empty() || !is_present_in_source(cx, attr.span) { + if attr_item.tokens.is_empty() || !is_present_in_source(cx, attr.span) { return; } diff --git a/clippy_lints/src/doc.rs b/clippy_lints/src/doc.rs index 726a044f9..aca4d1767 100644 --- a/clippy_lints/src/doc.rs +++ b/clippy_lints/src/doc.rs @@ -6,7 +6,7 @@ use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; use rustc::{declare_tool_lint, impl_lint_pass}; use rustc_data_structures::fx::FxHashSet; use std::ops::Range; -use syntax::ast::Attribute; +use syntax::ast::{AttrKind, Attribute}; use syntax::source_map::{BytePos, Span}; use syntax_pos::Pos; use url::Url; @@ -247,13 +247,11 @@ pub fn check_attrs<'a>(cx: &LateContext<'_, '_>, valid_idents: &FxHashSet [MAIN_RECURSION]); impl LateLintPass<'_, '_> for MainRecursion { fn check_crate(&mut self, _: &LateContext<'_, '_>, krate: &Crate) { - self.has_no_std_attr = krate.attrs.iter().any(|attr| attr.path == sym::no_std); + self.has_no_std_attr = krate.attrs.iter().any(|attr| { + if let AttrKind::Normal(ref attr) = attr.kind { + attr.path == sym::no_std + } else { + false + } + }); } fn check_expr_post(&mut self, cx: &LateContext<'_, '_>, expr: &Expr) { diff --git a/clippy_lints/src/utils/attrs.rs b/clippy_lints/src/utils/attrs.rs index 2520f366b..19dbae2ea 100644 --- a/clippy_lints/src/utils/attrs.rs +++ b/clippy_lints/src/utils/attrs.rs @@ -57,6 +57,11 @@ pub fn get_attr<'a>( name: &'static str, ) -> impl Iterator { attrs.iter().filter(move |attr| { + let attr = if let ast::AttrKind::Normal(ref attr) = attr.kind { + attr + } else { + return false; + }; let attr_segments = &attr.path.segments; if attr_segments.len() == 2 && attr_segments[0].ident.to_string() == "clippy" { if let Some(deprecation_status) =