Will It Vibe logoWill It Vibe?
RUST-015Low severity-4 points

mem::forget/Box::leak without justification

Part of Code Quality & Syntax, which counts for 20% of the overall score. When this check fires it deducts 4 points from that category, once per scan, no matter how many places it turns up.

What it detects

std::mem::forget/Box::leak intentionally skips destructors or permanently leaks memory. Heuristic: both have legitimate uses (deliberately leaking a guard, obtaining a 'static reference), but each occurrence is worth a second look to confirm it is intentional rather than an accidental resource leak.

Why it matters

std::mem::forget and Box::leak both intentionally bypass Rust's normal cleanup: forget skips the value's Drop entirely (so any resource it owned, like a file handle or a lock, is never released), and leak permanently gives up ownership of a heap allocation. Both have real, narrow uses, but each occurrence is also a plausible symptom of a resource that was supposed to be cleaned up and is not, especially if it appears somewhere it was not clearly intentional.

How to fix it

Confirm the specific reason this value needs to skip its destructor or be leaked (handing a raw pointer to an FFI boundary that will free it itself, deliberately promoting a value to 'static for the remaining program lifetime) and record that reason in a comment next to the call. If the intent was actually just to suppress an "unused" warning or work around a borrow-checker error, use the value normally (or an Arc/Rc/scope-based guard) instead of leaking it.

The paid report includes a ready-to-paste prompt for your AI coding agent for every check it finds, pointed at the exact findings from your scan. See pricing

Does your repo trip this check?

Paste a GitHub URL or drop a project folder. Scans run in your browser and take seconds.

Scan your repo

Related Code Quality & Syntax checks