Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 593d6d1

Browse files
committedJun 17, 2021
Make portability part of the summary.
That means it will be visible under "Implementors" on trait pages, and under "Implementations" on struct/enum pages, even when all methods are collapsed. Switch to a float layout for rightside elements.
1 parent 910c7fa commit 593d6d1

File tree

4 files changed

+27
-21
lines changed

4 files changed

+27
-21
lines changed
 

‎src/librustdoc/html/render/mod.rs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1552,6 +1552,7 @@ fn render_impl(
15521552
w,
15531553
cx,
15541554
i,
1555+
parent,
15551556
outer_version,
15561557
outer_const_version,
15571558
show_def_docs,
@@ -1562,11 +1563,6 @@ fn render_impl(
15621563
if toggled {
15631564
write!(w, "</summary>")
15641565
}
1565-
if trait_.is_some() {
1566-
if let Some(portability) = portability(&i.impl_item, Some(parent)) {
1567-
write!(w, "<div class=\"item-info\">{}</div>", portability);
1568-
}
1569-
}
15701566

15711567
if let Some(ref dox) = cx.shared.maybe_collapsed_doc_value(&i.impl_item) {
15721568
let mut ids = cx.id_map.borrow_mut();
@@ -1598,6 +1594,7 @@ pub(crate) fn render_impl_summary(
15981594
w: &mut Buffer,
15991595
cx: &Context<'_>,
16001596
i: &Impl,
1597+
parent: &clean::Item,
16011598
outer_version: Option<&str>,
16021599
outer_const_version: Option<&str>,
16031600
show_def_docs: bool,
@@ -1652,6 +1649,7 @@ pub(crate) fn render_impl_summary(
16521649
);
16531650
}
16541651
write!(w, "<a href=\"#{}\" class=\"anchor\"></a>", id);
1652+
write!(w, "<div class=\"rightside\">");
16551653
render_stability_since_raw(
16561654
w,
16571655
i.impl_item.stable_since(tcx).as_deref(),
@@ -1660,6 +1658,15 @@ pub(crate) fn render_impl_summary(
16601658
outer_const_version,
16611659
);
16621660
write_srclink(cx, &i.impl_item, w);
1661+
w.write_str("</div>"); // end of "rightside"
1662+
1663+
let is_trait = i.inner_impl().trait_.is_some();
1664+
if is_trait {
1665+
if let Some(portability) = portability(&i.impl_item, Some(parent)) {
1666+
write!(w, "<div class=\"item-info\">{}</div>", portability);
1667+
}
1668+
}
1669+
16631670
w.write_str("</div>");
16641671
}
16651672

‎src/librustdoc/html/render/print_item.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -585,11 +585,14 @@ fn item_trait(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, t: &clean::Tra
585585
if toggled {
586586
write!(w, "<details class=\"rustdoc-toggle\" open><summary>");
587587
}
588-
write!(w, "<div id=\"{}\" class=\"method has-srclink\"><code>", id);
589-
render_assoc_item(w, m, AssocItemLink::Anchor(Some(&id)), ItemType::Impl, cx);
590-
w.write_str("</code>");
588+
write!(w, "<div id=\"{}\" class=\"method has-srclink\">", id);
589+
write!(w, "<div class=\"rightside\">");
591590
render_stability_since(w, m, t, cx.tcx());
592591
write_srclink(cx, m, w);
592+
write!(w, "</div>");
593+
write!(w, "<code>");
594+
render_assoc_item(w, m, AssocItemLink::Anchor(Some(&id)), ItemType::Impl, cx);
595+
w.write_str("</code>");
593596
w.write_str("</div>");
594597
if toggled {
595598
write!(w, "</summary>");
@@ -697,6 +700,7 @@ fn item_trait(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, t: &clean::Tra
697700
w,
698701
cx,
699702
&implementor,
703+
it,
700704
outer_version.as_deref(),
701705
outer_const_version.as_deref(),
702706
false,
@@ -1305,7 +1309,7 @@ fn render_implementor(
13051309
implementor_dups: &FxHashMap<Symbol, (DefId, bool)>,
13061310
aliases: &[String],
13071311
) {
1308-
// If there's already another implementor that has the same abbridged name, use the
1312+
// If there's already another implementor that has the same abridged name, use the
13091313
// full path, for example in `std::iter::ExactSizeIterator`
13101314
let use_absolute = match implementor.inner_impl().for_ {
13111315
clean::ResolvedPath { ref path, is_generic: false, .. }
@@ -1321,6 +1325,7 @@ fn render_implementor(
13211325
w,
13221326
cx,
13231327
implementor,
1328+
trait_,
13241329
outer_version.as_deref(),
13251330
outer_const_version.as_deref(),
13261331
false,

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

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,6 @@ nav.sub {
581581
.content .item-info {
582582
position: relative;
583583
margin-left: 33px;
584-
margin-top: -13px;
585584
}
586585

587586
.sub-variant > div > .item-info {
@@ -852,12 +851,12 @@ body.blur > :not(#help) {
852851
}
853852

854853
.stab {
855-
display: table;
856854
border-width: 1px;
857855
border-style: solid;
858856
padding: 3px;
859857
margin-bottom: 5px;
860858
font-size: 90%;
859+
font-weight: normal;
861860
}
862861
.stab p {
863862
display: inline;
@@ -906,26 +905,22 @@ body.blur > :not(#help) {
906905
}
907906

908907
.impl-items .since, .impl .since, .methods .since {
909-
flex-grow: 0;
910908
padding-left: 12px;
911909
padding-right: 2px;
912910
position: initial;
913911
}
914912

915913
.impl-items .srclink, .impl .srclink, .methods .srclink {
916-
flex-grow: 0;
917914
/* Override header settings otherwise it's too bold */
918915
font-size: 17px;
919916
font-weight: normal;
920917
}
921918

922-
.impl-items code, .impl code, .methods code {
923-
flex-grow: 1;
919+
.rightside {
920+
float: right;
924921
}
925922

926923
.has-srclink {
927-
display: flex;
928-
flex-basis: 100%;
929924
font-size: 16px;
930925
margin-bottom: 12px;
931926
/* Push the src link out to the right edge consistently */
@@ -986,7 +981,6 @@ a.test-arrow:hover{
986981
}
987982

988983
.since + .srclink {
989-
display: table-cell;
990984
padding-left: 10px;
991985
}
992986

‎src/test/rustdoc/src-links-auto-impls.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
// @has foo/struct.Unsized.html
44
// @has - '//div[@id="impl-Sized"]/code' 'impl !Sized for Unsized'
5-
// @!has - '//div[@id="impl-Sized"]/a[@class="srclink"]' '[src]'
5+
// @!has - '//div[@id="impl-Sized"]//a[@class="srclink"]' '[src]'
66
// @has - '//div[@id="impl-Sync"]/code' 'impl Sync for Unsized'
7-
// @!has - '//div[@id="impl-Sync"]/a[@class="srclink"]' '[src]'
7+
// @!has - '//div[@id="impl-Sync"]//a[@class="srclink"]' '[src]'
88
// @has - '//div[@id="impl-Any"]/code' 'impl<T> Any for T'
9-
// @has - '//div[@id="impl-Any"]/a[@class="srclink"]' '[src]'
9+
// @has - '//div[@id="impl-Any"]//a[@class="srclink"]' '[src]'
1010
pub struct Unsized {
1111
data: [u8],
1212
}

0 commit comments

Comments
 (0)
Please sign in to comment.