From e0c8b4bf53d9665a36d951af74706ae7488c4b19 Mon Sep 17 00:00:00 2001 From: Samuel Tardieu Date: Tue, 15 Apr 2025 19:38:20 +0200 Subject: [PATCH] Replace stray `println!()` in lint code by `bug!()` 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. --- clippy_lints/src/arbitrary_source_item_ordering.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/clippy_lints/src/arbitrary_source_item_ordering.rs b/clippy_lints/src/arbitrary_source_item_ordering.rs index 8e261b9a882d..272444475c0c 100644 --- a/clippy_lints/src/arbitrary_source_item_ordering.rs +++ b/clippy_lints/src/arbitrary_source_item_ordering.rs @@ -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()