mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-28 09:44:08 +00:00
Merge #1440
1440: fixed #1384 r=matklad a=zbelial This PR fixed #1384 . Co-authored-by: zjy <zhaojiyang1@xiaomi.com>
This commit is contained in:
commit
5d829841cd
@ -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;
|
||||
|
@ -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(())
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,8 @@
|
||||
fn simple_function() {
|
||||
enum LocalEnum {
|
||||
One,
|
||||
Two,
|
||||
};
|
||||
fn f() {};
|
||||
struct S {};
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
SOURCE_FILE@[0; 111)
|
||||
FN_DEF@[0; 110)
|
||||
FN_KW@[0; 2) "fn"
|
||||
WHITESPACE@[2; 3) " "
|
||||
NAME@[3; 18)
|
||||
IDENT@[3; 18) "simple_function"
|
||||
PARAM_LIST@[18; 20)
|
||||
L_PAREN@[18; 19) "("
|
||||
R_PAREN@[19; 20) ")"
|
||||
WHITESPACE@[20; 21) " "
|
||||
BLOCK@[21; 110)
|
||||
L_CURLY@[21; 22) "{"
|
||||
WHITESPACE@[22; 27) "\n "
|
||||
ENUM_DEF@[27; 75)
|
||||
ENUM_KW@[27; 31) "enum"
|
||||
WHITESPACE@[31; 32) " "
|
||||
NAME@[32; 41)
|
||||
IDENT@[32; 41) "LocalEnum"
|
||||
WHITESPACE@[41; 42) " "
|
||||
ENUM_VARIANT_LIST@[42; 75)
|
||||
L_CURLY@[42; 43) "{"
|
||||
WHITESPACE@[43; 52) "\n "
|
||||
ENUM_VARIANT@[52; 55)
|
||||
NAME@[52; 55)
|
||||
IDENT@[52; 55) "One"
|
||||
COMMA@[55; 56) ","
|
||||
WHITESPACE@[56; 65) "\n "
|
||||
ENUM_VARIANT@[65; 68)
|
||||
NAME@[65; 68)
|
||||
IDENT@[65; 68) "Two"
|
||||
COMMA@[68; 69) ","
|
||||
WHITESPACE@[69; 74) "\n "
|
||||
R_CURLY@[74; 75) "}"
|
||||
SEMI@[75; 76) ";"
|
||||
WHITESPACE@[76; 81) "\n "
|
||||
FN_DEF@[81; 90)
|
||||
FN_KW@[81; 83) "fn"
|
||||
WHITESPACE@[83; 84) " "
|
||||
NAME@[84; 85)
|
||||
IDENT@[84; 85) "f"
|
||||
PARAM_LIST@[85; 87)
|
||||
L_PAREN@[85; 86) "("
|
||||
R_PAREN@[86; 87) ")"
|
||||
WHITESPACE@[87; 88) " "
|
||||
BLOCK@[88; 90)
|
||||
L_CURLY@[88; 89) "{"
|
||||
R_CURLY@[89; 90) "}"
|
||||
SEMI@[90; 91) ";"
|
||||
WHITESPACE@[91; 96) "\n "
|
||||
STRUCT_DEF@[96; 107)
|
||||
STRUCT_KW@[96; 102) "struct"
|
||||
WHITESPACE@[102; 103) " "
|
||||
NAME@[103; 104)
|
||||
IDENT@[103; 104) "S"
|
||||
WHITESPACE@[104; 105) " "
|
||||
NAMED_FIELD_DEF_LIST@[105; 107)
|
||||
L_CURLY@[105; 106) "{"
|
||||
R_CURLY@[106; 107) "}"
|
||||
SEMI@[107; 108) ";"
|
||||
WHITESPACE@[108; 109) "\n"
|
||||
R_CURLY@[109; 110) "}"
|
||||
WHITESPACE@[110; 111) "\n"
|
Loading…
Reference in New Issue
Block a user