Improve code by replacing &str with Symbol in render_stability_since_raw
This commit is contained in:
parent
0c1b0f7757
commit
b647c90262
3 changed files with 15 additions and 19 deletions
|
@ -602,16 +602,16 @@ impl Item {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
crate fn stable_since(&self, tcx: TyCtxt<'_>) -> Option<SymbolStr> {
|
crate fn stable_since(&self, tcx: TyCtxt<'_>) -> Option<Symbol> {
|
||||||
match self.stability(tcx)?.level {
|
match self.stability(tcx)?.level {
|
||||||
StabilityLevel::Stable { since, .. } => Some(since.as_str()),
|
StabilityLevel::Stable { since, .. } => Some(since),
|
||||||
StabilityLevel::Unstable { .. } => None,
|
StabilityLevel::Unstable { .. } => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
crate fn const_stable_since(&self, tcx: TyCtxt<'_>) -> Option<SymbolStr> {
|
crate fn const_stable_since(&self, tcx: TyCtxt<'_>) -> Option<Symbol> {
|
||||||
match self.const_stability(tcx)?.level {
|
match self.const_stability(tcx)?.level {
|
||||||
StabilityLevel::Stable { since, .. } => Some(since.as_str()),
|
StabilityLevel::Stable { since, .. } => Some(since),
|
||||||
StabilityLevel::Unstable { .. } => None,
|
StabilityLevel::Unstable { .. } => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -804,17 +804,17 @@ fn assoc_type(
|
||||||
|
|
||||||
fn render_stability_since_raw(
|
fn render_stability_since_raw(
|
||||||
w: &mut Buffer,
|
w: &mut Buffer,
|
||||||
ver: Option<&str>,
|
ver: Option<Symbol>,
|
||||||
const_stability: Option<&ConstStability>,
|
const_stability: Option<&ConstStability>,
|
||||||
containing_ver: Option<&str>,
|
containing_ver: Option<Symbol>,
|
||||||
containing_const_ver: Option<&str>,
|
containing_const_ver: Option<Symbol>,
|
||||||
) {
|
) {
|
||||||
let ver = ver.filter(|inner| !inner.is_empty());
|
let ver = ver.filter(|inner| !inner.is_empty());
|
||||||
|
|
||||||
match (ver, const_stability) {
|
match (ver, const_stability) {
|
||||||
// stable and const stable
|
// stable and const stable
|
||||||
(Some(v), Some(ConstStability { level: StabilityLevel::Stable { since }, .. }))
|
(Some(v), Some(ConstStability { level: StabilityLevel::Stable { since }, .. }))
|
||||||
if Some(since.as_str()).as_deref() != containing_const_ver =>
|
if Some(*since) != containing_const_ver =>
|
||||||
{
|
{
|
||||||
write!(
|
write!(
|
||||||
w,
|
w,
|
||||||
|
@ -1651,23 +1651,19 @@ fn render_rightside(
|
||||||
) {
|
) {
|
||||||
let tcx = cx.tcx();
|
let tcx = cx.tcx();
|
||||||
|
|
||||||
let const_stable_since;
|
|
||||||
// FIXME: Once https://github.com/rust-lang/rust/issues/67792 is implemented, we can remove
|
// FIXME: Once https://github.com/rust-lang/rust/issues/67792 is implemented, we can remove
|
||||||
// this condition.
|
// this condition.
|
||||||
let (const_stability, const_stable_since) = match render_mode {
|
let (const_stability, const_stable_since) = match render_mode {
|
||||||
RenderMode::Normal => {
|
RenderMode::Normal => (item.const_stability(tcx), containing_item.const_stable_since(tcx)),
|
||||||
const_stable_since = containing_item.const_stable_since(tcx);
|
|
||||||
(item.const_stability(tcx), const_stable_since.as_deref())
|
|
||||||
}
|
|
||||||
RenderMode::ForDeref { .. } => (None, None),
|
RenderMode::ForDeref { .. } => (None, None),
|
||||||
};
|
};
|
||||||
|
|
||||||
write!(w, "<div class=\"rightside\">");
|
write!(w, "<div class=\"rightside\">");
|
||||||
render_stability_since_raw(
|
render_stability_since_raw(
|
||||||
w,
|
w,
|
||||||
item.stable_since(tcx).as_deref(),
|
item.stable_since(tcx),
|
||||||
const_stability,
|
const_stability,
|
||||||
containing_item.stable_since(tcx).as_deref(),
|
containing_item.stable_since(tcx),
|
||||||
const_stable_since,
|
const_stable_since,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -101,7 +101,7 @@ pub(super) fn print_item(
|
||||||
let mut stability_since_raw = Buffer::new();
|
let mut stability_since_raw = Buffer::new();
|
||||||
render_stability_since_raw(
|
render_stability_since_raw(
|
||||||
&mut stability_since_raw,
|
&mut stability_since_raw,
|
||||||
item.stable_since(cx.tcx()).as_deref(),
|
item.stable_since(cx.tcx()),
|
||||||
item.const_stability(cx.tcx()),
|
item.const_stability(cx.tcx()),
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
|
@ -1462,10 +1462,10 @@ fn render_stability_since(
|
||||||
) {
|
) {
|
||||||
render_stability_since_raw(
|
render_stability_since_raw(
|
||||||
w,
|
w,
|
||||||
item.stable_since(tcx).as_deref(),
|
item.stable_since(tcx),
|
||||||
item.const_stability(tcx),
|
item.const_stability(tcx),
|
||||||
containing_item.stable_since(tcx).as_deref(),
|
containing_item.stable_since(tcx),
|
||||||
containing_item.const_stable_since(tcx).as_deref(),
|
containing_item.const_stable_since(tcx),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue