mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-30 14:52:56 +03:00
end expressions like return/continue/break with a semicolon
Close #3213
This commit is contained in:
@@ -137,7 +137,7 @@ pub fn parse(template: &str) -> Result<String, LicenseError> {
|
||||
return Err(LicenseError::Parse(format!(
|
||||
"incomplete escape sequence on l. {}",
|
||||
parser.linum
|
||||
)))
|
||||
)));
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
|
||||
+7
-2
@@ -29,7 +29,7 @@
|
||||
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(","))
|
||||
};
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
fn foo() {
|
||||
match 0 {
|
||||
0 => return AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA,
|
||||
1 => AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA,
|
||||
_ => "",
|
||||
};
|
||||
}
|
||||
@@ -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()));
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
fn foo() {
|
||||
match 0 {
|
||||
0 => {
|
||||
return AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA;
|
||||
}
|
||||
1 => {
|
||||
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
||||
}
|
||||
_ => "",
|
||||
};
|
||||
}
|
||||
@@ -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()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user