This commit is contained in:
zjy 2019-06-26 11:36:14 +08:00
parent 0129790a8f
commit de930237ff
4 changed files with 90 additions and 7 deletions

View file

@ -181,6 +181,17 @@ pub(crate) fn expr_block_contents(p: &mut Parser) {
// fn foo(){
// ;;;some_expr();;;;{;;;};;;;Ok(())
// }
// test nocontentexpr_after_item
// fn simple_function() {
// enum LocalEnum {
// One,
// Two,
// };
// fn f() {};
// struct S {};
// }
if p.current() == T![;] {
p.bump();
continue;

View file

@ -38,7 +38,15 @@ pub(super) fn item_or_macro(p: &mut Parser, stop_on_r_curly: bool, flavor: ItemF
let m = p.start();
attributes::outer_attributes(p);
let m = match maybe_item(p, m, flavor) {
Ok(()) => return,
Ok(()) => {
if p.at(T![;]) {
p.err_and_bump(
"expected item, found `;`\n\
consider removing this semicolon",
);
}
return;
}
Err(m) => m,
};
if paths::is_path_start(p) {
@ -263,12 +271,6 @@ fn items_without_modifiers(p: &mut Parser, m: Marker) -> Result<(), Marker> {
}
_ => return Err(m),
};
if p.at(T![;]) {
p.err_and_bump(
"expected item, found `;`\n\
consider removing this semicolon",
);
}
Ok(())
}