Skip to content

Commit abffd4a

Browse files
committed
Add white-space: nowrap to links in the sidebar
We already have overflow: hidden on these links, but if there is a possibility to wrap, they will wrap. This happens in particular for trait implementations because the punctuation (`<>, `) introduces opportunities for breaks. That produces inconsistent UI. Fix it by forcing them not to wrap.
1 parent e7825f2 commit abffd4a

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

src/librustdoc/html/static/css/rustdoc.css

+4
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,10 @@ nav.sub {
484484
overflow: hidden;
485485
}
486486

487+
.sidebar-links a {
488+
white-space: nowrap;
489+
}
490+
487491
.sidebar h2 {
488492
border-bottom: none;
489493
font-weight: 500;

src/test/rustdoc-gui/sidebar.goml

+4
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,7 @@ assert-text: (".sidebar > .location", "Module sub_sub_module")
7474
assert-false: ".sidebar-elems .crate"
7575
assert-text: (".sidebar-elems .items > ul > li:nth-child(1)", "Functions")
7676
assert-text: ("#functions + .item-table .item-left > a", "foo")
77+
78+
// Links to trait implementations in the sidebar should not wrap even if they are long.
79+
goto: file://|DOC_PATH|/lib2/struct.HasALongTraitWithParams.html
80+
assert-property: (".sidebar-links a", {"offsetHeight": 29})

src/test/rustdoc-gui/src/lib2/lib.rs

+6
Original file line numberDiff line numberDiff line change
@@ -114,3 +114,9 @@ pub mod too_long {
114114
pub fn foo(&self) {}
115115
}
116116
}
117+
118+
pub struct HasALongTraitWithParams {}
119+
120+
pub trait LongTraitWithParamsBananaBananaBanana<T> {}
121+
122+
impl LongTraitWithParamsBananaBananaBanana<usize> for HasALongTraitWithParams {}

0 commit comments

Comments
 (0)