rust/compiler/rustc_parse/src/parser
Esteban Küber a090e76dab Tweak "expected ident" parse error to avoid talking about doc comments
When encountering a doc comment without an identifier after, we'd unconditionally state "this doc comment doesn't document anything", swallowing the *actual* error which is that the thing *after* the doc comment wasn't expected. Added a check that the found token is something that "conceptually" closes the previous item before emitting that error, otherwise just complain about the missing identifier.

In both of the following cases, the syntax error follows a doc comment:
```
error: expected identifier, found keyword `Self`
  --> $DIR/doc-before-bad-variant.rs:4:5
   |
LL | enum TestEnum {
   |      -------- while parsing this enum
...
LL |     Self,
   |     ^^^^ expected identifier, found keyword
   |
   = help: enum variants can be `Variant`, `Variant = <integer>`, `Variant(Type, ..., TypeN)` or `Variant { fields: Types }`
```
```
error: expected identifier, found `<`
  --> $DIR/doc-before-syntax-error.rs:2:1
   |
LL | <>
   | ^ expected identifier
```

Fix #71982.
2025-02-19 17:26:13 +00:00
..
mut_visit Re-export more rustc_span::symbol things from rustc_span. 2024-12-18 13:38:53 +11:00
tokenstream update cfg(bootstrap) 2025-01-08 21:26:39 +01:00
attr.rs Speed up Parser::expected_token_types. 2024-12-19 16:05:41 +11:00
attr_wrapper.rs Rustfmt 2025-02-08 22:12:13 +00:00
diagnostics.rs Tweak "expected ident" parse error to avoid talking about doc comments 2025-02-19 17:26:13 +00:00
expr.rs Rustfmt 2025-02-08 22:12:13 +00:00
generics.rs Stop using span hack for contracts feature gating 2025-02-10 19:51:26 +00:00
item.rs Rustfmt 2025-02-08 22:12:13 +00:00
mod.rs tree-wide: parallel: Fully removed all Lrc, replaced with Arc 2025-02-03 13:25:57 +03:00
nonterminal.rs tree-wide: parallel: Fully removed all Lrc, replaced with Arc 2025-02-03 13:25:57 +03:00
pat.rs Rename PatKind::Lit to Expr 2025-01-08 07:34:59 +00:00
path.rs Rustfmt 2025-02-08 22:12:13 +00:00
stmt.rs Rustfmt 2025-02-08 22:12:13 +00:00
tests.rs Stop passing the same resource multiple times when building ParseSess 2025-02-06 17:30:10 +00:00
token_type.rs Rename rustc_contract to contract 2025-02-03 13:55:15 -08:00
ty.rs Trim extra whitespace in fn ptr suggestion span 2025-01-27 17:17:22 +00:00