diff --git a/src/librustdoc/html/format.rs b/src/librustdoc/html/format.rs
index fc5507d4d55..3589cc8fac6 100644
--- a/src/librustdoc/html/format.rs
+++ b/src/librustdoc/html/format.rs
@@ -945,6 +945,10 @@ impl<'a> fmt::Display for Method<'a> {
let mut args = String::new();
let mut args_plain = String::new();
for (i, input) in decl.inputs.values.iter().enumerate() {
+ if i == 0 {
+ args.push_str("
");
+ }
+
if let Some(selfty) = input.to_self() {
match selfty {
clean::SelfValue => {
@@ -986,8 +990,8 @@ impl<'a> fmt::Display for Method<'a> {
args_plain.push_str(&format!("{:#}", input.type_));
}
if i + 1 < decl.inputs.values.len() {
- args.push_str(",");
- args_plain.push_str(",");
+ args.push(',');
+ args_plain.push(',');
}
}
@@ -1003,27 +1007,19 @@ impl<'a> fmt::Display for Method<'a> {
format!("{}", decl.output)
};
- let mut output: String;
- let plain: String;
let pad = repeat(" ").take(indent).collect::();
- if arrow.is_empty() {
- output = format!("({})", args);
- plain = format!("{}({})", pad, args_plain);
- } else {
- output = format!("({args})
{arrow}", args = args, arrow = arrow);
- plain = format!("{pad}({args}){arrow}",
- pad = pad,
- args = args_plain,
- arrow = arrow_plain);
- }
+ let plain = format!("{pad}({args}){arrow}",
+ pad = pad,
+ args = args_plain,
+ arrow = arrow_plain);
- if plain.len() > 80 {
- let pad = repeat(" ").take(indent).collect::();
- let pad = format!("
{}", pad);
- output = output.replace("
", &pad);
+ let output = if plain.len() > 80 {
+ let pad = "
";
+ format!("({args}
){arrow}", args = args.replace("
", pad), arrow = arrow)
} else {
- output = output.replace("
", "");
- }
+ format!("({args}){arrow}", args = args.replace("
", ""), arrow = arrow)
+ };
+
if f.alternate() {
write!(f, "{}", output.replace("
", "\n"))
} else {