clippy: 33 deny lints + fix 2735 violations across workspace#31116
Merged
Conversation
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds 45 deny-level clippy lints +
dead_code/unused_*/unreachable_*to[workspace.lints], aclippy.tomlroutingstd::{fs,sync,collections,process,env}andprintln!/eprintln!throughbun_*wrappers, and fixes the resulting violations across the workspace. Net −6.2K LOC of dead code.Lint set
Soundness / leak prevention —
undocumented_unsafe_blocks,not_unsafe_ptr_arg_deref,mem_forget,cast_ptr_alignment,transmute_ptr_to_ptr,as_ptr_cast_mut,drop_non_drop,uninit_vecPerformance —
redundant_clone,unnecessary_to_owned,needless_collect,or_fun_call,assigning_clones,implicit_clone,iter_overeager_cloned,map_clone,trivially_copy_pass_by_ref,large_types_passed_by_value,large_enum_variant,large_stack_frames,vec_init_then_push,format_collect,manual_memcpy,needless_pass_by_valueClarity —
unnecessary_unwrap,derive_partial_eq_without_eq,derivable_impls,clone_on_ref_ptr,if_same_then_else,todo,unimplemented,dbg_macro,clone_on_copy,useless_conversion,manual_swap,mem_replace_option_with_none,redundant_locals,manual_c_str_literals,precedence,implicit_saturating_sub,ptr_eqDisallowed —
disallowed_{methods,types,macros}configured inclippy.toml:std::sync::{Mutex,RwLock}+parking_lot::*→bun_threading;std::fs::*→bun_sys;std::collections::Hash{Map,Set}→bun_collections(wyhash);std::process::Command→bun_sys::process;println!/eprintln!→bun_core::output;std::env::var→bun_core::env;std::thread::spawn→bun_threading;std::mem::zeroedbanned.rustc —
dead_code,unused_imports,unused_variables,unused_mut,unused_assignments,unused_macros,unreachable_code,unreachable_patternsdenied workspace-wide. ~505 inline#[allow(unused/dead_code/unreachable_*)]attrs and ~90 crate-level#![allow(unused, ...)]words removed; the items they were hiding deleted or#[cfg]'d to the platform/profile they're live on.31 default-warn lints explicitly
allow'd (Zig-port style).Notable fixes
// SAFETY:comments added immediately aboveunsafe {blocks, each stating the actual invariant.not_unsafe_ptr_arg_deref: safefn(p: *mut T)that derefp→unsafe fnwith# Safetydoc, or param changed toNonNull<T>/&T.generate-host-exports.tsalready detectedpub unsafe fnand wraps the thunk body — regenerated.mem_forget→ManuallyDrop/Box::into_raw/Arc::into_raw/Box::leak.enum_map!(8 sites) replaced withEnumMap::from_fn.trivially_copy_pass_by_ref+needless_pass_by_value+large_types_passed_by_value):&Copy→Copy, owned-but-only-read →&T. All callers updated.protocol::IsCompatible+calc_protocol_forwarders!:Browsers→&Browsers.SinkHandler/JsSinkType/impl_sink_handler!/VTable:data: StreamResult→&StreamResult.ParserLike::log(&self) -> &mut Log(mut_from_ref): replaced trait method withlog_ptr(&self) -> NonNull<Log>.tick_while_paused:&mut bool→*const bool+read_volatile()— C++ writes through an aliased pointer duringtick(), so&mutwas an aliasing violation, not just a lint.flush_category!(css border): 152KB stack frame →#[inline(never)]helpers.cppbind.ts:&x as *const T→core::ptr::from_ref;// SAFETY:above generatedunsafe { raw::… }calls.unicode.rsimpls; ~500 lines of unusedresolver/fs.rstypes; ~250 linesshell_parser; ~180 linespackage_jsonreverse-resolution; 256-line deadname_static; dead FFI extern decls (Rust→C++ imports nothing calls).#[cfg(target_os = ...)]/#[cfg(debug_assertions)]).CI
.github/workflows/clippy.yml—bun run rust:clippywith inline PR annotations via.github/rust-matcher.json..github/workflows/miri.yml—bun run rust:miri(Tree Borrows) on the FFI-free crate set.Exceptions (the only
#![allow]s added)build.rs:disallowed_{methods,types,macros}— build scripts run on the host beforebun_*crates exist.bun_alloc/lib.rs:disallowed_types— T0 foundation crate;bun_threading/bun_collectionsdepend on it.#[allow]insidemacro_rules!/quote!{}bodies are preserved — they suppress lints in emitted code that varies per call site.cargo clippy --workspace --no-deps: 0 errors.bun run rust:check-all: 10/10.bun bd: builds.