未验证 提交 8dfe5229 编写于 作者: E Eric Huss 提交者: GitHub

Rollup merge of #89297 - GuillaumeGomez:remove-never-from-type-enum, r=camelid

Remove Never variant from clean::Type enum

Fixes #89287.

r? ``@camelid``
......@@ -1313,7 +1313,7 @@ fn clean(&self, cx: &mut DocContext<'_>) -> Type {
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 @@ fn clean(&self, cx: &mut DocContext<'_>) -> Type {
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()),
......
......@@ -1396,7 +1396,6 @@ fn def_id_full(&self, cache: &Cache) -> Option<DefId> {
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 @@ fn inner_def_id(&self, cache: Option<&Cache>) -> Option<DefId> {
}
}
BareFunction(..) => PrimitiveType::Fn,
Never => PrimitiveType::Never,
Slice(..) => PrimitiveType::Slice,
Array(..) => PrimitiveType::Array,
RawPointer(..) => PrimitiveType::RawPointer,
......
......@@ -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",
......
......@@ -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
......
......@@ -417,13 +417,13 @@ fn from_tcx(ty: clean::Type, tcx: TyCtxt<'_>) -> Self {
}
}
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,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册