diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 5a22614fc71c..0f976c11938c 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -2921,6 +2921,25 @@ impl<'tcx> Clean for Ty<'tcx> { } } +impl<'tcx> Clean for ty::LazyConst<'tcx> { + fn clean(&self, cx: &DocContext<'_>) -> Constant { + if let ty::LazyConst::Evaluated(ct) = self { + ct.clean(cx) + } else { + unimplemented!() // FIXME(const_generics) + } + } +} + +impl<'tcx> Clean for ty::Const<'tcx> { + fn clean(&self, cx: &DocContext<'_>) -> Constant { + Constant { + type_: self.ty.clean(cx), + expr: format!("{:?}", self.val), // FIXME(const_generics) + } + } +} + impl Clean for hir::StructField { fn clean(&self, cx: &DocContext<'_>) -> Item { let local_did = cx.tcx.hir().local_def_id_from_hir_id(self.hir_id); diff --git a/src/librustdoc/html/format.rs b/src/librustdoc/html/format.rs index 36257914d192..2cba3c58889a 100644 --- a/src/librustdoc/html/format.rs +++ b/src/librustdoc/html/format.rs @@ -259,6 +259,12 @@ impl fmt::Display for clean::Lifetime { } } +impl fmt::Display for clean::Constant { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "{}: {}", self.expr, self.type_) + } +} + impl fmt::Display for clean::PolyTrait { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { if !self.generic_params.is_empty() {