Replace stray println!() in lint code by bug!() (#14618)

To avoid crashing Clippy, the `bug!()` is used only when debug
assertions are enabled. In regular usage, the result will be the same as
before, but without the extra line printed on the standard output which
has the potential for disrupting shell scripts.

changelog: none
This commit is contained in:
Alejandra González 2025-04-16 00:13:31 +00:00 committed by GitHub
commit 08c78e0095
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -382,7 +382,9 @@ impl<'tcx> LateLintPass<'tcx> for ArbitrarySourceItemOrdering {
// Filters the auto-included Rust standard library.
continue;
}
println!("Unknown item: {item:?}");
if cfg!(debug_assertions) {
rustc_middle::bug!("unknown item: {item:?}");
}
}
} else if let ItemKind::Impl(_) = item.kind
&& get_item_name(item).is_some()