Created
July 26, 2025 00:02
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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