← Rule catalog

rust-doctor · Performance

excessive-clone

Flags `.clone()` calls that may indicate unnecessary heap allocations. Each clone copies the entire value, which is expensive for `String`, `Vec`, and other heap-allocated types.

Severity
warning
Confidence
medium
Analyzer
syn-ast
Default policy
Enabled

Tags

  • heuristic
  • performance

Framework requirements

No framework requirement.

Limitations

  • Syntactic analysis does not have rustc name resolution or inferred type information.

Remediation

Use references (`&T`) or `Cow<T>` instead of cloning. Consider restructuring ownership to avoid the clone.

Fix capability: guidance