Implement Clean for const generics
Co-Authored-By: Gabriel Smith <yodaldevoid@users.noreply.github.com>
This commit is contained in:
parent
c915fe0245
commit
14913159e0
2 changed files with 25 additions and 0 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue