Change:
When copying bounds from a trait assoc item, you can accidentally copy the semicolon. If you forget to remove it, multiple errors are emitted, while the second is: This should be explicitly handled to avoid knock down errors. <!-- TRIAGEBOTSTART --<!-- TRIAGEBOTASSIGNSTART --<!-- TRIAGEBOTASSIGNDATASTARTTRIAGEBOTASSIGNDATAEND --<!-- TRIAGEBOTASSIGNEND --<!-- TRIAGEBOTEND --
claim

Discussion:
} match parse_item(self) { Ok(None) => { <del> let is_unnecessary_semicolon = !items.is_empty() </del> <ins> let mut is_unnecessary_semicolon = !items.is_empty() </ins> // When the close delim is `)` in a case like the following, `token.kind` is expected to be `token::CloseDelim(Delimiter::Parenthesis)`, <del> // but the actual `token.kind` is `token::CloseDelim(Delimiter::Bracket)`. </del> <ins> // but the actual `token.kind` is `token::CloseDelim(Delimiter::Brace)`. </ins> // This is because the `token.kind` of the close delim is treated as the same as // that of the open delim in `TokenTreesReader::parse_token_tree`, even if the delimiters of them are different. // Therefore, `token.kind` should not be compared here.

.span_to_snippet(self.prev_token.span) .map_or(false, |snippet| snippet == "}") && self.token.kind == token::Semi; <del> let semicolon_span = self.token.span; </del> <ins> let mut semicolon_span = self.token.span; if !is_unnecessary_semicolon { // #105369, Detect spurious `;` before assoc fn body is_unnecessary_semicolon = self.token == token::OpenDelim(Delimiter::Brace) && self.prev_token.kind == token::Semi; semicolon_span = self.prev_token.span; } </ins> // We have to bail or we'll potentially never make progress. let non_item_span = self.token.span; let is_let = self.token.is_keyword(kw::Let);

<ins> use std::fmt; struct S { } impl S { fn hello<P>(&self, val: &P) where P: fmt::Display; { //~^ ERROR non-item in item list //~| ERROR associated function in `impl` without body println!("val: {}", val); } } impl S { fn hello_empty<P>(&self, val: &P) where P: fmt::Display; //~^ ERROR associated function in `impl` without body } fn main() { let s = S{}; s.hello(&32); } </ins>

<ins> error: non-item in item list --> $DIR/issue-105226.rs:7:56 | LL | impl S { |        - item list starts here LL |     fn hello<P>(&self, val: &P) where P: fmt::Display; { |                                                      - ^ non-item starts here |                                                      | |                                                      help: consider removing this semicolon ... LL | } | - item list ends here error: associated function in `impl` without body --> $DIR/issue-105226.rs:7:5 | LL |     fn hello<P>(&self, val: &P) where P: fmt::Display; { |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- |                                                      | |                                                      help: provide a definition for the function: `{ <body> }` error: associated function in `impl` without body --> $DIR/issue-105226.rs:15:5 | LL |     fn hello_empty<P>(&self, val: &P) where P: fmt::Display; |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- |                                                            | |                                                            help: provide a definition for the function: `{ <body> }` error: aborting due to 3 previous errors </ins>