Remove Never variant from clean::Type enum

This commit is contained in:
Guillaume Gomez 2021-09-27 14:20:52 +02:00
parent 6df1d82869
commit bdd34717b8
5 changed files with 6 additions and 8 deletions

View File

@ -1313,7 +1313,7 @@ impl Clean<Type> for hir::Ty<'_> {
use rustc_hir::*;
match self.kind {
TyKind::Never => Never,
TyKind::Never => Primitive(PrimitiveType::Never),
TyKind::Ptr(ref m) => RawPointer(m.mutbl, box m.ty.clean(cx)),
TyKind::Rptr(ref l, ref m) => {
// There are two times a `Fresh` lifetime can be created:
@ -1402,7 +1402,7 @@ impl<'tcx> Clean<Type> for Ty<'tcx> {
trace!("cleaning type: {:?}", self);
let ty = normalize(cx, self).unwrap_or(self);
match *ty.kind() {
ty::Never => Never,
ty::Never => Primitive(PrimitiveType::Never),
ty::Bool => Primitive(PrimitiveType::Bool),
ty::Char => Primitive(PrimitiveType::Char),
ty::Int(int_ty) => Primitive(int_ty.into()),

View File

@ -1396,7 +1396,6 @@ crate enum Type {
Slice(Box<Type>),
/// The `String` field is about the size or the constant representing the array's length.
Array(Box<Type>, String),
Never,
RawPointer(Mutability, Box<Type>),
BorrowedRef {
lifetime: Option<Lifetime>,
@ -1462,7 +1461,6 @@ impl Type {
}
RawPointer(..) => Some(PrimitiveType::RawPointer),
BareFunction(..) => Some(PrimitiveType::Fn),
Never => Some(PrimitiveType::Never),
_ => None,
}
}
@ -1550,7 +1548,6 @@ impl Type {
}
}
BareFunction(..) => PrimitiveType::Fn,
Never => PrimitiveType::Never,
Slice(..) => PrimitiveType::Slice,
Array(..) => PrimitiveType::Array,
RawPointer(..) => PrimitiveType::RawPointer,

View File

@ -761,6 +761,9 @@ fn fmt_type<'cx>(
fmt::Display::fmt(&tybounds(bounds, lt, cx), f)
}
clean::Infer => write!(f, "_"),
clean::Primitive(clean::PrimitiveType::Never) => {
primitive_link(f, PrimitiveType::Never, "!", cx)
}
clean::Primitive(prim) => primitive_link(f, prim, &*prim.as_sym().as_str(), cx),
clean::BareFunction(ref decl) => {
if f.alternate() {
@ -819,7 +822,6 @@ fn fmt_type<'cx>(
primitive_link(f, PrimitiveType::Array, &format!("; {}]", Escape(n)), cx)
}
}
clean::Never => primitive_link(f, PrimitiveType::Never, "!", cx),
clean::RawPointer(m, ref t) => {
let m = match m {
hir::Mutability::Mut => "mut",

View File

@ -244,7 +244,6 @@ fn get_index_type_name(clean_type: &clean::Type, accept_generic: bool) -> Option
| clean::Tuple(_)
| clean::Slice(_)
| clean::Array(_, _)
| clean::Never
| clean::RawPointer(_, _)
| clean::QPath { .. }
| clean::Infer

View File

@ -417,13 +417,13 @@ impl FromWithTcx<clean::Type> for Type {
}
}
Generic(s) => Type::Generic(s.to_string()),
Primitive(clean::PrimitiveType::Never) => Type::Never,
Primitive(p) => Type::Primitive(p.as_sym().to_string()),
BareFunction(f) => Type::FunctionPointer(Box::new((*f).into_tcx(tcx))),
Tuple(t) => Type::Tuple(t.into_iter().map(|x| x.into_tcx(tcx)).collect()),
Slice(t) => Type::Slice(Box::new((*t).into_tcx(tcx))),
Array(t, s) => Type::Array { type_: Box::new((*t).into_tcx(tcx)), len: s },
ImplTrait(g) => Type::ImplTrait(g.into_iter().map(|x| x.into_tcx(tcx)).collect()),
Never => Type::Never,
Infer => Type::Infer,
RawPointer(mutability, type_) => Type::RawPointer {
mutable: mutability == ast::Mutability::Mut,