Skip to content

Keep formatting fn even if there is an unformattable argument #2981

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 30, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions tests/source/fn-simple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!();
}
9 changes: 9 additions & 0 deletions tests/target/fn-simple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!();
}