summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/libsyntax/parse/parser.rs2
-rw-r--r--src/test/ui/parser/issue-62660.rs11
-rw-r--r--src/test/ui/parser/issue-62660.stderr8
3 files changed, 20 insertions, 1 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs
index afd01a34b49..26c76ae5606 100644
--- a/src/libsyntax/parse/parser.rs
+++ b/src/libsyntax/parse/parser.rs
@@ -1498,7 +1498,7 @@ impl<'a> Parser<'a> {
         F: Fn(&token::Token) -> bool
     {
         let attrs = self.parse_arg_attributes()?;
-        if let Ok(Some(mut arg)) = self.parse_self_arg() {
+        if let Some(mut arg) = self.parse_self_arg()? {
             arg.attrs = attrs.into();
             return self.recover_bad_self_arg(arg, is_trait_item);
         }
diff --git a/src/test/ui/parser/issue-62660.rs b/src/test/ui/parser/issue-62660.rs
new file mode 100644
index 00000000000..33c8a9fa328
--- /dev/null
+++ b/src/test/ui/parser/issue-62660.rs
@@ -0,0 +1,11 @@
+// Regression test for issue #62660: if a receiver's type does not
+// successfully parse, emit the correct error instead of ICE-ing the compiler.
+
+struct Foo;
+
+impl Foo {
+    pub fn foo(_: i32, self: Box<Self) {}
+    //~^ ERROR expected one of `!`, `(`, `+`, `,`, `::`, `<`, or `>`, found `)`
+}
+
+fn main() {}
diff --git a/src/test/ui/parser/issue-62660.stderr b/src/test/ui/parser/issue-62660.stderr
new file mode 100644
index 00000000000..3a8f6797b82
--- /dev/null
+++ b/src/test/ui/parser/issue-62660.stderr
@@ -0,0 +1,8 @@
+error: expected one of `!`, `(`, `+`, `,`, `::`, `<`, or `>`, found `)`
+  --> $DIR/issue-62660.rs:7:38
+   |
+LL |     pub fn foo(_: i32, self: Box<Self) {}
+   |                                      ^ expected one of 7 possible tokens here
+
+error: aborting due to previous error
+