Skip to content

Rollup of 7 pull requests #87719

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 14 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix a parser ICE on invalid fn body
  • Loading branch information
JohnTitor committed Jul 30, 2021
commit d2d851949bab4c96b54d11126a0efd1826557d3f
4 changes: 1 addition & 3 deletions compiler/rustc_parse/src/parser/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1715,13 +1715,11 @@ impl<'a> Parser<'a> {
// the AST for typechecking.
err.span_label(ident.span, "while parsing this `fn`");
err.emit();
(Vec::new(), None)
} else {
return Err(err);
}
} else {
unreachable!()
}
(Vec::new(), None)
};
attrs.extend(inner_attrs);
Ok(body)
Expand Down
9 changes: 9 additions & 0 deletions src/test/ui/parser/issue-87635.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
struct Foo {}

impl Foo {
pub fn bar()
//~^ ERROR: expected `;`, found `}`
//~| ERROR: associated function in `impl` without body
}

fn main() {}
19 changes: 19 additions & 0 deletions src/test/ui/parser/issue-87635.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
error: expected `;`, found `}`
--> $DIR/issue-87635.rs:4:17
|
LL | pub fn bar()
| ^ help: add `;` here
...
LL | }
| - unexpected token

error: associated function in `impl` without body
--> $DIR/issue-87635.rs:4:5
|
LL | pub fn bar()
| ^^^^^^^^^^^-
| |
| help: provide a definition for the function: `{ <body> }`

error: aborting due to 2 previous errors