Skip to content

Commit a5ebf34

Browse files
committed
Fix HTML test failures
1 parent 50e4a66 commit a5ebf34

File tree

1 file changed

+31
-0
lines changed
  • src/librustdoc/html/render

1 file changed

+31
-0
lines changed

src/librustdoc/html/render/mod.rs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ use rustc_span::symbol::{kw, sym, Symbol};
5454
use serde::ser::SerializeSeq;
5555
use serde::{Serialize, Serializer};
5656

57+
use crate::clean::utils::print_const_expr;
5758
use crate::clean::{self, FakeDefId, GetDefId, RenderedLink, SelfTy};
5859
use crate::docfs::PathError;
5960
use crate::error::Error;
@@ -739,6 +740,7 @@ fn naive_assoc_href(it: &clean::Item, link: AssocItemLink<'_>, cx: &Context<'_>)
739740
let name = it.name.as_ref().unwrap();
740741
let ty = match it.type_() {
741742
Typedef | AssocType => AssocType,
743+
Constant | AssocConst => AssocConst,
742744
s => s,
743745
};
744746

@@ -1366,6 +1368,35 @@ fn render_impl(
13661368
w.write_str("</h4>");
13671369
}
13681370
}
1371+
clean::ConstantItem(clean::Constant {
1372+
type_: ref ty,
1373+
kind: clean::ConstantKind::Local { body, .. },
1374+
}) => {
1375+
let item_type = ItemType::AssocConst;
1376+
let source_id = format!("{}.{}", item_type, name);
1377+
let id = cx.derive_id(source_id.clone());
1378+
write!(w, "<h4 id=\"{}\" class=\"{}{}\"><code>", id, item_type, in_trait_class);
1379+
assoc_const(
1380+
w,
1381+
item,
1382+
ty,
1383+
Some(&print_const_expr(tcx, body)),
1384+
link.anchor(if trait_.is_some() { &source_id } else { &id }),
1385+
"",
1386+
cx,
1387+
);
1388+
w.write_str("</code>");
1389+
render_stability_since_raw(
1390+
w,
1391+
item.stable_since(tcx).as_deref(),
1392+
item.const_stable_since(tcx).as_deref(),
1393+
outer_version,
1394+
outer_const_version,
1395+
);
1396+
write!(w, "<a href=\"#{}\" class=\"anchor\"></a>", id);
1397+
write_srclink(cx, item, w);
1398+
w.write_str("</h4>");
1399+
}
13691400
clean::TypedefItem(ref tydef, _) => {
13701401
let source_id = format!("{}.{}", ItemType::AssocType, name);
13711402
let id = cx.derive_id(source_id.clone());

0 commit comments

Comments
 (0)