Auto merge of #118441 - GuillaumeGomez:display-stability-version, r=r… · rust-lang/rust@d1a0fa5 (original) (raw)

`@@ -996,32 +996,20 @@ fn assoc_method(

`

996

996

`/// consequence of the above rules.

`

997

997

`fn render_stability_since_raw_with_extra(

`

998

998

`w: &mut Buffer,

`

999

``

`-

ver: Option,

`

``

999

`+

stable_version: Option,

`

1000

1000

`const_stability: Option,

`

1001

``

`-

containing_ver: Option,

`

1002

``

`-

containing_const_ver: Option,

`

1003

1001

`extra_class: &str,

`

1004

1002

`) -> bool {

`

1005

``

`-

let stable_version = if ver != containing_ver

`

1006

``

`-

&& let Some(ver) = &ver

`

1007

``

`-

{

`

1008

``

`-

since_to_string(ver)

`

1009

``

`-

} else {

`

1010

``

`-

None

`

1011

``

`-

};

`

1012

``

-

1013

1003

`let mut title = String::new();

`

1014

1004

`let mut stability = String::new();

`

1015

1005

``

1016

``

`-

if let Some(ver) = stable_version {

`

1017

``

`-

stability.push_str(ver.as_str());

`

1018

``

`-

title.push_str(&format!("Stable since Rust version {ver}"));

`

``

1006

`+

if let Some(version) = stable_version.and_then(|version| since_to_string(&version)) {

`

``

1007

`+

stability.push_str(&version);

`

``

1008

`+

title.push_str(&format!("Stable since Rust version {version}"));

`

1019

1009

`}

`

1020

1010

``

1021

1011

`let const_title_and_stability = match const_stability {

`

1022

``

`-

Some(ConstStability { level: StabilityLevel::Stable { since, .. }, .. })

`

1023

``

`-

if Some(since) != containing_const_ver =>

`

1024

``

`-

{

`

``

1012

`+

Some(ConstStability { level: StabilityLevel::Stable { since, .. }, .. }) => {

`

1025

1013

`since_to_string(&since)

`

1026

1014

`.map(|since| (format!("const since {since}"), format!("const: {since}")))

`

1027

1015

`}

`

`@@ -1076,17 +1064,8 @@ fn render_stability_since_raw(

`

1076

1064

`w: &mut Buffer,

`

1077

1065

`ver: Option,

`

1078

1066

`const_stability: Option,

`

1079

``

`-

containing_ver: Option,

`

1080

``

`-

containing_const_ver: Option,

`

1081

1067

`) -> bool {

`

1082

``

`-

render_stability_since_raw_with_extra(

`

1083

``

`-

w,

`

1084

``

`-

ver,

`

1085

``

`-

const_stability,

`

1086

``

`-

containing_ver,

`

1087

``

`-

containing_const_ver,

`

1088

``

`-

"",

`

1089

``

`-

)

`

``

1068

`+

render_stability_since_raw_with_extra(w, ver, const_stability, "")

`

1090

1069

`}

`

1091

1070

``

1092

1071

`fn render_assoc_item(

`

`@@ -1585,7 +1564,6 @@ fn render_impl(

`

1585

1564

`cx: &mut Context<'_>,

`

1586

1565

`item: &clean::Item,

`

1587

1566

`parent: &clean::Item,

`

1588

``

`-

containing_item: &clean::Item,

`

1589

1567

`link: AssocItemLink<'_>,

`

1590

1568

`render_mode: RenderMode,

`

1591

1569

`is_default_item: bool,

`

`@@ -1681,7 +1659,7 @@ fn render_impl(

`

1681

1659

`})

`

1682

1660

`.map(|item| format!("{}.{name}", item.type_()));

`

1683

1661

`write!(w, "<section id="{id}" class="{item_type}{in_trait_class}">");

`

1684

``

`-

render_rightside(w, cx, item, containing_item, render_mode);

`

``

1662

`+

render_rightside(w, cx, item, render_mode);

`

1685

1663

`if trait_.is_some() {

`

1686

1664

`// Anchors are only used on trait impls.

`

1687

1665

`write!(w, "<a href="#{id}" class="anchor">§");

`

`@@ -1703,7 +1681,7 @@ fn render_impl(

`

1703

1681

`let source_id = format!("{item_type}.{name}");

`

1704

1682

`let id = cx.derive_id(&source_id);

`

1705

1683

`write!(w, "<section id="{id}" class="{item_type}{in_trait_class}">");

`

1706

``

`-

render_rightside(w, cx, item, containing_item, render_mode);

`

``

1684

`+

render_rightside(w, cx, item, render_mode);

`

1707

1685

`if trait_.is_some() {

`

1708

1686

`// Anchors are only used on trait impls.

`

1709

1687

`write!(w, "<a href="#{id}" class="anchor">§");

`

`@@ -1789,7 +1767,6 @@ fn render_impl(

`

1789

1767

` cx,

`

1790

1768

` trait_item,

`

1791

1769

`if trait_.is_some() { &i.impl_item } else { parent },

`

1792

``

`-

parent,

`

1793

1770

` link,

`

1794

1771

` render_mode,

`

1795

1772

`false,

`

`@@ -1805,7 +1782,6 @@ fn render_impl(

`

1805

1782

`t: &clean::Trait,

`

1806

1783

`i: &clean::Impl,

`

1807

1784

`parent: &clean::Item,

`

1808

``

`-

containing_item: &clean::Item,

`

1809

1785

`render_mode: RenderMode,

`

1810

1786

`rendering_params: ImplRenderingParameters,

`

1811

1787

`) {

`

`@@ -1833,7 +1809,6 @@ fn render_impl(

`

1833

1809

` cx,

`

1834

1810

` trait_item,

`

1835

1811

` parent,

`

1836

``

`-

containing_item,

`

1837

1812

` assoc_link,

`

1838

1813

` render_mode,

`

1839

1814

`true,

`

`@@ -1856,7 +1831,6 @@ fn render_impl(

`

1856

1831

` t,

`

1857

1832

` i.inner_impl(),

`

1858

1833

`&i.impl_item,

`

1859

``

`-

parent,

`

1860

1834

` render_mode,

`

1861

1835

` rendering_params,

`

1862

1836

`);

`

`@@ -1878,7 +1852,6 @@ fn render_impl(

`

1878

1852

` cx,

`

1879

1853

` i,

`

1880

1854

` parent,

`

1881

``

`-

parent,

`

1882

1855

` rendering_params.show_def_docs,

`

1883

1856

` use_absolute,

`

1884

1857

` aliases,

`

`@@ -1926,20 +1899,14 @@ fn render_impl(

`

1926

1899

``

1927

1900

`// Render the items that appear on the right side of methods, impls, and

`

1928

1901

`// associated types. For example "1.0.0 (const: 1.39.0) · source".

`

1929

``

`-

fn render_rightside(

`

1930

``

`-

w: &mut Buffer,

`

1931

``

`-

cx: &Context<'_>,

`

1932

``

`-

item: &clean::Item,

`

1933

``

`-

containing_item: &clean::Item,

`

1934

``

`-

render_mode: RenderMode,

`

1935

``

`-

) {

`

``

1902

`+

fn render_rightside(w: &mut Buffer, cx: &Context<'_>, item: &clean::Item, render_mode: RenderMode) {

`

1936

1903

`let tcx = cx.tcx();

`

1937

1904

``

1938

1905

`// FIXME: Once https://github.com/rust-lang/rust/issues/67792 is implemented, we can remove

`

1939

1906

`// this condition.

`

1940

``

`-

let (const_stability, const_stable_since) = match render_mode {

`

1941

``

`-

RenderMode::Normal => (item.const_stability(tcx), containing_item.const_stable_since(tcx)),

`

1942

``

`-

RenderMode::ForDeref { .. } => (None, None),

`

``

1907

`+

let const_stability = match render_mode {

`

``

1908

`+

RenderMode::Normal => item.const_stability(tcx),

`

``

1909

`+

RenderMode::ForDeref { .. } => None,

`

1943

1910

`};

`

1944

1911

`let src_href = cx.src_href(item);

`

1945

1912

`let has_src_ref = src_href.is_some();

`

`@@ -1949,8 +1916,6 @@ fn render_rightside(

`

1949

1916

`&mut rightside,

`

1950

1917

` item.stable_since(tcx),

`

1951

1918

` const_stability,

`

1952

``

`-

containing_item.stable_since(tcx),

`

1953

``

`-

const_stable_since,

`

1954

1919

`if has_src_ref { "" } else { " rightside" },

`

1955

1920

`);

`

1956

1921

`if let Some(link) = src_href {

`

`@@ -1972,7 +1937,6 @@ pub(crate) fn render_impl_summary(

`

1972

1937

`cx: &mut Context<'_>,

`

1973

1938

`i: &Impl,

`

1974

1939

`parent: &clean::Item,

`

1975

``

`-

containing_item: &clean::Item,

`

1976

1940

`show_def_docs: bool,

`

1977

1941

`use_absolute: Option,

`

1978

1942

`// This argument is used to reference same type with different paths to avoid duplication

`

`@@ -1987,7 +1951,7 @@ pub(crate) fn render_impl_summary(

`

1987

1951

`format!(" data-aliases="{}"", aliases.join(","))

`

1988

1952

`};

`

1989

1953

`write!(w, "<section id="{id}" class="impl"{aliases}>");

`

1990

``

`-

render_rightside(w, cx, &i.impl_item, containing_item, RenderMode::Normal);

`

``

1954

`+

render_rightside(w, cx, &i.impl_item, RenderMode::Normal);

`

1991

1955

`write!(

`

1992

1956

` w,

`

1993

1957

`"<a href="#{id}" class="anchor">§\

`