diff options
| author | Nicholas Nethercote <n.nethercote@gmail.com> | 2025-04-10 16:41:43 +1000 |
|---|---|---|
| committer | Nicholas Nethercote <n.nethercote@gmail.com> | 2025-04-10 16:49:18 +1000 |
| commit | 3690f3b37f37873c27dbea91eba7932c1acc49d9 (patch) | |
| tree | 943f8c67be2ef5a6483c0a0940e23532c02190e7 | |
| parent | 822b9316524f2387f804de5bed164abafb32f35a (diff) | |
| download | rust-3690f3b37f37873c27dbea91eba7932c1acc49d9.tar.gz rust-3690f3b37f37873c27dbea91eba7932c1acc49d9.zip | |
Avoid an `Ident::empty` usage.
By moving a couple of identifier checks earlier, we no longer need to use an empty identifier for the `impl` case. changelog: none
| -rw-r--r-- | clippy_lints/src/arbitrary_source_item_ordering.rs | 32 |
1 files changed, 15 insertions, 17 deletions
diff --git a/clippy_lints/src/arbitrary_source_item_ordering.rs b/clippy_lints/src/arbitrary_source_item_ordering.rs index 4111fd10c13..f64dbde9755 100644 --- a/clippy_lints/src/arbitrary_source_item_ordering.rs +++ b/clippy_lints/src/arbitrary_source_item_ordering.rs @@ -365,28 +365,26 @@ impl<'tcx> LateLintPass<'tcx> for ArbitrarySourceItemOrdering { continue; } - let ident = if let Some(ident) = item.kind.ident() { - ident + if let Some(ident) = item.kind.ident() { + if ident.name.as_str().starts_with('_') { + // Filters out unnamed macro-like impls for various derives, + // e.g. serde::Serialize or num_derive::FromPrimitive. + continue; + } + + if ident.name == rustc_span::sym::std && item.span.is_dummy() { + if let ItemKind::ExternCrate(None, _) = item.kind { + // Filters the auto-included Rust standard library. + continue; + } + println!("Unknown item: {item:?}"); + } } else if let ItemKind::Impl(_) = item.kind && get_item_name(item).is_some() { - rustc_span::Ident::empty() // FIXME: a bit strange, is there a better way to do it? + // keep going below } else { continue; - }; - - if ident.name.as_str().starts_with('_') { - // Filters out unnamed macro-like impls for various derives, - // e.g. serde::Serialize or num_derive::FromPrimitive. - continue; - } - - if ident.name == rustc_span::sym::std && item.span.is_dummy() { - if let ItemKind::ExternCrate(None, _) = item.kind { - // Filters the auto-included Rust standard library. - continue; - } - println!("Unknown item: {item:?}"); } let item_kind = convert_module_item_kind(&item.kind); |
