Skip to content

Commit 18fd2db

Browse files
Rollup merge of rust-lang#89297 - GuillaumeGomez:remove-never-from-type-enum, r=camelid
Remove Never variant from clean::Type enum Fixes rust-lang#89287. r? `@camelid`
2 parents d21761a + bdd3471 commit 18fd2db

File tree

5 files changed

+6
-8
lines changed

5 files changed

+6
-8
lines changed

src/librustdoc/clean/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1313,7 +1313,7 @@ impl Clean<Type> for hir::Ty<'_> {
13131313
use rustc_hir::*;
13141314

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

src/librustdoc/clean/types.rs

-3
Original file line numberDiff line numberDiff line change
@@ -1396,7 +1396,6 @@ crate enum Type {
13961396
Slice(Box<Type>),
13971397
/// The `String` field is about the size or the constant representing the array's length.
13981398
Array(Box<Type>, String),
1399-
Never,
14001399
RawPointer(Mutability, Box<Type>),
14011400
BorrowedRef {
14021401
lifetime: Option<Lifetime>,
@@ -1462,7 +1461,6 @@ impl Type {
14621461
}
14631462
RawPointer(..) => Some(PrimitiveType::RawPointer),
14641463
BareFunction(..) => Some(PrimitiveType::Fn),
1465-
Never => Some(PrimitiveType::Never),
14661464
_ => None,
14671465
}
14681466
}
@@ -1550,7 +1548,6 @@ impl Type {
15501548
}
15511549
}
15521550
BareFunction(..) => PrimitiveType::Fn,
1553-
Never => PrimitiveType::Never,
15541551
Slice(..) => PrimitiveType::Slice,
15551552
Array(..) => PrimitiveType::Array,
15561553
RawPointer(..) => PrimitiveType::RawPointer,

src/librustdoc/html/format.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -761,6 +761,9 @@ fn fmt_type<'cx>(
761761
fmt::Display::fmt(&tybounds(bounds, lt, cx), f)
762762
}
763763
clean::Infer => write!(f, "_"),
764+
clean::Primitive(clean::PrimitiveType::Never) => {
765+
primitive_link(f, PrimitiveType::Never, "!", cx)
766+
}
764767
clean::Primitive(prim) => primitive_link(f, prim, &*prim.as_sym().as_str(), cx),
765768
clean::BareFunction(ref decl) => {
766769
if f.alternate() {
@@ -819,7 +822,6 @@ fn fmt_type<'cx>(
819822
primitive_link(f, PrimitiveType::Array, &format!("; {}]", Escape(n)), cx)
820823
}
821824
}
822-
clean::Never => primitive_link(f, PrimitiveType::Never, "!", cx),
823825
clean::RawPointer(m, ref t) => {
824826
let m = match m {
825827
hir::Mutability::Mut => "mut",

src/librustdoc/html/render/cache.rs

-1
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,6 @@ fn get_index_type_name(clean_type: &clean::Type, accept_generic: bool) -> Option
244244
| clean::Tuple(_)
245245
| clean::Slice(_)
246246
| clean::Array(_, _)
247-
| clean::Never
248247
| clean::RawPointer(_, _)
249248
| clean::QPath { .. }
250249
| clean::Infer

src/librustdoc/json/conversions.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -417,13 +417,13 @@ impl FromWithTcx<clean::Type> for Type {
417417
}
418418
}
419419
Generic(s) => Type::Generic(s.to_string()),
420+
Primitive(clean::PrimitiveType::Never) => Type::Never,
420421
Primitive(p) => Type::Primitive(p.as_sym().to_string()),
421422
BareFunction(f) => Type::FunctionPointer(Box::new((*f).into_tcx(tcx))),
422423
Tuple(t) => Type::Tuple(t.into_iter().map(|x| x.into_tcx(tcx)).collect()),
423424
Slice(t) => Type::Slice(Box::new((*t).into_tcx(tcx))),
424425
Array(t, s) => Type::Array { type_: Box::new((*t).into_tcx(tcx)), len: s },
425426
ImplTrait(g) => Type::ImplTrait(g.into_iter().map(|x| x.into_tcx(tcx)).collect()),
426-
Never => Type::Never,
427427
Infer => Type::Infer,
428428
RawPointer(mutability, type_) => Type::RawPointer {
429429
mutable: mutability == ast::Mutability::Mut,

0 commit comments

Comments
 (0)