Shrink ast::Attribute
.
This commit is contained in:
parent
86a0a18179
commit
6e5f90ae46
4 changed files with 9 additions and 9 deletions
|
@ -74,8 +74,8 @@ impl EarlyLintPass for CrateInMacroDef {
|
||||||
|
|
||||||
fn is_macro_export(attr: &Attribute) -> bool {
|
fn is_macro_export(attr: &Attribute) -> bool {
|
||||||
if_chain! {
|
if_chain! {
|
||||||
if let AttrKind::Normal(attr_item, _) = &attr.kind;
|
if let AttrKind::Normal(normal) = &attr.kind;
|
||||||
if let [segment] = attr_item.path.segments.as_slice();
|
if let [segment] = normal.item.path.segments.as_slice();
|
||||||
then {
|
then {
|
||||||
segment.ident.name == sym::macro_export
|
segment.ident.name == sym::macro_export
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -695,7 +695,7 @@ pub fn eq_attr(l: &Attribute, r: &Attribute) -> bool {
|
||||||
l.style == r.style
|
l.style == r.style
|
||||||
&& match (&l.kind, &r.kind) {
|
&& match (&l.kind, &r.kind) {
|
||||||
(DocComment(l1, l2), DocComment(r1, r2)) => l1 == r1 && l2 == r2,
|
(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,
|
_ => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,8 +59,8 @@ pub fn get_attr<'a>(
|
||||||
name: &'static str,
|
name: &'static str,
|
||||||
) -> impl Iterator<Item = &'a ast::Attribute> {
|
) -> impl Iterator<Item = &'a ast::Attribute> {
|
||||||
attrs.iter().filter(move |attr| {
|
attrs.iter().filter(move |attr| {
|
||||||
let attr = if let ast::AttrKind::Normal(ref attr, _) = attr.kind {
|
let attr = if let ast::AttrKind::Normal(ref normal) = attr.kind {
|
||||||
attr
|
&normal.item
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
|
@ -1893,8 +1893,8 @@ pub fn std_or_core(cx: &LateContext<'_>) -> Option<&'static str> {
|
||||||
|
|
||||||
pub fn is_no_std_crate(cx: &LateContext<'_>) -> bool {
|
pub fn is_no_std_crate(cx: &LateContext<'_>) -> bool {
|
||||||
cx.tcx.hir().attrs(hir::CRATE_HIR_ID).iter().any(|attr| {
|
cx.tcx.hir().attrs(hir::CRATE_HIR_ID).iter().any(|attr| {
|
||||||
if let ast::AttrKind::Normal(ref attr, _) = attr.kind {
|
if let ast::AttrKind::Normal(ref normal) = attr.kind {
|
||||||
attr.path == sym::no_std
|
normal.item.path == sym::no_std
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
@ -1903,8 +1903,8 @@ pub fn is_no_std_crate(cx: &LateContext<'_>) -> bool {
|
||||||
|
|
||||||
pub fn is_no_core_crate(cx: &LateContext<'_>) -> bool {
|
pub fn is_no_core_crate(cx: &LateContext<'_>) -> bool {
|
||||||
cx.tcx.hir().attrs(hir::CRATE_HIR_ID).iter().any(|attr| {
|
cx.tcx.hir().attrs(hir::CRATE_HIR_ID).iter().any(|attr| {
|
||||||
if let ast::AttrKind::Normal(ref attr, _) = attr.kind {
|
if let ast::AttrKind::Normal(ref normal) = attr.kind {
|
||||||
attr.path == sym::no_core
|
normal.item.path == sym::no_core
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue