Skip to content

Instantly share code, notes, and snippets.

@waynexia
Created July 26, 2025 00:02
Show Gist options
  • Select an option

  • Save waynexia/33d4be6671460512b5c2c241781ea9d0 to your computer and use it in GitHub Desktop.

Select an option

Save waynexia/33d4be6671460512b5c2c241781ea9d0 to your computer and use it in GitHub Desktop.
use with `ast-grep scan -r unsized-vec.yml` to find bare vector declaration
id: unsized-vec
language: rust
rule:
all:
- pattern: 'let mut $VAR = $INIT'
- has:
pattern: $INIT
any:
- pattern: 'vec![]'
- pattern: 'Vec::new()'
- pattern: 'Vec::default()'
- not:
inside:
any:
- kind: mod_item
pattern: 'mod test {$$$}'
- kind: mod_item
pattern: 'mod tests {$$$}'
stopBy: end
ignores:
- "**/tests/**"
- "**/*_test.rs"
- "**/benches/**"
- "**/benchmarks/**"
- "**/examples/**"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment