Skip to content

Commit 8e86c95

Browse files
committed
Auto merge of rust-lang#127276 - aDotInTheVoid:no-opaque, r=camelid
rustdoc: Remove OpaqueTy r? `@ghost` Apparently this works lol?!? try-job: aarch64-apple
2 parents a886938 + 73ac5e0 commit 8e86c95

File tree

16 files changed

+56
-87
lines changed

16 files changed

+56
-87
lines changed

src/librustdoc/clean/mod.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2748,10 +2748,9 @@ fn clean_maybe_renamed_item<'tcx>(
27482748
type_: clean_ty(ty, cx),
27492749
kind: ConstantKind::Local { body: body_id, def_id },
27502750
})),
2751-
ItemKind::OpaqueTy(ref ty) => OpaqueTyItem(OpaqueTy {
2752-
bounds: ty.bounds.iter().filter_map(|x| clean_generic_bound(x, cx)).collect(),
2753-
generics: clean_generics(ty.generics, cx),
2754-
}),
2751+
// clean_ty changes types which reference an OpaqueTy item to instead be
2752+
// an ImplTrait, so it's ok to return nothing here.
2753+
ItemKind::OpaqueTy(_) => return vec![],
27552754
ItemKind::TyAlias(hir_ty, generics) => {
27562755
*cx.current_type_aliases.entry(def_id).or_insert(0) += 1;
27572756
let rustdoc_ty = clean_ty(hir_ty, cx);
@@ -2834,7 +2833,7 @@ fn clean_maybe_renamed_item<'tcx>(
28342833
ItemKind::Use(path, kind) => {
28352834
return clean_use_statement(item, name, path, kind, cx, &mut FxHashSet::default());
28362835
}
2837-
_ => unreachable!("not yet converted"),
2836+
_ => span_bug!(item.span, "not yet converted"),
28382837
};
28392838

28402839
vec![generate_item_with_correct_attrs(

src/librustdoc/clean/types.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -824,7 +824,6 @@ pub(crate) enum ItemKind {
824824
FunctionItem(Box<Function>),
825825
ModuleItem(Module),
826826
TypeAliasItem(Box<TypeAlias>),
827-
OpaqueTyItem(OpaqueTy),
828827
StaticItem(Static),
829828
TraitItem(Box<Trait>),
830829
TraitAliasItem(TraitAlias),
@@ -882,7 +881,6 @@ impl ItemKind {
882881
| ImportItem(_)
883882
| FunctionItem(_)
884883
| TypeAliasItem(_)
885-
| OpaqueTyItem(_)
886884
| StaticItem(_)
887885
| ConstantItem(_)
888886
| TraitAliasItem(_)
@@ -916,7 +914,6 @@ impl ItemKind {
916914
| ExternCrateItem { .. }
917915
| FunctionItem(_)
918916
| TypeAliasItem(_)
919-
| OpaqueTyItem(_)
920917
| StaticItem(_)
921918
| ConstantItem(_)
922919
| TraitAliasItem(_)
@@ -2339,12 +2336,6 @@ pub(crate) struct TypeAlias {
23392336
pub(crate) item_type: Option<Type>,
23402337
}
23412338

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

src/librustdoc/fold.rs

Lines changed: 0 additions & 1 deletion
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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,6 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> {
463463

464464
clean::ExternCrateItem { .. }
465465
| clean::ImportItem(..)
466-
| clean::OpaqueTyItem(..)
467466
| clean::ImplItem(..)
468467
| clean::TyMethodItem(..)
469468
| clean::MethodItem(..)

src/librustdoc/formats/item_type.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ pub(crate) enum ItemType {
5151
AssocConst = 19,
5252
Union = 20,
5353
ForeignType = 21,
54-
OpaqueTy = 22,
54+
// OpaqueTy used to be here, but it was removed in #127276
5555
ProcAttribute = 23,
5656
ProcDerive = 24,
5757
TraitAlias = 25,
@@ -84,7 +84,6 @@ impl<'a> From<&'a clean::Item> for ItemType {
8484
clean::EnumItem(..) => ItemType::Enum,
8585
clean::FunctionItem(..) => ItemType::Function,
8686
clean::TypeAliasItem(..) => ItemType::TypeAlias,
87-
clean::OpaqueTyItem(..) => ItemType::OpaqueTy,
8887
clean::StaticItem(..) => ItemType::Static,
8988
clean::ConstantItem(..) => ItemType::Constant,
9089
clean::TraitItem(..) => ItemType::Trait,
@@ -191,7 +190,6 @@ impl ItemType {
191190
ItemType::AssocConst => "associatedconstant",
192191
ItemType::ForeignType => "foreigntype",
193192
ItemType::Keyword => "keyword",
194-
ItemType::OpaqueTy => "opaque",
195193
ItemType::ProcAttribute => "attr",
196194
ItemType::ProcDerive => "derive",
197195
ItemType::TraitAlias => "traitalias",

src/librustdoc/html/render/mod.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,6 @@ impl AllTypes {
376376
ItemType::Macro => self.macros.insert(ItemEntry::new(new_url, name)),
377377
ItemType::Function => self.functions.insert(ItemEntry::new(new_url, name)),
378378
ItemType::TypeAlias => self.type_aliases.insert(ItemEntry::new(new_url, name)),
379-
ItemType::OpaqueTy => self.opaque_tys.insert(ItemEntry::new(new_url, name)),
380379
ItemType::Static => self.statics.insert(ItemEntry::new(new_url, name)),
381380
ItemType::Constant => self.constants.insert(ItemEntry::new(new_url, name)),
382381
ItemType::ProcAttribute => {
@@ -2299,7 +2298,6 @@ fn item_ty_to_section(ty: ItemType) -> ItemSection {
22992298
ItemType::AssocConst => ItemSection::AssociatedConstants,
23002299
ItemType::ForeignType => ItemSection::ForeignTypes,
23012300
ItemType::Keyword => ItemSection::Keywords,
2302-
ItemType::OpaqueTy => ItemSection::OpaqueTypes,
23032301
ItemType::ProcAttribute => ItemSection::AttributeMacros,
23042302
ItemType::ProcDerive => ItemSection::DeriveMacros,
23052303
ItemType::TraitAlias => ItemSection::TraitAliases,

src/librustdoc/html/render/print_item.rs

Lines changed: 0 additions & 31 deletions
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(ci) => item_constant(buf, cx, item, &ci.generics, &ci.type_, &ci.kind),
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.
@@ -1197,35 +1195,6 @@ fn item_trait_alias(
11971195
.unwrap();
11981196
}
11991197

1200-
fn item_opaque_ty(
1201-
w: &mut impl fmt::Write,
1202-
cx: &mut Context<'_>,
1203-
it: &clean::Item,
1204-
t: &clean::OpaqueTy,
1205-
) {
1206-
wrap_item(w, |w| {
1207-
write!(
1208-
w,
1209-
"{attrs}type {name}{generics}{where_clause} = impl {bounds};",
1210-
attrs = render_attributes_in_pre(it, "", cx),
1211-
name = it.name.unwrap(),
1212-
generics = t.generics.print(cx),
1213-
where_clause = print_where_clause(&t.generics, cx, 0, Ending::Newline),
1214-
bounds = bounds(&t.bounds, false, cx),
1215-
)
1216-
.unwrap();
1217-
});
1218-
1219-
write!(w, "{}", document(cx, it, None, HeadingOffset::H2)).unwrap();
1220-
1221-
// Render any items associated directly to this alias, as otherwise they
1222-
// won't be visible anywhere in the docs. It would be nice to also show
1223-
// associated items from the aliased type (see discussion in #32077), but
1224-
// we need #14072 to make sense of the generics.
1225-
write!(w, "{}", render_assoc_items(cx, it, it.item_id.expect_def_id(), AssocItemRender::All))
1226-
.unwrap();
1227-
}
1228-
12291198
fn item_type_alias(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, t: &clean::TypeAlias) {
12301199
wrap_item(w, |w| {
12311200
write!(

src/librustdoc/json/conversions.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,6 @@ fn from_clean_item(item: clean::Item, tcx: TyCtxt<'_>) -> ItemEnum {
333333
ForeignStaticItem(s, _) => ItemEnum::Static(s.into_tcx(tcx)),
334334
ForeignTypeItem => ItemEnum::ForeignType,
335335
TypeAliasItem(t) => ItemEnum::TypeAlias(t.into_tcx(tcx)),
336-
OpaqueTyItem(t) => ItemEnum::OpaqueTy(t.into_tcx(tcx)),
337336
// FIXME(generic_const_items): Add support for generic free consts
338337
ConstantItem(ci) => {
339338
ItemEnum::Constant { type_: ci.type_.into_tcx(tcx), const_: ci.kind.into_tcx(tcx) }
@@ -830,12 +829,6 @@ impl FromWithTcx<Box<clean::TypeAlias>> for TypeAlias {
830829
}
831830
}
832831

833-
impl FromWithTcx<clean::OpaqueTy> for OpaqueTy {
834-
fn from_tcx(opaque: clean::OpaqueTy, tcx: TyCtxt<'_>) -> Self {
835-
OpaqueTy { bounds: opaque.bounds.into_tcx(tcx), generics: opaque.generics.into_tcx(tcx) }
836-
}
837-
}
838-
839832
impl FromWithTcx<clean::Static> for Static {
840833
fn from_tcx(stat: clean::Static, tcx: TyCtxt<'_>) -> Self {
841834
Static {
@@ -867,7 +860,6 @@ impl FromWithTcx<ItemType> for ItemKind {
867860
Enum => ItemKind::Enum,
868861
Function | TyMethod | Method => ItemKind::Function,
869862
TypeAlias => ItemKind::TypeAlias,
870-
OpaqueTy => ItemKind::OpaqueTy,
871863
Static => ItemKind::Static,
872864
Constant => ItemKind::Constant,
873865
Trait => ItemKind::Trait,

src/librustdoc/json/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,6 @@ impl<'tcx> FormatRenderer<'tcx> for JsonRenderer<'tcx> {
184184
| types::ItemEnum::TraitAlias(_)
185185
| types::ItemEnum::Impl(_)
186186
| types::ItemEnum::TypeAlias(_)
187-
| types::ItemEnum::OpaqueTy(_)
188187
| types::ItemEnum::Constant { .. }
189188
| types::ItemEnum::Static(_)
190189
| types::ItemEnum::ForeignType

src/librustdoc/passes/stripper.rs

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

0 commit comments

Comments
 (0)