XPerf
语言Rust

rustperf-lint

这篇还没有中文,下面是英文原文。

Heuristic Rust checker for rs-alloc-hot–rs-collect-vec-hot. Line/brace window scanner — not a full AST/SSA pass.

RuleDefaultMessage
rs-alloc-hotoffalloc/clone in loop (Vec::new / .clone / to_string / to_owned); demoted after G3 OK-idiom
rs-println-hothintprintln! / eprintln! in loop
rs-format-rebind-hoterrorformat! rebind accum in loop (~99× vs write!); skips "{{{id}}}" wrap
rs-collect-vec-hothintcollect::<Vec<_>> inside a loop — reuse buffer / avoid per-iter collect

Self-dogfood: bash ../scripts/self-lint.sh must stay clean on examples (fixtures excluded via fixtures/ skip).

False positives / reverse-opt

  • Init / config loops that intentionally allocate once per entry (rs-alloc-hot)
  • Cold clap usage seeds (mid_string / sc_names) and help/shell generators
  • Inline #[cfg(test)] / #[test] regions
  • One-shot s = format!("{{{s}}}") usage braces (rs-format-rebind-hot skipped)

corpus-ready: yes (r4 TRIAGE — see docs/corpus.md).