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

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

`

955

955

`/// consequence of the above rules.

`

956

956

`fn render_stability_since_raw_with_extra(

`

957

957

`w: &mut Buffer,

`

958

``

`-

ver: Option,

`

``

958

`+

stable_version: Option,

`

959

959

`const_stability: Option,

`

960

``

`-

containing_ver: Option,

`

961

``

`-

containing_const_ver: Option,

`

962

960

`extra_class: &str,

`

963

961

`) -> bool {

`

964

``

`-

let stable_version = if ver != containing_ver

`

965

``

`-

&& let Some(ver) = &ver

`

966

``

`-

{

`

967

``

`-

since_to_string(ver)

`

968

``

`-

} else {

`

969

``

`-

None

`

970

``

`-

};

`

971

``

-

972

962

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

`

973

963

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

`

974

964

``

975

``

`-

if let Some(ver) = stable_version {

`

976

``

`-

stability.push_str(ver.as_str());

`

977

``

`-

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

`

``

965

`+

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

`

``

966

`+

stability.push_str(&version);

`

``

967

`+

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

`

978

968

`}

`

979

969

``

980

970

`let const_title_and_stability = match const_stability {

`

981

``

`-

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

`

982

``

`-

if Some(since) != containing_const_ver =>

`

983

``

`-

{

`

``

971

`+

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

`

984

972

`since_to_string(&since)

`

985

973

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

`

986

974

`}

`

`@@ -1035,17 +1023,8 @@ fn render_stability_since_raw(

`

1035

1023

`w: &mut Buffer,

`

1036

1024

`ver: Option,

`

1037

1025

`const_stability: Option,

`

1038

``

`-

containing_ver: Option,

`

1039

``

`-

containing_const_ver: Option,

`

1040

1026

`) -> bool {

`

1041

``

`-

render_stability_since_raw_with_extra(

`

1042

``

`-

w,

`

1043

``

`-

ver,

`

1044

``

`-

const_stability,

`

1045

``

`-

containing_ver,

`

1046

``

`-

containing_const_ver,

`

1047

``

`-

"",

`

1048

``

`-

)

`

``

1027

`+

render_stability_since_raw_with_extra(w, ver, const_stability, "")

`

1049

1028

`}

`

1050

1029

``

1051

1030

`fn render_assoc_item(

`

`@@ -1535,7 +1514,6 @@ fn render_impl(

`

1535

1514

`cx: &mut Context<'_>,

`

1536

1515

`item: &clean::Item,

`

1537

1516

`parent: &clean::Item,

`

1538

``

`-

containing_item: &clean::Item,

`

1539

1517

`link: AssocItemLink<'_>,

`

1540

1518

`render_mode: RenderMode,

`

1541

1519

`is_default_item: bool,

`

`@@ -1630,7 +1608,7 @@ fn render_impl(

`

1630

1608

`})

`

1631

1609

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

`

1632

1610

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

`

1633

``

`-

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

`

``

1611

`+

render_rightside(w, cx, item, render_mode);

`

1634

1612

`if trait_.is_some() {

`

1635

1613

`// Anchors are only used on trait impls.

`

1636

1614

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

`

`@@ -1652,7 +1630,7 @@ fn render_impl(

`

1652

1630

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

`

1653

1631

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

`

1654

1632

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

`

1655

``

`-

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

`

``

1633

`+

render_rightside(w, cx, item, render_mode);

`

1656

1634

`if trait_.is_some() {

`

1657

1635

`// Anchors are only used on trait impls.

`

1658

1636

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

`

`@@ -1738,7 +1716,6 @@ fn render_impl(

`

1738

1716

` cx,

`

1739

1717

` trait_item,

`

1740

1718

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

`

1741

``

`-

parent,

`

1742

1719

` link,

`

1743

1720

` render_mode,

`

1744

1721

`false,

`

`@@ -1754,7 +1731,6 @@ fn render_impl(

`

1754

1731

`t: &clean::Trait,

`

1755

1732

`i: &clean::Impl,

`

1756

1733

`parent: &clean::Item,

`

1757

``

`-

containing_item: &clean::Item,

`

1758

1734

`render_mode: RenderMode,

`

1759

1735

`rendering_params: ImplRenderingParameters,

`

1760

1736

`) {

`

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

`

1782

1758

` cx,

`

1783

1759

` trait_item,

`

1784

1760

` parent,

`

1785

``

`-

containing_item,

`

1786

1761

` assoc_link,

`

1787

1762

` render_mode,

`

1788

1763

`true,

`

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

`

1805

1780

` t,

`

1806

1781

` i.inner_impl(),

`

1807

1782

`&i.impl_item,

`

1808

``

`-

parent,

`

1809

1783

` render_mode,

`

1810

1784

` rendering_params,

`

1811

1785

`);

`

`@@ -1827,7 +1801,6 @@ fn render_impl(

`

1827

1801

` cx,

`

1828

1802

` i,

`

1829

1803

` parent,

`

1830

``

`-

parent,

`

1831

1804

` rendering_params.show_def_docs,

`

1832

1805

` use_absolute,

`

1833

1806

` aliases,

`

`@@ -1875,20 +1848,14 @@ fn render_impl(

`

1875

1848

``

1876

1849

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

`

1877

1850

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

`

1878

``

`-

fn render_rightside(

`

1879

``

`-

w: &mut Buffer,

`

1880

``

`-

cx: &Context<'_>,

`

1881

``

`-

item: &clean::Item,

`

1882

``

`-

containing_item: &clean::Item,

`

1883

``

`-

render_mode: RenderMode,

`

1884

``

`-

) {

`

``

1851

`+

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

`

1885

1852

`let tcx = cx.tcx();

`

1886

1853

``

1887

1854

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

`

1888

1855

`// this condition.

`

1889

``

`-

let (const_stability, const_stable_since) = match render_mode {

`

1890

``

`-

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

`

1891

``

`-

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

`

``

1856

`+

let const_stability = match render_mode {

`

``

1857

`+

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

`

``

1858

`+

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

`

1892

1859

`};

`

1893

1860

`let src_href = cx.src_href(item);

`

1894

1861

`let has_src_ref = src_href.is_some();

`

`@@ -1898,8 +1865,6 @@ fn render_rightside(

`

1898

1865

`&mut rightside,

`

1899

1866

` item.stable_since(tcx),

`

1900

1867

` const_stability,

`

1901

``

`-

containing_item.stable_since(tcx),

`

1902

``

`-

const_stable_since,

`

1903

1868

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

`

1904

1869

`);

`

1905

1870

`if let Some(link) = src_href {

`

`@@ -1921,7 +1886,6 @@ pub(crate) fn render_impl_summary(

`

1921

1886

`cx: &mut Context<'_>,

`

1922

1887

`i: &Impl,

`

1923

1888

`parent: &clean::Item,

`

1924

``

`-

containing_item: &clean::Item,

`

1925

1889

`show_def_docs: bool,

`

1926

1890

`use_absolute: Option,

`

1927

1891

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

`

`@@ -1936,7 +1900,7 @@ pub(crate) fn render_impl_summary(

`

1936

1900

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

`

1937

1901

`};

`

1938

1902

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

`

1939

``

`-

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

`

``

1903

`+

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

`

1940

1904

`write!(

`

1941

1905

` w,

`

1942

1906

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

`