diff options
| -rw-r--r-- | src/librustdoc/clean/mod.rs | 19 | ||||
| -rw-r--r-- | src/librustdoc/html/format.rs | 6 |
2 files changed, 25 insertions, 0 deletions
diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 5a22614fc71..0f976c11938 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -2921,6 +2921,25 @@ impl<'tcx> Clean<Type> for Ty<'tcx> { } } +impl<'tcx> Clean<Constant> 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<Constant> 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<Item> 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 36257914d19..2cba3c58889 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() { |
