mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-02 19:53:46 +00:00
Format source codes and add tests
This commit is contained in:
parent
15b988aed3
commit
554605d47c
@ -168,10 +168,9 @@ pub fn rewrite_chain(expr: &ast::Expr, context: &RewriteContext, shape: Shape) -
|
||||
.into_iter()
|
||||
.chain(::std::iter::repeat(other_child_shape).take(subexpr_list.len() - 1));
|
||||
let iter = subexpr_list.iter().rev().zip(child_shape_iter);
|
||||
let mut rewrites = try_opt!(iter.map(|(e, shape)| {
|
||||
rewrite_chain_subexpr(e, total_span, context, shape)
|
||||
})
|
||||
.collect::<Option<Vec<_>>>());
|
||||
let mut rewrites =
|
||||
try_opt!(iter.map(|(e, shape)| rewrite_chain_subexpr(e, total_span, context, shape))
|
||||
.collect::<Option<Vec<_>>>());
|
||||
|
||||
// Total of all items excluding the last.
|
||||
let last_non_try_index = rewrites.len() - (1 + trailing_try_num);
|
||||
|
@ -1782,7 +1782,7 @@ fn rewrite_call_args(context: &RewriteContext,
|
||||
// and not rewriting macro.
|
||||
Some(ref s) if context.config.fn_call_style() == IndentStyle::Block &&
|
||||
!context.inside_macro &&
|
||||
((!can_be_overflowed(&context, args) && last_char_is_not_comma &&
|
||||
((!can_be_overflowed(context, args) && last_char_is_not_comma &&
|
||||
s.contains('\n')) ||
|
||||
first_line_width(s) > one_line_budget) => {
|
||||
fmt.trailing_separator = SeparatorTactic::Vertical;
|
||||
|
@ -1783,9 +1783,7 @@ fn rewrite_args(context: &RewriteContext,
|
||||
-> Option<String> {
|
||||
let mut arg_item_strs =
|
||||
try_opt!(args.iter()
|
||||
.map(|arg| {
|
||||
arg.rewrite(&context, Shape::legacy(multi_line_budget, arg_indent))
|
||||
})
|
||||
.map(|arg| arg.rewrite(&context, Shape::legacy(multi_line_budget, arg_indent)))
|
||||
.collect::<Option<Vec<_>>>());
|
||||
|
||||
// Account for sugary self.
|
||||
|
@ -16,6 +16,10 @@ fn main() {
|
||||
.client_credentials(&self.config.auth.oauth2.id, &self.config.auth.oauth2.secret)?;
|
||||
}
|
||||
}
|
||||
|
||||
// nesting macro and function call
|
||||
try!(foo(xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx, xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx));
|
||||
try!(foo(try!(xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx, xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx)));
|
||||
}
|
||||
|
||||
// #1521
|
||||
|
@ -1,13 +1,11 @@
|
||||
// rustfmt-fn_call_style: Block
|
||||
|
||||
// #1547
|
||||
fuzz_target!(|data: &[u8]| {
|
||||
if let Some(first) = data.first() {
|
||||
let index = *first as usize;
|
||||
if index >= ENCODINGS.len() {
|
||||
return;
|
||||
}
|
||||
let encoding = ENCODINGS[index];
|
||||
dispatch_test(encoding, &data[1..]);
|
||||
fuzz_target!(|data: &[u8]| if let Some(first) = data.first() {
|
||||
let index = *first as usize;
|
||||
if index >= ENCODINGS.len() {
|
||||
return;
|
||||
}
|
||||
let encoding = ENCODINGS[index];
|
||||
dispatch_test(encoding, &data[1..]);
|
||||
});
|
||||
|
@ -32,6 +32,16 @@ fn main() {
|
||||
)?;
|
||||
}
|
||||
}
|
||||
|
||||
// nesting macro and function call
|
||||
try!(foo(
|
||||
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx,
|
||||
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx,
|
||||
));
|
||||
try!(foo(try!(
|
||||
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx,
|
||||
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
)));
|
||||
}
|
||||
|
||||
// #1521
|
||||
|
Loading…
Reference in New Issue
Block a user