Skip to content

Commit 8e21be7

Browse files
committed
rustdoc: Remove OpaqueTy
It turns out it's never constructed anywhere.
1 parent e2cf31a commit 8e21be7

File tree

15 files changed

+7
-87
lines changed

15 files changed

+7
-87
lines changed

src/librustdoc/clean/mod.rs

-4
Original file line numberDiff line numberDiff line change
@@ -2735,10 +2735,6 @@ fn clean_maybe_renamed_item<'tcx>(
27352735
Box::new(clean_ty(ty, cx)),
27362736
Constant { kind: ConstantKind::Local { body: body_id, def_id } },
27372737
),
2738-
ItemKind::OpaqueTy(ref ty) => OpaqueTyItem(OpaqueTy {
2739-
bounds: ty.bounds.iter().filter_map(|x| clean_generic_bound(x, cx)).collect(),
2740-
generics: clean_generics(ty.generics, cx),
2741-
}),
27422738
ItemKind::TyAlias(hir_ty, generics) => {
27432739
*cx.current_type_aliases.entry(def_id).or_insert(0) += 1;
27442740
let rustdoc_ty = clean_ty(hir_ty, cx);

src/librustdoc/clean/types.rs

-9
Original file line numberDiff line numberDiff line change
@@ -828,7 +828,6 @@ pub(crate) enum ItemKind {
828828
FunctionItem(Box<Function>),
829829
ModuleItem(Module),
830830
TypeAliasItem(Box<TypeAlias>),
831-
OpaqueTyItem(OpaqueTy),
832831
StaticItem(Static),
833832
TraitItem(Box<Trait>),
834833
TraitAliasItem(TraitAlias),
@@ -886,7 +885,6 @@ impl ItemKind {
886885
| ImportItem(_)
887886
| FunctionItem(_)
888887
| TypeAliasItem(_)
889-
| OpaqueTyItem(_)
890888
| StaticItem(_)
891889
| ConstantItem(_, _, _)
892890
| TraitAliasItem(_)
@@ -920,7 +918,6 @@ impl ItemKind {
920918
| ExternCrateItem { .. }
921919
| FunctionItem(_)
922920
| TypeAliasItem(_)
923-
| OpaqueTyItem(_)
924921
| StaticItem(_)
925922
| ConstantItem(_, _, _)
926923
| TraitAliasItem(_)
@@ -2341,12 +2338,6 @@ pub(crate) struct TypeAlias {
23412338
pub(crate) item_type: Option<Type>,
23422339
}
23432340

2344-
#[derive(Clone, Debug)]
2345-
pub(crate) struct OpaqueTy {
2346-
pub(crate) bounds: Vec<GenericBound>,
2347-
pub(crate) generics: Generics,
2348-
}
2349-
23502341
#[derive(Clone, PartialEq, Eq, Debug, Hash)]
23512342
pub(crate) struct BareFunctionDecl {
23522343
pub(crate) safety: hir::Safety,

src/librustdoc/fold.rs

-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ pub(crate) trait DocFolder: Sized {
7777
ExternCrateItem { src: _ }
7878
| ImportItem(_)
7979
| FunctionItem(_)
80-
| OpaqueTyItem(_)
8180
| StaticItem(_)
8281
| ConstantItem(_, _, _)
8382
| TraitAliasItem(_)

src/librustdoc/formats/cache.rs

-1
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,6 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> {
462462

463463
clean::ExternCrateItem { .. }
464464
| clean::ImportItem(..)
465-
| clean::OpaqueTyItem(..)
466465
| clean::ImplItem(..)
467466
| clean::TyMethodItem(..)
468467
| clean::MethodItem(..)

src/librustdoc/formats/item_type.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ pub(crate) enum ItemType {
5252
AssocConst = 19,
5353
Union = 20,
5454
ForeignType = 21,
55-
OpaqueTy = 22,
55+
// OpaqueTy used to be here, but it was removed in #127276
5656
ProcAttribute = 23,
5757
ProcDerive = 24,
5858
TraitAlias = 25,
@@ -85,7 +85,6 @@ impl<'a> From<&'a clean::Item> for ItemType {
8585
clean::EnumItem(..) => ItemType::Enum,
8686
clean::FunctionItem(..) => ItemType::Function,
8787
clean::TypeAliasItem(..) => ItemType::TypeAlias,
88-
clean::OpaqueTyItem(..) => ItemType::OpaqueTy,
8988
clean::StaticItem(..) => ItemType::Static,
9089
clean::ConstantItem(..) => ItemType::Constant,
9190
clean::TraitItem(..) => ItemType::Trait,
@@ -192,7 +191,6 @@ impl ItemType {
192191
ItemType::AssocConst => "associatedconstant",
193192
ItemType::ForeignType => "foreigntype",
194193
ItemType::Keyword => "keyword",
195-
ItemType::OpaqueTy => "opaque",
196194
ItemType::ProcAttribute => "attr",
197195
ItemType::ProcDerive => "derive",
198196
ItemType::TraitAlias => "traitalias",

src/librustdoc/html/render/mod.rs

-2
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,6 @@ impl AllTypes {
382382
ItemType::Macro => self.macros.insert(ItemEntry::new(new_url, name)),
383383
ItemType::Function => self.functions.insert(ItemEntry::new(new_url, name)),
384384
ItemType::TypeAlias => self.type_aliases.insert(ItemEntry::new(new_url, name)),
385-
ItemType::OpaqueTy => self.opaque_tys.insert(ItemEntry::new(new_url, name)),
386385
ItemType::Static => self.statics.insert(ItemEntry::new(new_url, name)),
387386
ItemType::Constant => self.constants.insert(ItemEntry::new(new_url, name)),
388387
ItemType::ProcAttribute => {
@@ -2284,7 +2283,6 @@ fn item_ty_to_section(ty: ItemType) -> ItemSection {
22842283
ItemType::AssocConst => ItemSection::AssociatedConstants,
22852284
ItemType::ForeignType => ItemSection::ForeignTypes,
22862285
ItemType::Keyword => ItemSection::Keywords,
2287-
ItemType::OpaqueTy => ItemSection::OpaqueTypes,
22882286
ItemType::ProcAttribute => ItemSection::AttributeMacros,
22892287
ItemType::ProcDerive => ItemSection::DeriveMacros,
22902288
ItemType::TraitAlias => ItemSection::TraitAliases,

src/librustdoc/html/render/print_item.rs

-31
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,6 @@ pub(super) fn print_item(cx: &mut Context<'_>, item: &clean::Item, buf: &mut Buf
202202
clean::ConstantItem(..) => "Constant ",
203203
clean::ForeignTypeItem => "Foreign Type ",
204204
clean::KeywordItem => "Keyword ",
205-
clean::OpaqueTyItem(..) => "Opaque Type ",
206205
clean::TraitAliasItem(..) => "Trait Alias ",
207206
_ => {
208207
// We don't generate pages for any other type.
@@ -270,7 +269,6 @@ pub(super) fn print_item(cx: &mut Context<'_>, item: &clean::Item, buf: &mut Buf
270269
clean::ConstantItem(generics, ty, c) => item_constant(buf, cx, item, generics, ty, c),
271270
clean::ForeignTypeItem => item_foreign_type(buf, cx, item),
272271
clean::KeywordItem => item_keyword(buf, cx, item),
273-
clean::OpaqueTyItem(ref e) => item_opaque_ty(buf, cx, item, e),
274272
clean::TraitAliasItem(ref ta) => item_trait_alias(buf, cx, item, ta),
275273
_ => {
276274
// We don't generate pages for any other type.
@@ -1210,35 +1208,6 @@ fn item_trait_alias(
12101208
.unwrap();
12111209
}
12121210

1213-
fn item_opaque_ty(
1214-
w: &mut impl fmt::Write,
1215-
cx: &mut Context<'_>,
1216-
it: &clean::Item,
1217-
t: &clean::OpaqueTy,
1218-
) {
1219-
wrap_item(w, |w| {
1220-
write!(
1221-
w,
1222-
"{attrs}type {name}{generics}{where_clause} = impl {bounds};",
1223-
attrs = render_attributes_in_pre(it, "", cx),
1224-
name = it.name.unwrap(),
1225-
generics = t.generics.print(cx),
1226-
where_clause = print_where_clause(&t.generics, cx, 0, Ending::Newline),
1227-
bounds = bounds(&t.bounds, false, cx),
1228-
)
1229-
.unwrap();
1230-
});
1231-
1232-
write!(w, "{}", document(cx, it, None, HeadingOffset::H2)).unwrap();
1233-
1234-
// Render any items associated directly to this alias, as otherwise they
1235-
// won't be visible anywhere in the docs. It would be nice to also show
1236-
// associated items from the aliased type (see discussion in #32077), but
1237-
// we need #14072 to make sense of the generics.
1238-
write!(w, "{}", render_assoc_items(cx, it, it.item_id.expect_def_id(), AssocItemRender::All))
1239-
.unwrap();
1240-
}
1241-
12421211
fn item_type_alias(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, t: &clean::TypeAlias) {
12431212
wrap_item(w, |w| {
12441213
write!(

src/librustdoc/json/conversions.rs

-8
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,6 @@ fn from_clean_item(item: clean::Item, tcx: TyCtxt<'_>) -> ItemEnum {
323323
ForeignStaticItem(s, _) => ItemEnum::Static(s.into_tcx(tcx)),
324324
ForeignTypeItem => ItemEnum::ForeignType,
325325
TypeAliasItem(t) => ItemEnum::TypeAlias(t.into_tcx(tcx)),
326-
OpaqueTyItem(t) => ItemEnum::OpaqueTy(t.into_tcx(tcx)),
327326
// FIXME(generic_const_items): Add support for generic free consts
328327
ConstantItem(_generics, t, c) => {
329328
ItemEnum::Constant { type_: (*t).into_tcx(tcx), const_: c.into_tcx(tcx) }
@@ -819,12 +818,6 @@ impl FromWithTcx<Box<clean::TypeAlias>> for TypeAlias {
819818
}
820819
}
821820

822-
impl FromWithTcx<clean::OpaqueTy> for OpaqueTy {
823-
fn from_tcx(opaque: clean::OpaqueTy, tcx: TyCtxt<'_>) -> Self {
824-
OpaqueTy { bounds: opaque.bounds.into_tcx(tcx), generics: opaque.generics.into_tcx(tcx) }
825-
}
826-
}
827-
828821
impl FromWithTcx<clean::Static> for Static {
829822
fn from_tcx(stat: clean::Static, tcx: TyCtxt<'_>) -> Self {
830823
Static {
@@ -856,7 +849,6 @@ impl FromWithTcx<ItemType> for ItemKind {
856849
Enum => ItemKind::Enum,
857850
Function | TyMethod | Method => ItemKind::Function,
858851
TypeAlias => ItemKind::TypeAlias,
859-
OpaqueTy => ItemKind::OpaqueTy,
860852
Static => ItemKind::Static,
861853
Constant => ItemKind::Constant,
862854
Trait => ItemKind::Trait,

src/librustdoc/json/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,6 @@ impl<'tcx> FormatRenderer<'tcx> for JsonRenderer<'tcx> {
185185
| types::ItemEnum::TraitAlias(_)
186186
| types::ItemEnum::Impl(_)
187187
| types::ItemEnum::TypeAlias(_)
188-
| types::ItemEnum::OpaqueTy(_)
189188
| types::ItemEnum::Constant { .. }
190189
| types::ItemEnum::Static(_)
191190
| types::ItemEnum::ForeignType

src/librustdoc/passes/stripper.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,7 @@ impl<'a, 'tcx> DocFolder for Stripper<'a, 'tcx> {
4949
return Some(ret);
5050
}
5151
// These items can all get re-exported
52-
clean::OpaqueTyItem(..)
53-
| clean::TypeAliasItem(..)
52+
clean::TypeAliasItem(..)
5453
| clean::StaticItem(..)
5554
| clean::StructItem(..)
5655
| clean::EnumItem(..)

src/librustdoc/visit.rs

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ pub(crate) trait DocVisitor: Sized {
2626
| ImportItem(_)
2727
| FunctionItem(_)
2828
| TypeAliasItem(_)
29-
| OpaqueTyItem(_)
3029
| StaticItem(_)
3130
| ConstantItem(_, _, _)
3231
| TraitAliasItem(_)

src/rustdoc-json-types/lib.rs

+1-9
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use serde::{Deserialize, Serialize};
88
use std::path::PathBuf;
99

1010
/// rustdoc format-version.
11-
pub const FORMAT_VERSION: u32 = 31;
11+
pub const FORMAT_VERSION: u32 = 32;
1212

1313
/// A `Crate` is the root of the emitted JSON blob. It contains all type/documentation information
1414
/// about the language items in the local crate, as well as info about external items to allow
@@ -214,7 +214,6 @@ pub enum ItemKind {
214214
Variant,
215215
Function,
216216
TypeAlias,
217-
OpaqueTy,
218217
Constant,
219218
Trait,
220219
TraitAlias,
@@ -253,7 +252,6 @@ pub enum ItemEnum {
253252
Impl(Impl),
254253

255254
TypeAlias(TypeAlias),
256-
OpaqueTy(OpaqueTy),
257255
Constant {
258256
#[serde(rename = "type")]
259257
type_: Type,
@@ -725,12 +723,6 @@ pub struct TypeAlias {
725723
pub generics: Generics,
726724
}
727725

728-
#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
729-
pub struct OpaqueTy {
730-
pub bounds: Vec<GenericBound>,
731-
pub generics: Generics,
732-
}
733-
734726
#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
735727
pub struct Static {
736728
#[serde(rename = "type")]

src/tools/jsondoclint/src/item_kind.rs

-5
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ pub(crate) enum Kind {
1313
Variant,
1414
Function,
1515
TypeAlias,
16-
OpaqueTy,
1716
Constant,
1817
Trait,
1918
TraitAlias,
@@ -55,7 +54,6 @@ impl Kind {
5554

5655
// FIXME(adotinthevoid): I'm not sure if these are correct
5756
Keyword => false,
58-
OpaqueTy => false,
5957
ProcAttribute => false,
6058
ProcDerive => false,
6159

@@ -99,7 +97,6 @@ impl Kind {
9997
Kind::Enum => false,
10098
Kind::Variant => false,
10199
Kind::TypeAlias => false,
102-
Kind::OpaqueTy => false,
103100
Kind::Constant => false,
104101
Kind::Trait => false,
105102
Kind::TraitAlias => false,
@@ -149,7 +146,6 @@ impl Kind {
149146
ItemEnum::TraitAlias(_) => TraitAlias,
150147
ItemEnum::Impl(_) => Impl,
151148
ItemEnum::TypeAlias(_) => TypeAlias,
152-
ItemEnum::OpaqueTy(_) => OpaqueTy,
153149
ItemEnum::Constant { .. } => Constant,
154150
ItemEnum::Static(_) => Static,
155151
ItemEnum::Macro(_) => Macro,
@@ -177,7 +173,6 @@ impl Kind {
177173
ItemKind::Keyword => Keyword,
178174
ItemKind::Macro => Macro,
179175
ItemKind::Module => Module,
180-
ItemKind::OpaqueTy => OpaqueTy,
181176
ItemKind::Primitive => Primitive,
182177
ItemKind::ProcAttribute => ProcAttribute,
183178
ItemKind::ProcDerive => ProcDerive,

src/tools/jsondoclint/src/validator.rs

+3-9
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ use std::hash::Hash;
33

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

@@ -100,7 +100,6 @@ impl<'a> Validator<'a> {
100100
ItemEnum::TraitAlias(x) => self.check_trait_alias(x),
101101
ItemEnum::Impl(x) => self.check_impl(x, id),
102102
ItemEnum::TypeAlias(x) => self.check_type_alias(x),
103-
ItemEnum::OpaqueTy(x) => self.check_opaque_ty(x),
104103
ItemEnum::Constant { type_, const_ } => {
105104
self.check_type(type_);
106105
self.check_constant(const_);
@@ -229,11 +228,6 @@ impl<'a> Validator<'a> {
229228
self.check_type(&x.type_);
230229
}
231230

232-
fn check_opaque_ty(&mut self, x: &'a OpaqueTy) {
233-
x.bounds.iter().for_each(|b| self.check_generic_bound(b));
234-
self.check_generics(&x.generics);
235-
}
236-
237231
fn check_constant(&mut self, _x: &'a Constant) {
238232
// nop
239233
}

0 commit comments

Comments
 (0)