name: m03-mutability description: "CRITICAL: Use for mutability issues. Triggers: E0596, E0499, E0502, cannot borrow as mutable, already borrowed as immutable, mut, &mut, interior mutability, Cell
阅读全文
Rust Trait Explorer
name: rust-trait-explorer description: "Explore Rust trait implementations using LSP. Triggers on: /trait-impl, find implementations, who implements, trait 实现, 谁实现了, 实现了哪些trait" argument-hint:
阅读全文
Add SAFETY Comment Before Any Unsafe Block
id: safety-09 original_id: P.UNS.SAS.09 level: P impact: CRITICAL clippy: undocumented_unsafe_blocks Add SAFETY Comment Before Any Unsafe Block Summary Every unsafe block or unsafe impl must have a //
阅读全文
Do Not Abuse Unsafe to Escape Compiler Safety Checks
id: general-01 original_id: P.UNS.01 level: P impact: CRITICAL Do Not Abuse Unsafe to Escape Compiler Safety Checks Summary Unsafe Rust should not be used as an escape hatch from the borrow checker or
阅读全文
Avoid Union Except for C Interop
id: union-01 original_id: P.UNS.UNI.01 level: P impact: HIGH Avoid Union Except for C Interop Summary Only use union for FFI with C code. For Rust-only code, use enum with explicit tags. Rationale Uni
阅读全文
Do Not Share Raw Pointers Across Threads
id: ptr-01 original_id: P.UNS.PTR.01 level: P impact: CRITICAL Do Not Share Raw Pointers Across Threads Summary Raw pointers (*const T, *mut T) are not Send or Sync by default. Do not share them acros
阅读全文
Implement Drop for Rust Types Wrapping Memory-Managing C Pointers
id: ffi-03 original_id: P.UNS.FFI.03 level: P impact: CRITICAL Implement Drop for Rust Types Wrapping Memory-Managing C Pointers Summary When wrapping a C pointer that owns memory, implement Drop to c
阅读全文
Use References Instead of Raw Pointers When Calling Safe C Functions
id: ffi-09 original_id: P.UNS.FFI.09 level: P impact: MEDIUM Use References Instead of Raw Pointers When Calling Safe C Functions Summary When wrapping C functions that don't need null pointers, use R
阅读全文
Document Invariant Assumptions for C-Provided Parameters
id: ffi-12 original_id: P.UNS.FFI.12 level: P impact: MEDIUM Document Invariant Assumptions for C-Provided Parameters Summary When receiving parameters from C, document what invariants you assume (non
阅读全文
Rule Template
Rule Template Use this template for all unsafe-checker rules. --- id: {prefix}-{number} original_id: P.UNS.XXX.YY or G.UNS.XXX.YY level: P|G impact: CRITICAL|HIGH|MEDIUM clippy: <clippy_lint_name&g
阅读全文