Fix a parser ICE on invalid fn
body
This commit is contained in:
parent
f3f8e758f2
commit
d2d851949b
3 changed files with 29 additions and 3 deletions
|
@ -1715,13 +1715,11 @@ impl<'a> Parser<'a> {
|
||||||
// the AST for typechecking.
|
// the AST for typechecking.
|
||||||
err.span_label(ident.span, "while parsing this `fn`");
|
err.span_label(ident.span, "while parsing this `fn`");
|
||||||
err.emit();
|
err.emit();
|
||||||
(Vec::new(), None)
|
|
||||||
} else {
|
} else {
|
||||||
return Err(err);
|
return Err(err);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
unreachable!()
|
|
||||||
}
|
}
|
||||||
|
(Vec::new(), None)
|
||||||
};
|
};
|
||||||
attrs.extend(inner_attrs);
|
attrs.extend(inner_attrs);
|
||||||
Ok(body)
|
Ok(body)
|
||||||
|
|
9
src/test/ui/parser/issue-87635.rs
Normal file
9
src/test/ui/parser/issue-87635.rs
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
struct Foo {}
|
||||||
|
|
||||||
|
impl Foo {
|
||||||
|
pub fn bar()
|
||||||
|
//~^ ERROR: expected `;`, found `}`
|
||||||
|
//~| ERROR: associated function in `impl` without body
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {}
|
19
src/test/ui/parser/issue-87635.stderr
Normal file
19
src/test/ui/parser/issue-87635.stderr
Normal file
|
@ -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
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue