end expressions like return/continue/break with a semicolon
Close #3213
This commit is contained in:
parent
4f233a513e
commit
d03d9a45ef
6 changed files with 28 additions and 5 deletions
|
|
@ -137,7 +137,7 @@ impl TemplateParser {
|
|||
return Err(LicenseError::Parse(format!(
|
||||
"incomplete escape sequence on l. {}",
|
||||
parser.linum
|
||||
)))
|
||||
)));
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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(","))
|
||||
};
|
||||
|
|
|
|||
7
tests/source/issue-3213.rs
Normal file
7
tests/source/issue-3213.rs
Normal file
|
|
@ -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()));
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
|
|||
11
tests/target/issue-3213.rs
Normal file
11
tests/target/issue-3213.rs
Normal file
|
|
@ -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()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue