Skip to content

Commit 5dc80dc

Browse files
authored
Rollup merge of #49442 - GuillaumeGomez:text-overlap, r=QuietMisdreavus
Fix text overlap Fixes #49006. r? @QuietMisdreavus
2 parents 1a89250 + 51f26ac commit 5dc80dc

File tree

9 files changed

+55
-32
lines changed

9 files changed

+55
-32
lines changed

src/librustdoc/html/render.rs

+17-16
Original file line numberDiff line numberDiff line change
@@ -2243,14 +2243,7 @@ fn item_function(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
22432243

22442244
fn render_implementor(cx: &Context, implementor: &Impl, w: &mut fmt::Formatter,
22452245
implementor_dups: &FxHashMap<&str, (DefId, bool)>) -> Result<(), fmt::Error> {
2246-
write!(w, "<li>")?;
2247-
if let Some(l) = (Item { cx, item: &implementor.impl_item }).src_href() {
2248-
write!(w, "<div class='out-of-band'>")?;
2249-
write!(w, "<a class='srclink' href='{}' title='{}'>[src]</a>",
2250-
l, "goto source code")?;
2251-
write!(w, "</div>")?;
2252-
}
2253-
write!(w, "<code>")?;
2246+
write!(w, "<li><table class='table-display'><tbody><tr><td><code>")?;
22542247
// If there's already another implementor that has the same abbridged name, use the
22552248
// full path, for example in `std::iter::ExactSizeIterator`
22562249
let use_absolute = match implementor.inner_impl().for_ {
@@ -2269,7 +2262,14 @@ fn render_implementor(cx: &Context, implementor: &Impl, w: &mut fmt::Formatter,
22692262
write!(w, ";</span>")?;
22702263
}
22712264
}
2272-
writeln!(w, "</code></li>")?;
2265+
write!(w, "</code><td>")?;
2266+
if let Some(l) = (Item { cx, item: &implementor.impl_item }).src_href() {
2267+
write!(w, "<div class='out-of-band'>")?;
2268+
write!(w, "<a class='srclink' href='{}' title='{}'>[src]</a>",
2269+
l, "goto source code")?;
2270+
write!(w, "</div>")?;
2271+
}
2272+
writeln!(w, "</td></tr></tbody></table></li>")?;
22732273
Ok(())
22742274
}
22752275

@@ -3314,10 +3314,11 @@ fn render_impl(w: &mut fmt::Formatter, cx: &Context, i: &Impl, link: AssocItemLi
33143314
Some(ref t) => format!("impl-{}", small_url_encode(&format!("{:#}", t))),
33153315
None => "impl".to_string(),
33163316
});
3317-
write!(w, "<h3 id='{}' class='impl'><span class='in-band'><code>{}</code>",
3317+
write!(w, "<h3 id='{}' class='impl'><span class='in-band'><table class='table-display'>\
3318+
<tbody><tr><td><code>{}</code>",
33183319
id, i.inner_impl())?;
33193320
write!(w, "<a href='#{}' class='anchor'></a>", id)?;
3320-
write!(w, "</span><span class='out-of-band'>")?;
3321+
write!(w, "</span></td><td><span class='out-of-band'>")?;
33213322
let since = i.impl_item.stability.as_ref().map(|s| &s.since[..]);
33223323
if let Some(l) = (Item { item: &i.impl_item, cx: cx }).src_href() {
33233324
write!(w, "<div class='ghost'></div>")?;
@@ -3327,8 +3328,7 @@ fn render_impl(w: &mut fmt::Formatter, cx: &Context, i: &Impl, link: AssocItemLi
33273328
} else {
33283329
render_stability_since_raw(w, since, outer_version)?;
33293330
}
3330-
write!(w, "</span>")?;
3331-
write!(w, "</h3>\n")?;
3331+
write!(w, "</span></td></tr></tbody></table></h3>")?;
33323332
if let Some(ref dox) = cx.shared.maybe_collapsed_doc_value(&i.impl_item) {
33333333
write!(w, "<div class='docblock'>{}</div>",
33343334
Markdown(&*dox, &i.impl_item.links()))?;
@@ -3357,19 +3357,20 @@ fn render_impl(w: &mut fmt::Formatter, cx: &Context, i: &Impl, link: AssocItemLi
33573357
write!(w, "<h4 id='{}' class=\"{}\">", id, item_type)?;
33583358
write!(w, "{}", spotlight_decl(decl)?)?;
33593359
write!(w, "<span id='{}' class='invisible'>", ns_id)?;
3360-
write!(w, "<code>")?;
3360+
write!(w, "<table class='table-display'><tbody><tr><td><code>")?;
33613361
render_assoc_item(w, item, link.anchor(&id), ItemType::Impl)?;
33623362
write!(w, "</code>")?;
33633363
if let Some(l) = (Item { cx, item }).src_href() {
3364-
write!(w, "</span><span class='out-of-band'>")?;
3364+
write!(w, "</span></td><td><span class='out-of-band'>")?;
33653365
write!(w, "<div class='ghost'></div>")?;
33663366
render_stability_since_raw(w, item.stable_since(), outer_version)?;
33673367
write!(w, "<a class='srclink' href='{}' title='{}'>[src]</a>",
33683368
l, "goto source code")?;
33693369
} else {
3370+
write!(w, "</td><td>")?;
33703371
render_stability_since_raw(w, item.stable_since(), outer_version)?;
33713372
}
3372-
write!(w, "</span></h4>\n")?;
3373+
write!(w, "</td></tr></tbody></table></span></h4>")?;
33733374
}
33743375
}
33753376
clean::TypedefItem(ref tydef, _) => {

src/librustdoc/html/static/rustdoc.css

+26-4
Original file line numberDiff line numberDiff line change
@@ -392,8 +392,6 @@ h4 > code, h3 > code, .invisible > code {
392392
.content .in-band {
393393
margin: 0px;
394394
padding: 0px;
395-
display: inline-block;
396-
max-width: calc(100% - 43px);
397395
}
398396

399397
.in-band > code {
@@ -408,7 +406,7 @@ h4 > code, h3 > code, .invisible > code {
408406
font-family: "Fira Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
409407
}
410408

411-
.content table {
409+
.content table:not(.table-display) {
412410
border-spacing: 0 5px;
413411
border-collapse: separate;
414412
}
@@ -475,7 +473,6 @@ h4 > code, h3 > code, .invisible > code {
475473
.content .methods > div:not(.important-traits) { margin-left: 40px; }
476474

477475
.content .impl-items .docblock, .content .impl-items .stability {
478-
margin-left: 40px;
479476
margin-bottom: .6em;
480477
}
481478
.content .impl-items .method, .content .impl-items > .type, .impl-items > .associatedconstant {
@@ -1267,3 +1264,28 @@ kbd {
12671264
/* important because of conflicting rule for small screens */
12681265
display: none !important;
12691266
}
1267+
1268+
#implementations-list > h3 > span.in-band {
1269+
width: 100%;
1270+
}
1271+
1272+
.table-display {
1273+
width: 100%;
1274+
border: 0;
1275+
border-collapse: collapse;
1276+
border-spacing: 0;
1277+
font-size: 16px;
1278+
}
1279+
1280+
.table-display tr td:first-child {
1281+
padding-right: 0;
1282+
}
1283+
1284+
.table-display tr td:last-child {
1285+
float: right;
1286+
}
1287+
.table-display .out-of-band {
1288+
position: relative;
1289+
font-size: 19px;
1290+
display: block;
1291+
}

src/test/rustdoc/synthetic_auto/complex.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ mod foo {
3030
}
3131

3232
// @has complex/struct.NotOuter.html
33-
// @has - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]/*/code' "impl<'a, T, K: \
33+
// @has - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]//*/code' "impl<'a, T, K: \
3434
// ?Sized> Send for NotOuter<'a, T, K> where K: for<'b> Fn((&'b bool, &'a u8)) \
3535
// -> &'b i8, T: MyTrait<'a>, <T as MyTrait<'a>>::MyItem: Copy, 'a: 'static"
3636

src/test/rustdoc/synthetic_auto/lifetimes.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ where
1818
{}
1919

2020
// @has lifetimes/struct.Foo.html
21-
// @has - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]/*/code' "impl<'c, K> Send \
21+
// @has - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]//*/code' "impl<'c, K> Send \
2222
// for Foo<'c, K> where K: for<'b> Fn(&'b bool) -> &'c u8, 'c: 'static"
2323
//
24-
// @has - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]/*/code' "impl<'c, K> Sync \
24+
// @has - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]//*/code' "impl<'c, K> Sync \
2525
// for Foo<'c, K> where K: Sync"
2626
pub struct Foo<'c, K: 'c> {
2727
inner_field: Inner<'c, K>,

src/test/rustdoc/synthetic_auto/manual.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
// except according to those terms.
1010

1111
// @has manual/struct.Foo.html
12-
// @has - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]/*/code' 'impl<T> Sync for \
12+
// @has - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]//*/code' 'impl<T> Sync for \
1313
// Foo<T> where T: Sync'
1414
//
15-
// @has - '//*[@id="implementations-list"]/*[@class="impl"]/*/code' \
15+
// @has - '//*[@id="implementations-list"]/*[@class="impl"]//*/code' \
1616
// 'impl<T> Send for Foo<T>'
1717
//
1818
// @count - '//*[@id="implementations-list"]/*[@class="impl"]' 1

src/test/rustdoc/synthetic_auto/negative.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ pub struct Inner<T: Copy> {
1313
}
1414

1515
// @has negative/struct.Outer.html
16-
// @has - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]/*/code' "impl<T> !Send for \
16+
// @has - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]//*/code' "impl<T> !Send for \
1717
// Outer<T>"
1818
//
19-
// @has - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]/*/code' "impl<T> \
19+
// @has - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]//*/code' "impl<T> \
2020
// !Sync for Outer<T>"
2121
pub struct Outer<T: Copy> {
2222
inner_field: Inner<T>,

src/test/rustdoc/synthetic_auto/nested.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ where
1818
}
1919

2020
// @has nested/struct.Foo.html
21-
// @has - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]/*/code' 'impl<T> Send for \
21+
// @has - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]//*/code' 'impl<T> Send for \
2222
// Foo<T> where T: Copy'
2323
//
24-
// @has - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]/*/code' \
24+
// @has - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]//*/code' \
2525
// 'impl<T> Sync for Foo<T> where T: Sync'
2626
pub struct Foo<T> {
2727
inner_field: Inner<T>,

src/test/rustdoc/synthetic_auto/no-redundancy.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ where
1919
}
2020

2121
// @has no_redundancy/struct.Outer.html
22-
// @has - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]/*/code' "impl<T> Send for \
22+
// @has - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]//*/code' "impl<T> Send for \
2323
// Outer<T> where T: Copy + Send"
2424
pub struct Outer<T> {
2525
inner_field: Inner<T>,

src/test/rustdoc/synthetic_auto/project.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ where
3333
}
3434

3535
// @has project/struct.Foo.html
36-
// @has - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]/*/code' "impl<'c, K> Send \
36+
// @has - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]//*/code' "impl<'c, K> Send \
3737
// for Foo<'c, K> where K: MyTrait<MyItem = bool>, 'c: 'static"
3838
//
39-
// @has - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]/*/code' "impl<'c, K> Sync \
39+
// @has - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]//*/code' "impl<'c, K> Sync \
4040
// for Foo<'c, K> where K: MyTrait, <K as MyTrait>::MyItem: OtherTrait, 'c: 'static,"
4141
pub struct Foo<'c, K: 'c> {
4242
inner_field: Inner<'c, K>,

0 commit comments

Comments
 (0)