end expressions like return/continue/break with a semicolon

Close #3213
This commit is contained in:
Stéphane Campinas 2018-11-29 20:39:07 +01:00
parent 4f233a513e
commit d03d9a45ef
No known key found for this signature in database
GPG key ID: 6D5620D908210133
6 changed files with 28 additions and 5 deletions

View file

@ -137,7 +137,7 @@ impl TemplateParser {
return Err(LicenseError::Parse(format!(
"incomplete escape sequence on l. {}",
parser.linum
)))
)));
}
_ => (),
}

View file

@ -29,7 +29,7 @@ use source_map::SpanUtils;
use spanned::Spanned;
use utils::{
contains_skip, extra_offset, first_line_width, inner_attributes, last_line_extendable, mk_sp,
ptr_vec_to_ref_vec, trimmed_last_line_width,
ptr_vec_to_ref_vec, semicolon_for_expr, trimmed_last_line_width,
};
/// A simple wrapper type against `ast::Arm`. Used inside `write_list()`.
@ -413,7 +413,12 @@ fn rewrite_match_body(
} else {
""
};
("{", format!("{}}}{}", indent_str, comma))
let semicolon = if semicolon_for_expr(context, body) {
";"
} else {
""
};
("{", format!("{}{}}}{}", semicolon, indent_str, comma))
} else {
("", String::from(","))
};

View file

@ -0,0 +1,7 @@
fn foo() {
match 0 {
0 => return AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA,
1 => AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA,
_ => "",
};
}

View file

@ -545,7 +545,7 @@ fn issue_3005() {
{
return NoCalcLength::parse_dimension(context, value, unit)
.map(LengthOrPercentage::Length)
.map_err(|()| location.new_unexpected_token_error(token.clone()))
.map_err(|()| location.new_unexpected_token_error(token.clone()));
},
}
}

View file

@ -0,0 +1,11 @@
fn foo() {
match 0 {
0 => {
return AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA;
}
1 => {
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
}
_ => "",
};
}

View file

@ -572,7 +572,7 @@ fn issue_3005() {
} if num_context.is_ok(context.parsing_mode, value) => {
return NoCalcLength::parse_dimension(context, value, unit)
.map(LengthOrPercentage::Length)
.map_err(|()| location.new_unexpected_token_error(token.clone()))
.map_err(|()| location.new_unexpected_token_error(token.clone()));
}
}
}