|
9 | 9 |
|
10 | 10 | use std::borrow::Cow;
|
11 | 11 | use std::cell::Cell;
|
| 12 | +use std::cmp::Ordering; |
12 | 13 | use std::fmt::{self, Display, Write};
|
13 | 14 | use std::iter::{self, once};
|
14 | 15 |
|
@@ -785,16 +786,20 @@ pub(crate) fn href_relative_parts<'fqp>(
|
785 | 786 | );
|
786 | 787 | }
|
787 | 788 | }
|
788 |
| - // e.g. linking to std::sync::atomic from std::sync |
789 |
| - if relative_to_fqp.len() < fqp.len() { |
790 |
| - Box::new(fqp[relative_to_fqp.len()..fqp.len()].iter().copied()) |
791 |
| - // e.g. linking to std::sync from std::sync::atomic |
792 |
| - } else if fqp.len() < relative_to_fqp.len() { |
793 |
| - let dissimilar_part_count = relative_to_fqp.len() - fqp.len(); |
794 |
| - Box::new(iter::repeat(sym::dotdot).take(dissimilar_part_count)) |
795 |
| - // linking to the same module |
796 |
| - } else { |
797 |
| - Box::new(iter::empty()) |
| 789 | + match relative_to_fqp.len().cmp(&fqp.len()) { |
| 790 | + Ordering::Less => { |
| 791 | + // e.g. linking to std::sync::atomic from std::sync |
| 792 | + Box::new(fqp[relative_to_fqp.len()..fqp.len()].iter().copied()) |
| 793 | + } |
| 794 | + Ordering::Greater => { |
| 795 | + // e.g. linking to std::sync from std::sync::atomic |
| 796 | + let dissimilar_part_count = relative_to_fqp.len() - fqp.len(); |
| 797 | + Box::new(iter::repeat(sym::dotdot).take(dissimilar_part_count)) |
| 798 | + } |
| 799 | + Ordering::Equal => { |
| 800 | + // linking to the same module |
| 801 | + Box::new(iter::empty()) |
| 802 | + } |
798 | 803 | }
|
799 | 804 | }
|
800 | 805 |
|
@@ -1384,7 +1389,7 @@ impl clean::Impl {
|
1384 | 1389 | write!(f, ">")?;
|
1385 | 1390 | }
|
1386 | 1391 | } else {
|
1387 |
| - fmt_type(&type_, f, use_absolute, cx)?; |
| 1392 | + fmt_type(type_, f, use_absolute, cx)?; |
1388 | 1393 | }
|
1389 | 1394 | Ok(())
|
1390 | 1395 | }
|
@@ -1531,14 +1536,14 @@ impl clean::FnDecl {
|
1531 | 1536 | (None, Some(last_i)) if i != last_i => write!(f, ", ")?,
|
1532 | 1537 | (None, Some(_)) => (),
|
1533 | 1538 | (Some(n), Some(last_i)) if i != last_i => write!(f, ",\n{}", Indent(n + 4))?,
|
1534 |
| - (Some(_), Some(_)) => write!(f, ",\n")?, |
| 1539 | + (Some(_), Some(_)) => writeln!(f, ",")?, |
1535 | 1540 | }
|
1536 | 1541 | }
|
1537 | 1542 |
|
1538 | 1543 | if self.c_variadic {
|
1539 | 1544 | match line_wrapping_indent {
|
1540 | 1545 | None => write!(f, ", ...")?,
|
1541 |
| - Some(n) => write!(f, "{}...\n", Indent(n + 4))?, |
| 1546 | + Some(n) => writeln!(f, "{}...", Indent(n + 4))?, |
1542 | 1547 | };
|
1543 | 1548 | }
|
1544 | 1549 |
|
|
0 commit comments