← Rule catalog

rust-doctor · Performance

regex-created-in-loop

Detect regular expressions compiled inside loops

Severity
warning
Confidence
high
Analyzer
syn-ast
Default policy
Opt-in

Tags

  • heuristic
  • performance

Framework requirements

No framework requirement.

Limitations

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

Remediation

Compile the expression once outside the loop or store it in LazyLock.

Fix capability: guidance