rustdoc: Show "const" for const-unstable if also overall unstable · rust-lang/rust@699d28f (original) (raw)

`@@ -13,7 +13,7 @@ use std::fmt::{self, Display, Write};

`

13

13

`use std::iter::{self, once};

`

14

14

``

15

15

`use rustc_ast as ast;

`

16

``

`-

use rustc_attr::{ConstStability, StabilityLevel};

`

``

16

`+

use rustc_attr::{ConstStability, StabilityLevel, StableSince};

`

17

17

`use rustc_data_structures::captures::Captures;

`

18

18

`use rustc_data_structures::fx::FxHashSet;

`

19

19

`use rustc_hir as hir;

`

`@@ -1633,17 +1633,24 @@ impl PrintWithSpace for hir::Mutability {

`

1633

1633

``

1634

1634

`pub(crate) fn print_constness_with_space(

`

1635

1635

`c: &hir::Constness,

`

1636

``

`-

s: Option,

`

``

1636

`+

overall_stab: Option,

`

``

1637

`+

const_stab: Option,

`

1637

1638

`) -> &'static str {

`

1638

``

`-

match (c, s) {

`

1639

``

`-

// const stable or when feature(staged_api) is not set

`

1640

``

`-

(

`

1641

``

`-

hir::Constness::Const,

`

1642

``

`-

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

`

1643

``

`-

)

`

1644

``

`-

| (hir::Constness::Const, None) => "const ",

`

1645

``

`-

// const unstable or not const

`

1646

``

`-

_ => "",

`

``

1639

`+

match c {

`

``

1640

`+

hir::Constness::Const => match (overall_stab, const_stab) {

`

``

1641

`+

// const stable...

`

``

1642

`+

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

`

``

1643

`+

// ...or when feature(staged_api) is not set...

`

``

1644

`+

| (_, None)

`

``

1645

`+

// ...or when const unstable, but overall unstable too

`

``

1646

`+

| (None, Some(ConstStability { level: StabilityLevel::Unstable { .. }, .. })) => {

`

``

1647

`+

"const "

`

``

1648

`+

}

`

``

1649

`+

// const unstable (and overall stable)

`

``

1650

`+

(Some(_), Some(ConstStability { level: StabilityLevel::Unstable { .. }, .. })) => "",

`

``

1651

`+

},

`

``

1652

`+

// not const

`

``

1653

`+

hir::Constness::NotConst => "",

`

1647

1654

`}

`

1648

1655

`}

`

1649

1656

``