Merge pull request #2981 from topecongiro/issue-2956

Keep formatting fn even if there is an unformattable argument
This commit is contained in:
Nick Cameron 2018-08-31 10:43:06 +12:00 committed by GitHub
commit d88139893f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 2 deletions

View File

@ -2232,8 +2232,10 @@ fn rewrite_args(
) -> Option<String> {
let mut arg_item_strs = args
.iter()
.map(|arg| arg.rewrite(context, Shape::legacy(multi_line_budget, arg_indent)))
.collect::<Option<Vec<_>>>()?;
.map(|arg| {
arg.rewrite(context, Shape::legacy(multi_line_budget, arg_indent))
.unwrap_or_else(|| context.snippet(arg.span()).to_owned())
}).collect::<Vec<_>>();
// Account for sugary self.
// FIXME: the comment for the self argument is dropped. This is blocked

View File

@ -67,3 +67,8 @@ crate fn init() {}
// #2630
fn make_map<T, F: (Fn(&T) -> String)>(records: &Vec<T>, key_fn: F) -> HashMap<String, usize> {}
// #2956
fn bar(beans: Asdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdf, spam: bool, eggs: bool) -> bool{
unimplemented!();
}

View File

@ -108,3 +108,12 @@ crate fn init() {}
// #2630
fn make_map<T, F: (Fn(&T) -> String)>(records: &Vec<T>, key_fn: F) -> HashMap<String, usize> {}
// #2956
fn bar(
beans: Asdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdf,
spam: bool,
eggs: bool,
) -> bool {
unimplemented!();
}