diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2023-05-27 20:40:28 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-05-27 20:40:28 +0200 |
| commit | 97fae38bf92a80c6ba41bf2a195afb2300aae275 (patch) | |
| tree | c7e2bd24f9b038dda87fc007c3d0f0aee41489c2 /tests/ui/parser/issues | |
| parent | 0b300a7bfae0fa9031e8c593cc6101c117c47a74 (diff) | |
| parent | 272dc5a6d5967c0816564894b4fd86835a860d97 (diff) | |
| download | rust-97fae38bf92a80c6ba41bf2a195afb2300aae275.tar.gz rust-97fae38bf92a80c6ba41bf2a195afb2300aae275.zip | |
Rollup merge of #111181 - bvanjoi:fix-issue-111148, r=davidtwco
fix(parse): return unpected when current token is EOF close https://github.com/rust-lang/rust/issues/111148 #111148 panic occurred because [FatalError.raise()](https://github.com/bvanjoi/rust/blob/master/compiler/rustc_parse/src/parser/mod.rs#LL540C3-L540C3) was encountered which caused by `Eof` and `Pound`(the last token) had same span, when parsing `#` in `fn a<<i<Y<w<>#`. <img width="825" alt="image" src="https://user-images.githubusercontent.com/30187863/236612589-9e2c6a0b-18cd-408c-b636-c12a51cbcf1c.png"> There are a few ways to solve this problem: - Change the action assign for [self.last_unexpected_token_span](https://github.com/rust-lang/rust/blob/master/compiler/rustc_parse/src/parser/diagnostics.rs#L592), for example, if current token is `Eof`, then return Error directly. - Avoid triggering the `FatalError` when the current token is `Eof`. I have chosen the second option because executing `expected_one_of_not_found` when the token is `Eof` but not in `ediable` seems reasonable.
Diffstat (limited to 'tests/ui/parser/issues')
| -rw-r--r-- | tests/ui/parser/issues/issue-111148.rs | 2 | ||||
| -rw-r--r-- | tests/ui/parser/issues/issue-111148.stderr | 8 |
2 files changed, 10 insertions, 0 deletions
diff --git a/tests/ui/parser/issues/issue-111148.rs b/tests/ui/parser/issues/issue-111148.rs new file mode 100644 index 00000000000..2502beab443 --- /dev/null +++ b/tests/ui/parser/issues/issue-111148.rs @@ -0,0 +1,2 @@ +fn a<<i<Y<w<># +//~^ ERROR expected one of `#`, `>`, `const`, identifier, or lifetime, found `<` diff --git a/tests/ui/parser/issues/issue-111148.stderr b/tests/ui/parser/issues/issue-111148.stderr new file mode 100644 index 00000000000..e6595a5cbcc --- /dev/null +++ b/tests/ui/parser/issues/issue-111148.stderr @@ -0,0 +1,8 @@ +error: expected one of `#`, `>`, `const`, identifier, or lifetime, found `<` + --> $DIR/issue-111148.rs:1:6 + | +LL | fn a<<i<Y<w<># + | ^ expected one of `#`, `>`, `const`, identifier, or lifetime + +error: aborting due to previous error + |
