about summary refs log tree commit diff
path: root/src/test/ui/parser
diff options
context:
space:
mode:
authorYuki Okushi <jtitor@2k36.org>2021-08-03 19:07:44 +0900
committerGitHub <noreply@github.com>2021-08-03 19:07:44 +0900
commitf69daa261742f447f269d1ee9f814dfd5cb4eb1b (patch)
tree50c0a0d230dbf2519d669e808e6f3aec02d1d90d /src/test/ui/parser
parent345862d2245c2fe132c793ab528709045b38beaa (diff)
parentd2d851949bab4c96b54d11126a0efd1826557d3f (diff)
downloadrust-f69daa261742f447f269d1ee9f814dfd5cb4eb1b.tar.gz
rust-f69daa261742f447f269d1ee9f814dfd5cb4eb1b.zip
Rollup merge of #87646 - JohnTitor:fix-parser-ice, r=oli-obk
Fix a parser ICE on invalid `fn` body

Fixes #87635
A better fix would add a check for `fn` body on `expected_one_of_not_found` but I haven't come up with a graceful way. Any idea?
r? ```@oli-obk``` ```@estebank```
Diffstat (limited to 'src/test/ui/parser')
-rw-r--r--src/test/ui/parser/issue-87635.rs9
-rw-r--r--src/test/ui/parser/issue-87635.stderr19
2 files changed, 28 insertions, 0 deletions
diff --git a/src/test/ui/parser/issue-87635.rs b/src/test/ui/parser/issue-87635.rs
new file mode 100644
index 00000000000..da74c1877b1
--- /dev/null
+++ b/src/test/ui/parser/issue-87635.rs
@@ -0,0 +1,9 @@
+struct Foo {}
+
+impl Foo {
+    pub fn bar()
+    //~^ ERROR: expected `;`, found `}`
+    //~| ERROR: associated function in `impl` without body
+}
+
+fn main() {}
diff --git a/src/test/ui/parser/issue-87635.stderr b/src/test/ui/parser/issue-87635.stderr
new file mode 100644
index 00000000000..920a9f937dd
--- /dev/null
+++ b/src/test/ui/parser/issue-87635.stderr
@@ -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
+