diff options
| author | Alejandra González <blyxyas@gmail.com> | 2025-04-16 00:13:31 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-04-16 00:13:31 +0000 |
| commit | 08c78e00951715570546eb182f65bc535a470bf9 (patch) | |
| tree | cb5997962cfb38a481525fc3c0f39505d16e4e01 | |
| parent | 9663da39d2aee8ae68d06de75ae122ea27d88281 (diff) | |
| parent | e0c8b4bf53d9665a36d951af74706ae7488c4b19 (diff) | |
| download | rust-08c78e00951715570546eb182f65bc535a470bf9.tar.gz rust-08c78e00951715570546eb182f65bc535a470bf9.zip | |
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
| -rw-r--r-- | clippy_lints/src/arbitrary_source_item_ordering.rs | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/clippy_lints/src/arbitrary_source_item_ordering.rs b/clippy_lints/src/arbitrary_source_item_ordering.rs index 8e261b9a882..272444475c0 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() |
