diff options
| author | bors <bors@rust-lang.org> | 2022-06-15 20:01:37 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-06-15 20:01:37 +0000 |
| commit | 519d7484f3b1beb25dec9f2249adeaaa21033433 (patch) | |
| tree | 1ef3bfd60915f0c75a4889283ddde41da7050f17 /src/test/codegen/src-hash-algorithm | |
| parent | d39d520a210e5d92c7c5d7ad5b6e9ecd0a0a4f07 (diff) | |
| parent | c32f1332363fd719cade4b4b2a7ba885a3ded4e7 (diff) | |
| download | rust-519d7484f3b1beb25dec9f2249adeaaa21033433.tar.gz rust-519d7484f3b1beb25dec9f2249adeaaa21033433.zip | |
Auto merge of #12545 - jeremyBanks:shebangs, r=Veykril
fix: inserted imports must come after a shebang if present
The current `insert_use` logic adds the first `use` item near the beginning of the file, only skipping past comments and whitespace. However, it does not skip leading [shebang lines](https://en.wikipedia.org/wiki/Shebang_\(Unix\)). This can produce a syntax error, as shebangs are only accepted (ignored) on the first line of the file.
### Before Insertion (valid syntax)
```rust
#!/usr/bin/env rust
fn main() {}
```
### After Insertion (invalid syntax)
```rust
use foo::bar::Baz;
#!/usr/bin/env rust
fn main() {}
```
Rust analyzer's grammar is already shebang-aware, so this PR just adds that to the array of SyntaxKinds that are skipped past when looking for an insertion location, and adds a corresponding test case.
Diffstat (limited to 'src/test/codegen/src-hash-algorithm')
0 files changed, 0 insertions, 0 deletions
