Skip to content

Commit

Permalink
Shrink ast::Attribute.
Browse files Browse the repository at this point in the history
  • Loading branch information
nnethercote committed Aug 16, 2022
1 parent 86a0a18 commit 6e5f90a
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions clippy_lints/src/crate_in_macro_def.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ impl EarlyLintPass for CrateInMacroDef {

fn is_macro_export(attr: &Attribute) -> bool {
if_chain! {
if let AttrKind::Normal(attr_item, _) = &attr.kind;
if let [segment] = attr_item.path.segments.as_slice();
if let AttrKind::Normal(normal) = &attr.kind;
if let [segment] = normal.item.path.segments.as_slice();
then {
segment.ident.name == sym::macro_export
} else {
Expand Down
2 changes: 1 addition & 1 deletion clippy_utils/src/ast_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,7 @@ pub fn eq_attr(l: &Attribute, r: &Attribute) -> bool {
l.style == r.style
&& match (&l.kind, &r.kind) {
(DocComment(l1, l2), DocComment(r1, r2)) => l1 == r1 && l2 == r2,
(Normal(l, _), Normal(r, _)) => eq_path(&l.path, &r.path) && eq_mac_args(&l.args, &r.args),
(Normal(l), Normal(r)) => eq_path(&l.item.path, &r.item.path) && eq_mac_args(&l.item.args, &r.item.args),
_ => false,
}
}
Expand Down
4 changes: 2 additions & 2 deletions clippy_utils/src/attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ pub fn get_attr<'a>(
name: &'static str,
) -> impl Iterator<Item = &'a ast::Attribute> {
attrs.iter().filter(move |attr| {
let attr = if let ast::AttrKind::Normal(ref attr, _) = attr.kind {
attr
let attr = if let ast::AttrKind::Normal(ref normal) = attr.kind {
&normal.item
} else {
return false;
};
Expand Down
8 changes: 4 additions & 4 deletions clippy_utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1893,8 +1893,8 @@ pub fn std_or_core(cx: &LateContext<'_>) -> Option<&'static str> {

pub fn is_no_std_crate(cx: &LateContext<'_>) -> bool {
cx.tcx.hir().attrs(hir::CRATE_HIR_ID).iter().any(|attr| {
if let ast::AttrKind::Normal(ref attr, _) = attr.kind {
attr.path == sym::no_std
if let ast::AttrKind::Normal(ref normal) = attr.kind {
normal.item.path == sym::no_std
} else {
false
}
Expand All @@ -1903,8 +1903,8 @@ pub fn is_no_std_crate(cx: &LateContext<'_>) -> bool {

pub fn is_no_core_crate(cx: &LateContext<'_>) -> bool {
cx.tcx.hir().attrs(hir::CRATE_HIR_ID).iter().any(|attr| {
if let ast::AttrKind::Normal(ref attr, _) = attr.kind {
attr.path == sym::no_core
if let ast::AttrKind::Normal(ref normal) = attr.kind {
normal.item.path == sym::no_core
} else {
false
}
Expand Down

0 comments on commit 6e5f90a

Please sign in to comment.