return false;
}
- let list = match attr.meta_item_list() {
- None => return false,
- Some(it) => it,
+ let Some(list) = attr.meta_item_list() else {
+ return false;
};
if matches!(&list[..], &[NestedMetaItem::Literal(Lit { kind: LitKind::Int(..), .. })]) {
return false;
}
- let list = match attr.meta_item_list() {
+ let Some(list) = attr.meta_item_list() else {
// The attribute form is validated on AST.
- None => return false,
- Some(it) => it,
+ return false;
};
- let (decl, generics) = match item {
- Some(ItemLike::Item(Item {
- kind: ItemKind::Fn(FnSig { decl, .. }, generics, _),
- ..
- })) => (decl, generics),
- _ => bug!("should be a function item"),
+ let Some(ItemLike::Item(Item {
+ kind: ItemKind::Fn(FnSig { decl, .. }, generics, _),
+ ..
+ })) = item else {
+ bug!("should be a function item");
};
for param in generics.params {
fn check_used(&self, attrs: &[Attribute], target: Target) {
let mut used_linker_span = None;
let mut used_compiler_span = None;
- for attr in attrs {
- if attr.has_name(sym::used) && target != Target::Static {
+ for attr in attrs.iter().filter(|attr| attr.has_name(sym::used)) {
+ if target != Target::Static {
self.tcx
.sess
.span_err(attr.span, "attribute must be applied to a `static` variable");
// Historically we've run more checks on non-exported than exported macros,
// so this lets us continue to run them while maintaining backwards compatibility.
// In the long run, the checks should be harmonized.
- if let ItemKind::Macro(ref macro_def) = item.kind {
+ if let ItemKind::Macro(ref macro_def, _) = item.kind {
let def_id = item.def_id.to_def_id();
if macro_def.macro_rules && !self.tcx.has_attr(def_id, sym::macro_export) {
check_non_exported_macro_for_invalid_attrs(self.tcx, item);
rustc_errors::Applicability::MachineApplicable,
);
}
- err.emit()
+ err.emit();
}
}
}