Hasty Briefsbeta

Making a Small Clippy Lint

7 days ago
  • #PatternMatching
  • #Rust
  • #Clippy
  • A friend inquired about a Clippy lint to enforce exhaustive structural pattern matching to avoid unhandled variables in struct matches.
  • Initial research found no existing lint for this purpose, prompting the creation of a new lint.
  • The first version of the lint was an early pass that flagged the use of rest patterns (`..`) in struct destructuring.
  • The lint was improved to a late pass to include type information and suggestions for ignored fields (`field: _`).
  • Challenges included handling macro-generated code and accurately identifying the span of the `..` symbol in the HIR.
  • A pull request was made to Rust to include span information for the `..` symbol in the compiler.
  • The lint is pending review due to a feature freeze in Clippy, but the project provided valuable insights into Clippy and rustc internals.