diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2024-08-31 10:08:51 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-08-31 10:08:51 +0200 |
| commit | 1fd0c71818dd63ba4c75b4be8d5962af35e143d2 (patch) | |
| tree | b96a1d541231ff104785b5c8ff32074b2d91f128 /compiler/rustc_codegen_llvm/src/errors.rs | |
| parent | fa72f0763de6bc1596208fc1419883ce5aea0de4 (diff) | |
| parent | c61f85b6dd47343abe6383ea2eb71f0b3a7d0e2b (diff) | |
| download | rust-1fd0c71818dd63ba4c75b4be8d5962af35e143d2.tar.gz rust-1fd0c71818dd63ba4c75b4be8d5962af35e143d2.zip | |
Rollup merge of #120221 - compiler-errors:statements-are-not-patterns, r=nnethercote
Don't make statement nonterminals match pattern nonterminals
Right now, the heuristic we use to check if a token may begin a pattern nonterminal falls back to `may_be_ident`:
https://github.com/rust-lang/rust/blob/ef71f1047e04438181d7cb925a833e2ada6ab390/compiler/rustc_parse/src/parser/nonterminal.rs#L21-L37
This has the unfortunate side effect that a `stmt` nonterminal eagerly matches against a `pat` nonterminal, leading to a parse error:
```rust
macro_rules! m {
($pat:pat) => {};
($stmt:stmt) => {};
}
macro_rules! m2 {
($stmt:stmt) => {
m! { $stmt }
};
}
m2! { let x = 1 }
```
This PR fixes it by more accurately reflecting the set of nonterminals that may begin a pattern nonterminal.
As a side-effect, I modified `Token::can_begin_pattern` to work correctly and used that in `Parser::nonterminal_may_begin_with`.
Diffstat (limited to 'compiler/rustc_codegen_llvm/src/errors.rs')
0 files changed, 0 insertions, 0 deletions
