1
Fork 0

Update term for use in more places

Replace use of `ty()` on term and use it in more places. This will allow more flexibility in the
future, but slightly worried it allows items which are consts which only accept types.
This commit is contained in:
kadmin 2022-01-10 23:39:21 +00:00
parent 67f56671d0
commit e7529d6a38
31 changed files with 284 additions and 128 deletions

View file

@ -1442,11 +1442,11 @@ impl clean::TypeBinding {
display_fn(move |f| {
f.write_str(self.name.as_str())?;
match self.kind {
clean::TypeBindingKind::Equality { ref ty } => {
clean::TypeBindingKind::Equality { ref term } => {
if f.alternate() {
write!(f, " = {:#}", ty.print(cx))?;
write!(f, " = {:#}", term.print(cx))?;
} else {
write!(f, " = {}", ty.print(cx))?;
write!(f, " = {}", term.print(cx))?;
}
}
clean::TypeBindingKind::Constraint { ref bounds } => {
@ -1492,6 +1492,18 @@ impl clean::GenericArg {
}
}
impl clean::types::Term {
crate fn print<'a, 'tcx: 'a>(
&'a self,
cx: &'a Context<'tcx>,
) -> impl fmt::Display + 'a + Captures<'tcx> {
match self {
clean::types::Term::Type(ty) => ty.print(cx),
_ => todo!(),
}
}
}
crate fn display_fn(f: impl FnOnce(&mut fmt::Formatter<'_>) -> fmt::Result) -> impl fmt::Display {
struct WithFormatter<F>(Cell<Option<F>>);