Skip to content

Commit

Permalink
rustdoc: Remove OpaqueTy
Browse files Browse the repository at this point in the history
It turns out it's never constructed anywhere.
  • Loading branch information
aDotInTheVoid committed Jul 4, 2024
1 parent e2cf31a commit 7c76747
Show file tree
Hide file tree
Showing 14 changed files with 6 additions and 86 deletions.
4 changes: 0 additions & 4 deletions src/librustdoc/clean/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2735,10 +2735,6 @@ fn clean_maybe_renamed_item<'tcx>(
Box::new(clean_ty(ty, cx)),
Constant { kind: ConstantKind::Local { body: body_id, def_id } },
),
ItemKind::OpaqueTy(ref ty) => OpaqueTyItem(OpaqueTy {
bounds: ty.bounds.iter().filter_map(|x| clean_generic_bound(x, cx)).collect(),
generics: clean_generics(ty.generics, cx),
}),
ItemKind::TyAlias(hir_ty, generics) => {
*cx.current_type_aliases.entry(def_id).or_insert(0) += 1;
let rustdoc_ty = clean_ty(hir_ty, cx);
Expand Down
9 changes: 0 additions & 9 deletions src/librustdoc/clean/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -828,7 +828,6 @@ pub(crate) enum ItemKind {
FunctionItem(Box<Function>),
ModuleItem(Module),
TypeAliasItem(Box<TypeAlias>),
OpaqueTyItem(OpaqueTy),
StaticItem(Static),
TraitItem(Box<Trait>),
TraitAliasItem(TraitAlias),
Expand Down Expand Up @@ -886,7 +885,6 @@ impl ItemKind {
| ImportItem(_)
| FunctionItem(_)
| TypeAliasItem(_)
| OpaqueTyItem(_)
| StaticItem(_)
| ConstantItem(_, _, _)
| TraitAliasItem(_)
Expand Down Expand Up @@ -920,7 +918,6 @@ impl ItemKind {
| ExternCrateItem { .. }
| FunctionItem(_)
| TypeAliasItem(_)
| OpaqueTyItem(_)
| StaticItem(_)
| ConstantItem(_, _, _)
| TraitAliasItem(_)
Expand Down Expand Up @@ -2341,12 +2338,6 @@ pub(crate) struct TypeAlias {
pub(crate) item_type: Option<Type>,
}

#[derive(Clone, Debug)]
pub(crate) struct OpaqueTy {
pub(crate) bounds: Vec<GenericBound>,
pub(crate) generics: Generics,
}

#[derive(Clone, PartialEq, Eq, Debug, Hash)]
pub(crate) struct BareFunctionDecl {
pub(crate) safety: hir::Safety,
Expand Down
1 change: 0 additions & 1 deletion src/librustdoc/fold.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ pub(crate) trait DocFolder: Sized {
ExternCrateItem { src: _ }
| ImportItem(_)
| FunctionItem(_)
| OpaqueTyItem(_)
| StaticItem(_)
| ConstantItem(_, _, _)
| TraitAliasItem(_)
Expand Down
1 change: 0 additions & 1 deletion src/librustdoc/formats/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,6 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> {

clean::ExternCrateItem { .. }
| clean::ImportItem(..)
| clean::OpaqueTyItem(..)
| clean::ImplItem(..)
| clean::TyMethodItem(..)
| clean::MethodItem(..)
Expand Down
4 changes: 1 addition & 3 deletions src/librustdoc/formats/item_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ pub(crate) enum ItemType {
AssocConst = 19,
Union = 20,
ForeignType = 21,
OpaqueTy = 22,
// OpaqueTy used to be here, but it was removed in #127276
ProcAttribute = 23,
ProcDerive = 24,
TraitAlias = 25,
Expand Down Expand Up @@ -85,7 +85,6 @@ impl<'a> From<&'a clean::Item> for ItemType {
clean::EnumItem(..) => ItemType::Enum,
clean::FunctionItem(..) => ItemType::Function,
clean::TypeAliasItem(..) => ItemType::TypeAlias,
clean::OpaqueTyItem(..) => ItemType::OpaqueTy,
clean::StaticItem(..) => ItemType::Static,
clean::ConstantItem(..) => ItemType::Constant,
clean::TraitItem(..) => ItemType::Trait,
Expand Down Expand Up @@ -192,7 +191,6 @@ impl ItemType {
ItemType::AssocConst => "associatedconstant",
ItemType::ForeignType => "foreigntype",
ItemType::Keyword => "keyword",
ItemType::OpaqueTy => "opaque",
ItemType::ProcAttribute => "attr",
ItemType::ProcDerive => "derive",
ItemType::TraitAlias => "traitalias",
Expand Down
2 changes: 0 additions & 2 deletions src/librustdoc/html/render/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,6 @@ impl AllTypes {
ItemType::Macro => self.macros.insert(ItemEntry::new(new_url, name)),
ItemType::Function => self.functions.insert(ItemEntry::new(new_url, name)),
ItemType::TypeAlias => self.type_aliases.insert(ItemEntry::new(new_url, name)),
ItemType::OpaqueTy => self.opaque_tys.insert(ItemEntry::new(new_url, name)),
ItemType::Static => self.statics.insert(ItemEntry::new(new_url, name)),
ItemType::Constant => self.constants.insert(ItemEntry::new(new_url, name)),
ItemType::ProcAttribute => {
Expand Down Expand Up @@ -2284,7 +2283,6 @@ fn item_ty_to_section(ty: ItemType) -> ItemSection {
ItemType::AssocConst => ItemSection::AssociatedConstants,
ItemType::ForeignType => ItemSection::ForeignTypes,
ItemType::Keyword => ItemSection::Keywords,
ItemType::OpaqueTy => ItemSection::OpaqueTypes,
ItemType::ProcAttribute => ItemSection::AttributeMacros,
ItemType::ProcDerive => ItemSection::DeriveMacros,
ItemType::TraitAlias => ItemSection::TraitAliases,
Expand Down
31 changes: 0 additions & 31 deletions src/librustdoc/html/render/print_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,6 @@ pub(super) fn print_item(cx: &mut Context<'_>, item: &clean::Item, buf: &mut Buf
clean::ConstantItem(..) => "Constant ",
clean::ForeignTypeItem => "Foreign Type ",
clean::KeywordItem => "Keyword ",
clean::OpaqueTyItem(..) => "Opaque Type ",
clean::TraitAliasItem(..) => "Trait Alias ",
_ => {
// We don't generate pages for any other type.
Expand Down Expand Up @@ -270,7 +269,6 @@ pub(super) fn print_item(cx: &mut Context<'_>, item: &clean::Item, buf: &mut Buf
clean::ConstantItem(generics, ty, c) => item_constant(buf, cx, item, generics, ty, c),
clean::ForeignTypeItem => item_foreign_type(buf, cx, item),
clean::KeywordItem => item_keyword(buf, cx, item),
clean::OpaqueTyItem(ref e) => item_opaque_ty(buf, cx, item, e),
clean::TraitAliasItem(ref ta) => item_trait_alias(buf, cx, item, ta),
_ => {
// We don't generate pages for any other type.
Expand Down Expand Up @@ -1210,35 +1208,6 @@ fn item_trait_alias(
.unwrap();
}

fn item_opaque_ty(
w: &mut impl fmt::Write,
cx: &mut Context<'_>,
it: &clean::Item,
t: &clean::OpaqueTy,
) {
wrap_item(w, |w| {
write!(
w,
"{attrs}type {name}{generics}{where_clause} = impl {bounds};",
attrs = render_attributes_in_pre(it, "", cx),
name = it.name.unwrap(),
generics = t.generics.print(cx),
where_clause = print_where_clause(&t.generics, cx, 0, Ending::Newline),
bounds = bounds(&t.bounds, false, cx),
)
.unwrap();
});

write!(w, "{}", document(cx, it, None, HeadingOffset::H2)).unwrap();

// Render any items associated directly to this alias, as otherwise they
// won't be visible anywhere in the docs. It would be nice to also show
// associated items from the aliased type (see discussion in #32077), but
// we need #14072 to make sense of the generics.
write!(w, "{}", render_assoc_items(cx, it, it.item_id.expect_def_id(), AssocItemRender::All))
.unwrap();
}

fn item_type_alias(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, t: &clean::TypeAlias) {
wrap_item(w, |w| {
write!(
Expand Down
8 changes: 0 additions & 8 deletions src/librustdoc/json/conversions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,6 @@ fn from_clean_item(item: clean::Item, tcx: TyCtxt<'_>) -> ItemEnum {
ForeignStaticItem(s, _) => ItemEnum::Static(s.into_tcx(tcx)),
ForeignTypeItem => ItemEnum::ForeignType,
TypeAliasItem(t) => ItemEnum::TypeAlias(t.into_tcx(tcx)),
OpaqueTyItem(t) => ItemEnum::OpaqueTy(t.into_tcx(tcx)),
// FIXME(generic_const_items): Add support for generic free consts
ConstantItem(_generics, t, c) => {
ItemEnum::Constant { type_: (*t).into_tcx(tcx), const_: c.into_tcx(tcx) }
Expand Down Expand Up @@ -819,12 +818,6 @@ impl FromWithTcx<Box<clean::TypeAlias>> for TypeAlias {
}
}

impl FromWithTcx<clean::OpaqueTy> for OpaqueTy {
fn from_tcx(opaque: clean::OpaqueTy, tcx: TyCtxt<'_>) -> Self {
OpaqueTy { bounds: opaque.bounds.into_tcx(tcx), generics: opaque.generics.into_tcx(tcx) }
}
}

impl FromWithTcx<clean::Static> for Static {
fn from_tcx(stat: clean::Static, tcx: TyCtxt<'_>) -> Self {
Static {
Expand Down Expand Up @@ -856,7 +849,6 @@ impl FromWithTcx<ItemType> for ItemKind {
Enum => ItemKind::Enum,
Function | TyMethod | Method => ItemKind::Function,
TypeAlias => ItemKind::TypeAlias,
OpaqueTy => ItemKind::OpaqueTy,
Static => ItemKind::Static,
Constant => ItemKind::Constant,
Trait => ItemKind::Trait,
Expand Down
1 change: 0 additions & 1 deletion src/librustdoc/json/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,6 @@ impl<'tcx> FormatRenderer<'tcx> for JsonRenderer<'tcx> {
| types::ItemEnum::TraitAlias(_)
| types::ItemEnum::Impl(_)
| types::ItemEnum::TypeAlias(_)
| types::ItemEnum::OpaqueTy(_)
| types::ItemEnum::Constant { .. }
| types::ItemEnum::Static(_)
| types::ItemEnum::ForeignType
Expand Down
3 changes: 1 addition & 2 deletions src/librustdoc/passes/stripper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ impl<'a, 'tcx> DocFolder for Stripper<'a, 'tcx> {
return Some(ret);
}
// These items can all get re-exported
clean::OpaqueTyItem(..)
| clean::TypeAliasItem(..)
clean::TypeAliasItem(..)
| clean::StaticItem(..)
| clean::StructItem(..)
| clean::EnumItem(..)
Expand Down
1 change: 0 additions & 1 deletion src/librustdoc/visit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ pub(crate) trait DocVisitor: Sized {
| ImportItem(_)
| FunctionItem(_)
| TypeAliasItem(_)
| OpaqueTyItem(_)
| StaticItem(_)
| ConstantItem(_, _, _)
| TraitAliasItem(_)
Expand Down
10 changes: 1 addition & 9 deletions src/rustdoc-json-types/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use serde::{Deserialize, Serialize};
use std::path::PathBuf;

/// rustdoc format-version.
pub const FORMAT_VERSION: u32 = 31;
pub const FORMAT_VERSION: u32 = 32;

/// A `Crate` is the root of the emitted JSON blob. It contains all type/documentation information
/// about the language items in the local crate, as well as info about external items to allow
Expand Down Expand Up @@ -214,7 +214,6 @@ pub enum ItemKind {
Variant,
Function,
TypeAlias,
OpaqueTy,
Constant,
Trait,
TraitAlias,
Expand Down Expand Up @@ -253,7 +252,6 @@ pub enum ItemEnum {
Impl(Impl),

TypeAlias(TypeAlias),
OpaqueTy(OpaqueTy),
Constant {
#[serde(rename = "type")]
type_: Type,
Expand Down Expand Up @@ -725,12 +723,6 @@ pub struct TypeAlias {
pub generics: Generics,
}

#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct OpaqueTy {
pub bounds: Vec<GenericBound>,
pub generics: Generics,
}

#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct Static {
#[serde(rename = "type")]
Expand Down
5 changes: 0 additions & 5 deletions src/tools/jsondoclint/src/item_kind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ pub(crate) enum Kind {
Variant,
Function,
TypeAlias,
OpaqueTy,
Constant,
Trait,
TraitAlias,
Expand Down Expand Up @@ -55,7 +54,6 @@ impl Kind {

// FIXME(adotinthevoid): I'm not sure if these are correct
Keyword => false,
OpaqueTy => false,
ProcAttribute => false,
ProcDerive => false,

Expand Down Expand Up @@ -99,7 +97,6 @@ impl Kind {
Kind::Enum => false,
Kind::Variant => false,
Kind::TypeAlias => false,
Kind::OpaqueTy => false,
Kind::Constant => false,
Kind::Trait => false,
Kind::TraitAlias => false,
Expand Down Expand Up @@ -149,7 +146,6 @@ impl Kind {
ItemEnum::TraitAlias(_) => TraitAlias,
ItemEnum::Impl(_) => Impl,
ItemEnum::TypeAlias(_) => TypeAlias,
ItemEnum::OpaqueTy(_) => OpaqueTy,
ItemEnum::Constant { .. } => Constant,
ItemEnum::Static(_) => Static,
ItemEnum::Macro(_) => Macro,
Expand Down Expand Up @@ -177,7 +173,6 @@ impl Kind {
ItemKind::Keyword => Keyword,
ItemKind::Macro => Macro,
ItemKind::Module => Module,
ItemKind::OpaqueTy => OpaqueTy,
ItemKind::Primitive => Primitive,
ItemKind::ProcAttribute => ProcAttribute,
ItemKind::ProcDerive => ProcDerive,
Expand Down
12 changes: 3 additions & 9 deletions src/tools/jsondoclint/src/validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ use std::hash::Hash;

use rustdoc_json_types::{
Constant, Crate, DynTrait, Enum, FnDecl, Function, FunctionPointer, GenericArg, GenericArgs,
GenericBound, GenericParamDef, Generics, Id, Impl, Import, ItemEnum, ItemSummary, Module,
OpaqueTy, Path, Primitive, ProcMacro, Static, Struct, StructKind, Term, Trait, TraitAlias,
Type, TypeAlias, TypeBinding, TypeBindingKind, Union, Variant, VariantKind, WherePredicate,
GenericBound, GenericParamDef, Generics, Id, Impl, Import, ItemEnum, ItemSummary, Module, Path,
Primitive, ProcMacro, Static, Struct, StructKind, Term, Trait, TraitAlias, Type, TypeAlias,
TypeBinding, TypeBindingKind, Union, Variant, VariantKind, WherePredicate,
};
use serde_json::Value;

Expand Down Expand Up @@ -100,7 +100,6 @@ impl<'a> Validator<'a> {
ItemEnum::TraitAlias(x) => self.check_trait_alias(x),
ItemEnum::Impl(x) => self.check_impl(x, id),
ItemEnum::TypeAlias(x) => self.check_type_alias(x),
ItemEnum::OpaqueTy(x) => self.check_opaque_ty(x),
ItemEnum::Constant { type_, const_ } => {
self.check_type(type_);
self.check_constant(const_);
Expand Down Expand Up @@ -229,11 +228,6 @@ impl<'a> Validator<'a> {
self.check_type(&x.type_);
}

fn check_opaque_ty(&mut self, x: &'a OpaqueTy) {
x.bounds.iter().for_each(|b| self.check_generic_bound(b));
self.check_generics(&x.generics);
}

fn check_constant(&mut self, _x: &'a Constant) {
// nop
}
Expand Down

0 comments on commit 7c76747

Please sign in to comment.