Auto merge of #127276 - aDotInTheVoid:no-opaque, r=camelid
rustdoc: Remove OpaqueTy r? `@ghost` Apparently this works lol?!? try-job: aarch64-apple
This commit is contained in:
commit
8e86c95671
@ -2748,10 +2748,9 @@ fn clean_maybe_renamed_item<'tcx>(
|
|||||||
type_: clean_ty(ty, cx),
|
type_: clean_ty(ty, cx),
|
||||||
kind: ConstantKind::Local { body: body_id, def_id },
|
kind: ConstantKind::Local { body: body_id, def_id },
|
||||||
})),
|
})),
|
||||||
ItemKind::OpaqueTy(ref ty) => OpaqueTyItem(OpaqueTy {
|
// clean_ty changes types which reference an OpaqueTy item to instead be
|
||||||
bounds: ty.bounds.iter().filter_map(|x| clean_generic_bound(x, cx)).collect(),
|
// an ImplTrait, so it's ok to return nothing here.
|
||||||
generics: clean_generics(ty.generics, cx),
|
ItemKind::OpaqueTy(_) => return vec![],
|
||||||
}),
|
|
||||||
ItemKind::TyAlias(hir_ty, generics) => {
|
ItemKind::TyAlias(hir_ty, generics) => {
|
||||||
*cx.current_type_aliases.entry(def_id).or_insert(0) += 1;
|
*cx.current_type_aliases.entry(def_id).or_insert(0) += 1;
|
||||||
let rustdoc_ty = clean_ty(hir_ty, cx);
|
let rustdoc_ty = clean_ty(hir_ty, cx);
|
||||||
@ -2834,7 +2833,7 @@ fn clean_maybe_renamed_item<'tcx>(
|
|||||||
ItemKind::Use(path, kind) => {
|
ItemKind::Use(path, kind) => {
|
||||||
return clean_use_statement(item, name, path, kind, cx, &mut FxHashSet::default());
|
return clean_use_statement(item, name, path, kind, cx, &mut FxHashSet::default());
|
||||||
}
|
}
|
||||||
_ => unreachable!("not yet converted"),
|
_ => span_bug!(item.span, "not yet converted"),
|
||||||
};
|
};
|
||||||
|
|
||||||
vec![generate_item_with_correct_attrs(
|
vec![generate_item_with_correct_attrs(
|
||||||
|
@ -824,7 +824,6 @@ pub(crate) enum ItemKind {
|
|||||||
FunctionItem(Box<Function>),
|
FunctionItem(Box<Function>),
|
||||||
ModuleItem(Module),
|
ModuleItem(Module),
|
||||||
TypeAliasItem(Box<TypeAlias>),
|
TypeAliasItem(Box<TypeAlias>),
|
||||||
OpaqueTyItem(OpaqueTy),
|
|
||||||
StaticItem(Static),
|
StaticItem(Static),
|
||||||
TraitItem(Box<Trait>),
|
TraitItem(Box<Trait>),
|
||||||
TraitAliasItem(TraitAlias),
|
TraitAliasItem(TraitAlias),
|
||||||
@ -882,7 +881,6 @@ pub(crate) fn inner_items(&self) -> impl Iterator<Item = &Item> {
|
|||||||
| ImportItem(_)
|
| ImportItem(_)
|
||||||
| FunctionItem(_)
|
| FunctionItem(_)
|
||||||
| TypeAliasItem(_)
|
| TypeAliasItem(_)
|
||||||
| OpaqueTyItem(_)
|
|
||||||
| StaticItem(_)
|
| StaticItem(_)
|
||||||
| ConstantItem(_)
|
| ConstantItem(_)
|
||||||
| TraitAliasItem(_)
|
| TraitAliasItem(_)
|
||||||
@ -916,7 +914,6 @@ pub(crate) fn is_non_assoc(&self) -> bool {
|
|||||||
| ExternCrateItem { .. }
|
| ExternCrateItem { .. }
|
||||||
| FunctionItem(_)
|
| FunctionItem(_)
|
||||||
| TypeAliasItem(_)
|
| TypeAliasItem(_)
|
||||||
| OpaqueTyItem(_)
|
|
||||||
| StaticItem(_)
|
| StaticItem(_)
|
||||||
| ConstantItem(_)
|
| ConstantItem(_)
|
||||||
| TraitAliasItem(_)
|
| TraitAliasItem(_)
|
||||||
@ -2339,12 +2336,6 @@ pub(crate) struct TypeAlias {
|
|||||||
pub(crate) item_type: Option<Type>,
|
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)]
|
#[derive(Clone, PartialEq, Eq, Debug, Hash)]
|
||||||
pub(crate) struct BareFunctionDecl {
|
pub(crate) struct BareFunctionDecl {
|
||||||
pub(crate) safety: hir::Safety,
|
pub(crate) safety: hir::Safety,
|
||||||
|
@ -77,7 +77,6 @@ fn fold_inner_recur(&mut self, kind: ItemKind) -> ItemKind {
|
|||||||
ExternCrateItem { src: _ }
|
ExternCrateItem { src: _ }
|
||||||
| ImportItem(_)
|
| ImportItem(_)
|
||||||
| FunctionItem(_)
|
| FunctionItem(_)
|
||||||
| OpaqueTyItem(_)
|
|
||||||
| StaticItem(_)
|
| StaticItem(_)
|
||||||
| ConstantItem(..)
|
| ConstantItem(..)
|
||||||
| TraitAliasItem(_)
|
| TraitAliasItem(_)
|
||||||
|
@ -463,7 +463,6 @@ fn is_from_private_dep(tcx: TyCtxt<'_>, cache: &Cache, def_id: DefId) -> bool {
|
|||||||
|
|
||||||
clean::ExternCrateItem { .. }
|
clean::ExternCrateItem { .. }
|
||||||
| clean::ImportItem(..)
|
| clean::ImportItem(..)
|
||||||
| clean::OpaqueTyItem(..)
|
|
||||||
| clean::ImplItem(..)
|
| clean::ImplItem(..)
|
||||||
| clean::TyMethodItem(..)
|
| clean::TyMethodItem(..)
|
||||||
| clean::MethodItem(..)
|
| clean::MethodItem(..)
|
||||||
|
@ -51,7 +51,7 @@ pub(crate) enum ItemType {
|
|||||||
AssocConst = 19,
|
AssocConst = 19,
|
||||||
Union = 20,
|
Union = 20,
|
||||||
ForeignType = 21,
|
ForeignType = 21,
|
||||||
OpaqueTy = 22,
|
// OpaqueTy used to be here, but it was removed in #127276
|
||||||
ProcAttribute = 23,
|
ProcAttribute = 23,
|
||||||
ProcDerive = 24,
|
ProcDerive = 24,
|
||||||
TraitAlias = 25,
|
TraitAlias = 25,
|
||||||
@ -84,7 +84,6 @@ fn from(item: &'a clean::Item) -> ItemType {
|
|||||||
clean::EnumItem(..) => ItemType::Enum,
|
clean::EnumItem(..) => ItemType::Enum,
|
||||||
clean::FunctionItem(..) => ItemType::Function,
|
clean::FunctionItem(..) => ItemType::Function,
|
||||||
clean::TypeAliasItem(..) => ItemType::TypeAlias,
|
clean::TypeAliasItem(..) => ItemType::TypeAlias,
|
||||||
clean::OpaqueTyItem(..) => ItemType::OpaqueTy,
|
|
||||||
clean::StaticItem(..) => ItemType::Static,
|
clean::StaticItem(..) => ItemType::Static,
|
||||||
clean::ConstantItem(..) => ItemType::Constant,
|
clean::ConstantItem(..) => ItemType::Constant,
|
||||||
clean::TraitItem(..) => ItemType::Trait,
|
clean::TraitItem(..) => ItemType::Trait,
|
||||||
@ -191,7 +190,6 @@ pub(crate) fn as_str(&self) -> &'static str {
|
|||||||
ItemType::AssocConst => "associatedconstant",
|
ItemType::AssocConst => "associatedconstant",
|
||||||
ItemType::ForeignType => "foreigntype",
|
ItemType::ForeignType => "foreigntype",
|
||||||
ItemType::Keyword => "keyword",
|
ItemType::Keyword => "keyword",
|
||||||
ItemType::OpaqueTy => "opaque",
|
|
||||||
ItemType::ProcAttribute => "attr",
|
ItemType::ProcAttribute => "attr",
|
||||||
ItemType::ProcDerive => "derive",
|
ItemType::ProcDerive => "derive",
|
||||||
ItemType::TraitAlias => "traitalias",
|
ItemType::TraitAlias => "traitalias",
|
||||||
|
@ -376,7 +376,6 @@ fn append(&mut self, item_name: String, item_type: &ItemType) {
|
|||||||
ItemType::Macro => self.macros.insert(ItemEntry::new(new_url, name)),
|
ItemType::Macro => self.macros.insert(ItemEntry::new(new_url, name)),
|
||||||
ItemType::Function => self.functions.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::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::Static => self.statics.insert(ItemEntry::new(new_url, name)),
|
||||||
ItemType::Constant => self.constants.insert(ItemEntry::new(new_url, name)),
|
ItemType::Constant => self.constants.insert(ItemEntry::new(new_url, name)),
|
||||||
ItemType::ProcAttribute => {
|
ItemType::ProcAttribute => {
|
||||||
@ -2299,7 +2298,6 @@ fn item_ty_to_section(ty: ItemType) -> ItemSection {
|
|||||||
ItemType::AssocConst => ItemSection::AssociatedConstants,
|
ItemType::AssocConst => ItemSection::AssociatedConstants,
|
||||||
ItemType::ForeignType => ItemSection::ForeignTypes,
|
ItemType::ForeignType => ItemSection::ForeignTypes,
|
||||||
ItemType::Keyword => ItemSection::Keywords,
|
ItemType::Keyword => ItemSection::Keywords,
|
||||||
ItemType::OpaqueTy => ItemSection::OpaqueTypes,
|
|
||||||
ItemType::ProcAttribute => ItemSection::AttributeMacros,
|
ItemType::ProcAttribute => ItemSection::AttributeMacros,
|
||||||
ItemType::ProcDerive => ItemSection::DeriveMacros,
|
ItemType::ProcDerive => ItemSection::DeriveMacros,
|
||||||
ItemType::TraitAlias => ItemSection::TraitAliases,
|
ItemType::TraitAlias => ItemSection::TraitAliases,
|
||||||
|
@ -202,7 +202,6 @@ pub(super) fn print_item(cx: &mut Context<'_>, item: &clean::Item, buf: &mut Buf
|
|||||||
clean::ConstantItem(..) => "Constant ",
|
clean::ConstantItem(..) => "Constant ",
|
||||||
clean::ForeignTypeItem => "Foreign Type ",
|
clean::ForeignTypeItem => "Foreign Type ",
|
||||||
clean::KeywordItem => "Keyword ",
|
clean::KeywordItem => "Keyword ",
|
||||||
clean::OpaqueTyItem(..) => "Opaque Type ",
|
|
||||||
clean::TraitAliasItem(..) => "Trait Alias ",
|
clean::TraitAliasItem(..) => "Trait Alias ",
|
||||||
_ => {
|
_ => {
|
||||||
// We don't generate pages for any other type.
|
// 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
|
|||||||
clean::ConstantItem(ci) => item_constant(buf, cx, item, &ci.generics, &ci.type_, &ci.kind),
|
clean::ConstantItem(ci) => item_constant(buf, cx, item, &ci.generics, &ci.type_, &ci.kind),
|
||||||
clean::ForeignTypeItem => item_foreign_type(buf, cx, item),
|
clean::ForeignTypeItem => item_foreign_type(buf, cx, item),
|
||||||
clean::KeywordItem => item_keyword(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),
|
clean::TraitAliasItem(ref ta) => item_trait_alias(buf, cx, item, ta),
|
||||||
_ => {
|
_ => {
|
||||||
// We don't generate pages for any other type.
|
// We don't generate pages for any other type.
|
||||||
@ -1197,35 +1195,6 @@ fn item_trait_alias(
|
|||||||
.unwrap();
|
.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) {
|
fn item_type_alias(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, t: &clean::TypeAlias) {
|
||||||
wrap_item(w, |w| {
|
wrap_item(w, |w| {
|
||||||
write!(
|
write!(
|
||||||
|
@ -333,7 +333,6 @@ fn from_clean_item(item: clean::Item, tcx: TyCtxt<'_>) -> ItemEnum {
|
|||||||
ForeignStaticItem(s, _) => ItemEnum::Static(s.into_tcx(tcx)),
|
ForeignStaticItem(s, _) => ItemEnum::Static(s.into_tcx(tcx)),
|
||||||
ForeignTypeItem => ItemEnum::ForeignType,
|
ForeignTypeItem => ItemEnum::ForeignType,
|
||||||
TypeAliasItem(t) => ItemEnum::TypeAlias(t.into_tcx(tcx)),
|
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
|
// FIXME(generic_const_items): Add support for generic free consts
|
||||||
ConstantItem(ci) => {
|
ConstantItem(ci) => {
|
||||||
ItemEnum::Constant { type_: ci.type_.into_tcx(tcx), const_: ci.kind.into_tcx(tcx) }
|
ItemEnum::Constant { type_: ci.type_.into_tcx(tcx), const_: ci.kind.into_tcx(tcx) }
|
||||||
@ -830,12 +829,6 @@ fn from_tcx(type_alias: Box<clean::TypeAlias>, tcx: TyCtxt<'_>) -> Self {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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 {
|
impl FromWithTcx<clean::Static> for Static {
|
||||||
fn from_tcx(stat: clean::Static, tcx: TyCtxt<'_>) -> Self {
|
fn from_tcx(stat: clean::Static, tcx: TyCtxt<'_>) -> Self {
|
||||||
Static {
|
Static {
|
||||||
@ -867,7 +860,6 @@ fn from_tcx(kind: ItemType, _tcx: TyCtxt<'_>) -> Self {
|
|||||||
Enum => ItemKind::Enum,
|
Enum => ItemKind::Enum,
|
||||||
Function | TyMethod | Method => ItemKind::Function,
|
Function | TyMethod | Method => ItemKind::Function,
|
||||||
TypeAlias => ItemKind::TypeAlias,
|
TypeAlias => ItemKind::TypeAlias,
|
||||||
OpaqueTy => ItemKind::OpaqueTy,
|
|
||||||
Static => ItemKind::Static,
|
Static => ItemKind::Static,
|
||||||
Constant => ItemKind::Constant,
|
Constant => ItemKind::Constant,
|
||||||
Trait => ItemKind::Trait,
|
Trait => ItemKind::Trait,
|
||||||
|
@ -184,7 +184,6 @@ fn item(&mut self, item: clean::Item) -> Result<(), Error> {
|
|||||||
| types::ItemEnum::TraitAlias(_)
|
| types::ItemEnum::TraitAlias(_)
|
||||||
| types::ItemEnum::Impl(_)
|
| types::ItemEnum::Impl(_)
|
||||||
| types::ItemEnum::TypeAlias(_)
|
| types::ItemEnum::TypeAlias(_)
|
||||||
| types::ItemEnum::OpaqueTy(_)
|
|
||||||
| types::ItemEnum::Constant { .. }
|
| types::ItemEnum::Constant { .. }
|
||||||
| types::ItemEnum::Static(_)
|
| types::ItemEnum::Static(_)
|
||||||
| types::ItemEnum::ForeignType
|
| types::ItemEnum::ForeignType
|
||||||
|
@ -50,8 +50,7 @@ fn fold_item(&mut self, i: Item) -> Option<Item> {
|
|||||||
return Some(ret);
|
return Some(ret);
|
||||||
}
|
}
|
||||||
// These items can all get re-exported
|
// These items can all get re-exported
|
||||||
clean::OpaqueTyItem(..)
|
clean::TypeAliasItem(..)
|
||||||
| clean::TypeAliasItem(..)
|
|
||||||
| clean::StaticItem(..)
|
| clean::StaticItem(..)
|
||||||
| clean::StructItem(..)
|
| clean::StructItem(..)
|
||||||
| clean::EnumItem(..)
|
| clean::EnumItem(..)
|
||||||
|
@ -26,7 +26,6 @@ fn visit_inner_recur(&mut self, kind: &ItemKind) {
|
|||||||
| ImportItem(_)
|
| ImportItem(_)
|
||||||
| FunctionItem(_)
|
| FunctionItem(_)
|
||||||
| TypeAliasItem(_)
|
| TypeAliasItem(_)
|
||||||
| OpaqueTyItem(_)
|
|
||||||
| StaticItem(_)
|
| StaticItem(_)
|
||||||
| ConstantItem(..)
|
| ConstantItem(..)
|
||||||
| TraitAliasItem(_)
|
| TraitAliasItem(_)
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
/// This integer is incremented with every breaking change to the API,
|
/// This integer is incremented with every breaking change to the API,
|
||||||
/// and is returned along with the JSON blob as [`Crate::format_version`].
|
/// and is returned along with the JSON blob as [`Crate::format_version`].
|
||||||
/// Consuming code should assert that this value matches the format version(s) that it supports.
|
/// Consuming code should assert that this value matches the format version(s) that it supports.
|
||||||
pub const FORMAT_VERSION: u32 = 32;
|
pub const FORMAT_VERSION: u32 = 33;
|
||||||
|
|
||||||
/// The root of the emitted JSON blob.
|
/// The root of the emitted JSON blob.
|
||||||
///
|
///
|
||||||
@ -326,7 +326,6 @@ pub enum ItemKind {
|
|||||||
Function,
|
Function,
|
||||||
/// A type alias declaration, e.g. `type Pig = std::borrow::Cow<'static, str>;`
|
/// A type alias declaration, e.g. `type Pig = std::borrow::Cow<'static, str>;`
|
||||||
TypeAlias,
|
TypeAlias,
|
||||||
OpaqueTy,
|
|
||||||
/// The declaration of a constant, e.g. `const GREETING: &str = "Hi :3";`
|
/// The declaration of a constant, e.g. `const GREETING: &str = "Hi :3";`
|
||||||
Constant,
|
Constant,
|
||||||
/// A `trait` declaration.
|
/// A `trait` declaration.
|
||||||
@ -414,7 +413,6 @@ pub enum ItemEnum {
|
|||||||
|
|
||||||
/// A type alias declaration, e.g. `type Pig = std::borrow::Cow<'static, str>;`
|
/// A type alias declaration, e.g. `type Pig = std::borrow::Cow<'static, str>;`
|
||||||
TypeAlias(TypeAlias),
|
TypeAlias(TypeAlias),
|
||||||
OpaqueTy(OpaqueTy),
|
|
||||||
/// The declaration of a constant, e.g. `const GREETING: &str = "Hi :3";`
|
/// The declaration of a constant, e.g. `const GREETING: &str = "Hi :3";`
|
||||||
Constant {
|
Constant {
|
||||||
/// The type of the constant.
|
/// The type of the constant.
|
||||||
@ -1200,12 +1198,6 @@ pub struct TypeAlias {
|
|||||||
pub generics: Generics,
|
pub generics: Generics,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
|
||||||
pub struct OpaqueTy {
|
|
||||||
pub bounds: Vec<GenericBound>,
|
|
||||||
pub generics: Generics,
|
|
||||||
}
|
|
||||||
|
|
||||||
/// A `static` declaration.
|
/// A `static` declaration.
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||||
pub struct Static {
|
pub struct Static {
|
||||||
|
@ -13,7 +13,6 @@ pub(crate) enum Kind {
|
|||||||
Variant,
|
Variant,
|
||||||
Function,
|
Function,
|
||||||
TypeAlias,
|
TypeAlias,
|
||||||
OpaqueTy,
|
|
||||||
Constant,
|
Constant,
|
||||||
Trait,
|
Trait,
|
||||||
TraitAlias,
|
TraitAlias,
|
||||||
@ -55,7 +54,6 @@ pub fn can_appear_in_mod(self) -> bool {
|
|||||||
|
|
||||||
// FIXME(adotinthevoid): I'm not sure if these are correct
|
// FIXME(adotinthevoid): I'm not sure if these are correct
|
||||||
Keyword => false,
|
Keyword => false,
|
||||||
OpaqueTy => false,
|
|
||||||
ProcAttribute => false,
|
ProcAttribute => false,
|
||||||
ProcDerive => false,
|
ProcDerive => false,
|
||||||
|
|
||||||
@ -99,7 +97,6 @@ pub fn can_appear_in_trait(self) -> bool {
|
|||||||
Kind::Enum => false,
|
Kind::Enum => false,
|
||||||
Kind::Variant => false,
|
Kind::Variant => false,
|
||||||
Kind::TypeAlias => false,
|
Kind::TypeAlias => false,
|
||||||
Kind::OpaqueTy => false,
|
|
||||||
Kind::Constant => false,
|
Kind::Constant => false,
|
||||||
Kind::Trait => false,
|
Kind::Trait => false,
|
||||||
Kind::TraitAlias => false,
|
Kind::TraitAlias => false,
|
||||||
@ -149,7 +146,6 @@ pub fn from_item(i: &Item) -> Self {
|
|||||||
ItemEnum::TraitAlias(_) => TraitAlias,
|
ItemEnum::TraitAlias(_) => TraitAlias,
|
||||||
ItemEnum::Impl(_) => Impl,
|
ItemEnum::Impl(_) => Impl,
|
||||||
ItemEnum::TypeAlias(_) => TypeAlias,
|
ItemEnum::TypeAlias(_) => TypeAlias,
|
||||||
ItemEnum::OpaqueTy(_) => OpaqueTy,
|
|
||||||
ItemEnum::Constant { .. } => Constant,
|
ItemEnum::Constant { .. } => Constant,
|
||||||
ItemEnum::Static(_) => Static,
|
ItemEnum::Static(_) => Static,
|
||||||
ItemEnum::Macro(_) => Macro,
|
ItemEnum::Macro(_) => Macro,
|
||||||
@ -177,7 +173,6 @@ pub fn from_summary(s: &ItemSummary) -> Self {
|
|||||||
ItemKind::Keyword => Keyword,
|
ItemKind::Keyword => Keyword,
|
||||||
ItemKind::Macro => Macro,
|
ItemKind::Macro => Macro,
|
||||||
ItemKind::Module => Module,
|
ItemKind::Module => Module,
|
||||||
ItemKind::OpaqueTy => OpaqueTy,
|
|
||||||
ItemKind::Primitive => Primitive,
|
ItemKind::Primitive => Primitive,
|
||||||
ItemKind::ProcAttribute => ProcAttribute,
|
ItemKind::ProcAttribute => ProcAttribute,
|
||||||
ItemKind::ProcDerive => ProcDerive,
|
ItemKind::ProcDerive => ProcDerive,
|
||||||
|
@ -3,9 +3,9 @@
|
|||||||
|
|
||||||
use rustdoc_json_types::{
|
use rustdoc_json_types::{
|
||||||
Constant, Crate, DynTrait, Enum, FnDecl, Function, FunctionPointer, GenericArg, GenericArgs,
|
Constant, Crate, DynTrait, Enum, FnDecl, Function, FunctionPointer, GenericArg, GenericArgs,
|
||||||
GenericBound, GenericParamDef, Generics, Id, Impl, Import, ItemEnum, ItemSummary, Module,
|
GenericBound, GenericParamDef, Generics, Id, Impl, Import, ItemEnum, ItemSummary, Module, Path,
|
||||||
OpaqueTy, Path, Primitive, ProcMacro, Static, Struct, StructKind, Term, Trait, TraitAlias,
|
Primitive, ProcMacro, Static, Struct, StructKind, Term, Trait, TraitAlias, Type, TypeAlias,
|
||||||
Type, TypeAlias, TypeBinding, TypeBindingKind, Union, Variant, VariantKind, WherePredicate,
|
TypeBinding, TypeBindingKind, Union, Variant, VariantKind, WherePredicate,
|
||||||
};
|
};
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
|
|
||||||
@ -101,7 +101,6 @@ fn check_item(&mut self, id: &'a Id) {
|
|||||||
ItemEnum::TraitAlias(x) => self.check_trait_alias(x),
|
ItemEnum::TraitAlias(x) => self.check_trait_alias(x),
|
||||||
ItemEnum::Impl(x) => self.check_impl(x, id),
|
ItemEnum::Impl(x) => self.check_impl(x, id),
|
||||||
ItemEnum::TypeAlias(x) => self.check_type_alias(x),
|
ItemEnum::TypeAlias(x) => self.check_type_alias(x),
|
||||||
ItemEnum::OpaqueTy(x) => self.check_opaque_ty(x),
|
|
||||||
ItemEnum::Constant { type_, const_ } => {
|
ItemEnum::Constant { type_, const_ } => {
|
||||||
self.check_type(type_);
|
self.check_type(type_);
|
||||||
self.check_constant(const_);
|
self.check_constant(const_);
|
||||||
@ -230,11 +229,6 @@ fn check_type_alias(&mut self, x: &'a TypeAlias) {
|
|||||||
self.check_type(&x.type_);
|
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) {
|
fn check_constant(&mut self, _x: &'a Constant) {
|
||||||
// nop
|
// nop
|
||||||
}
|
}
|
||||||
|
29
tests/rustdoc-json/impl-trait-in-assoc-type.rs
Normal file
29
tests/rustdoc-json/impl-trait-in-assoc-type.rs
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
// ignore-tidy-linelength
|
||||||
|
#![feature(impl_trait_in_assoc_type)]
|
||||||
|
|
||||||
|
pub struct AlwaysTrue;
|
||||||
|
|
||||||
|
/// impl IntoIterator
|
||||||
|
impl IntoIterator for AlwaysTrue {
|
||||||
|
//@ set Item = '$.index[*][?(@.docs=="type Item")].id'
|
||||||
|
/// type Item
|
||||||
|
type Item = bool;
|
||||||
|
|
||||||
|
//@ count '$.index[*][?(@.docs=="type IntoIter")].inner.assoc_type.default.impl_trait[*]' 1
|
||||||
|
//@ is '$.index[*][?(@.docs=="type IntoIter")].inner.assoc_type.default.impl_trait[0].trait_bound.trait.name' '"Iterator"'
|
||||||
|
//@ count '$.index[*][?(@.docs=="type IntoIter")].inner.assoc_type.default.impl_trait[0].trait_bound.trait.args.angle_bracketed.bindings[*]' 1
|
||||||
|
//@ is '$.index[*][?(@.docs=="type IntoIter")].inner.assoc_type.default.impl_trait[0].trait_bound.trait.args.angle_bracketed.bindings[0].name' '"Item"'
|
||||||
|
//@ is '$.index[*][?(@.docs=="type IntoIter")].inner.assoc_type.default.impl_trait[0].trait_bound.trait.args.angle_bracketed.bindings[0].binding.equality.type.primitive' '"bool"'
|
||||||
|
|
||||||
|
//@ set IntoIter = '$.index[*][?(@.docs=="type IntoIter")].id'
|
||||||
|
/// type IntoIter
|
||||||
|
type IntoIter = impl Iterator<Item = bool>;
|
||||||
|
|
||||||
|
//@ set into_iter = '$.index[*][?(@.docs=="fn into_iter")].id'
|
||||||
|
/// fn into_iter
|
||||||
|
fn into_iter(self) -> Self::IntoIter {
|
||||||
|
std::iter::repeat(true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//@ ismany '$.index[*][?(@.docs=="impl IntoIterator")].inner.impl.items[*]' $Item $IntoIter $into_iter
|
17
tests/rustdoc/type-alias/impl_trait_in_assoc_type.rs
Normal file
17
tests/rustdoc/type-alias/impl_trait_in_assoc_type.rs
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
#![feature(impl_trait_in_assoc_type)]
|
||||||
|
|
||||||
|
pub struct AlwaysTrue;
|
||||||
|
|
||||||
|
//@ has impl_trait_in_assoc_type/struct.AlwaysTrue.html
|
||||||
|
|
||||||
|
impl IntoIterator for AlwaysTrue {
|
||||||
|
type Item = bool;
|
||||||
|
|
||||||
|
//@ has - '//*[@id="associatedtype.IntoIter"]//h4[@class="code-header"]' \
|
||||||
|
// 'type IntoIter = impl Iterator<Item = bool>'
|
||||||
|
type IntoIter = impl Iterator<Item = bool>;
|
||||||
|
|
||||||
|
fn into_iter(self) -> Self::IntoIter {
|
||||||
|
std::iter::repeat(true)
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user