mirror of
				https://github.com/rust-lang/rust.git
				synced 2025-10-31 13:04:42 +00:00 
			
		
		
		
	 a090e76dab
			
		
	
	
		a090e76dab
		
	
	
	
	
		
			
			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.
		
	
			
		
			
				
	
	
		
			7 lines
		
	
	
		
			153 B
		
	
	
	
		
			Rust
		
	
	
	
	
	
			
		
		
	
	
			7 lines
		
	
	
		
			153 B
		
	
	
	
		
			Rust
		
	
	
	
	
	
| enum TestEnum {
 | |
|     Works,
 | |
|     /// Some documentation
 | |
|     Self, //~ ERROR expected identifier, found keyword `Self`
 | |
|     //~^ HELP enum variants can be
 | |
| }
 |