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
@@ -382,7 +382,9 @@ struct CurItem<'a> {
// 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()