Don't panic on function return type rewrite failure

This commit is contained in:
Marcus Klaas 2015-12-12 15:41:10 +01:00
parent e20722ab5d
commit 2636fed5f3
2 changed files with 12 additions and 6 deletions

View File

@ -1057,9 +1057,8 @@ fn rewrite_fn_base(context: &RewriteContext,
// Note that if the width and indent really matter, we'll re-layout the
// return type later anyway.
let ret_str = fd.output
.rewrite(&context, context.config.max_width - indent.width(), indent)
.unwrap();
let ret_str = try_opt!(fd.output
.rewrite(&context, context.config.max_width - indent.width(), indent));
let multi_line_ret_str = ret_str.contains('\n');
let ret_str_len = if multi_line_ret_str {
@ -1158,9 +1157,8 @@ fn rewrite_fn_base(context: &RewriteContext,
// re-layout the return type.
let budget = try_opt!(context.config.max_width.checked_sub(ret_indent.width()));
let ret_str = fd.output
.rewrite(context, budget, ret_indent)
.unwrap();
let ret_str = try_opt!(fd.output
.rewrite(context, budget, ret_indent));
result.push_str(&ret_str);
} else {
result.push_str(&ret_str);

View File

@ -91,3 +91,11 @@ fn foo(a: i32) -> i32 {
// comment
if a > 0 { 1 } else { 2 }
}
fn ______________________baz(a: i32)
->
*mut ::std::option::Option<extern "C" fn(arg1: i32,
_____________________a: i32,
arg3: i32)
-> ()> {
}