Skip to content

Commit 3690f3b

Browse files
committed
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
1 parent 822b931 commit 3690f3b

File tree

1 file changed

+15
-17
lines changed

1 file changed

+15
-17
lines changed

Diff for: clippy_lints/src/arbitrary_source_item_ordering.rs

+15-17
Original file line numberDiff line numberDiff line change
@@ -365,28 +365,26 @@ impl<'tcx> LateLintPass<'tcx> for ArbitrarySourceItemOrdering {
365365
continue;
366366
}
367367

368-
let ident = if let Some(ident) = item.kind.ident() {
369-
ident
368+
if let Some(ident) = item.kind.ident() {
369+
if ident.name.as_str().starts_with('_') {
370+
// Filters out unnamed macro-like impls for various derives,
371+
// e.g. serde::Serialize or num_derive::FromPrimitive.
372+
continue;
373+
}
374+
375+
if ident.name == rustc_span::sym::std && item.span.is_dummy() {
376+
if let ItemKind::ExternCrate(None, _) = item.kind {
377+
// Filters the auto-included Rust standard library.
378+
continue;
379+
}
380+
println!("Unknown item: {item:?}");
381+
}
370382
} else if let ItemKind::Impl(_) = item.kind
371383
&& get_item_name(item).is_some()
372384
{
373-
rustc_span::Ident::empty() // FIXME: a bit strange, is there a better way to do it?
385+
// keep going below
374386
} else {
375387
continue;
376-
};
377-
378-
if ident.name.as_str().starts_with('_') {
379-
// Filters out unnamed macro-like impls for various derives,
380-
// e.g. serde::Serialize or num_derive::FromPrimitive.
381-
continue;
382-
}
383-
384-
if ident.name == rustc_span::sym::std && item.span.is_dummy() {
385-
if let ItemKind::ExternCrate(None, _) = item.kind {
386-
// Filters the auto-included Rust standard library.
387-
continue;
388-
}
389-
println!("Unknown item: {item:?}");
390388
}
391389

392390
let item_kind = convert_module_item_kind(&item.kind);

0 commit comments

Comments
 (0)