Check for const_unstable before printing const
This commit is contained in:
parent
9c495b30ef
commit
5fb27bca6c
4 changed files with 65 additions and 44 deletions
|
@ -9,6 +9,7 @@ use std::cell::Cell;
|
|||
use std::fmt;
|
||||
use std::iter;
|
||||
|
||||
use rustc_attr::{ConstStability, StabilityLevel};
|
||||
use rustc_data_structures::captures::Captures;
|
||||
use rustc_data_structures::fx::FxHashSet;
|
||||
use rustc_hir as hir;
|
||||
|
@ -1253,15 +1254,6 @@ impl PrintWithSpace for hir::Unsafety {
|
|||
}
|
||||
}
|
||||
|
||||
impl PrintWithSpace for hir::Constness {
|
||||
fn print_with_space(&self) -> &str {
|
||||
match self {
|
||||
hir::Constness::Const => "const ",
|
||||
hir::Constness::NotConst => "",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl PrintWithSpace for hir::IsAsync {
|
||||
fn print_with_space(&self) -> &str {
|
||||
match self {
|
||||
|
@ -1280,6 +1272,22 @@ impl PrintWithSpace for hir::Mutability {
|
|||
}
|
||||
}
|
||||
|
||||
crate fn print_constness_with_space(
|
||||
c: &hir::Constness,
|
||||
s: Option<&ConstStability>,
|
||||
) -> &'static str {
|
||||
match (c, s) {
|
||||
// const stable or no stability attribute
|
||||
(
|
||||
hir::Constness::Const,
|
||||
Some(ConstStability { level: StabilityLevel::Stable { .. }, .. }),
|
||||
)
|
||||
| (hir::Constness::Const, None) => "const ",
|
||||
// const unstable or not const
|
||||
(hir::Constness::Const, _) | (hir::Constness::NotConst, _) => "",
|
||||
}
|
||||
}
|
||||
|
||||
impl clean::Import {
|
||||
crate fn print<'a, 'tcx: 'a>(
|
||||
&'a self,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue