From ff65d62922631bd00af13b905fd3abd9c971ae27 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Sat, 14 Dec 2024 17:02:09 -0800 Subject: [PATCH] Rename TyAssocTypeItem -> RequiredAssocTypeItem --- src/librustdoc/clean/mod.rs | 4 ++-- src/librustdoc/clean/types.rs | 10 +++++----- src/librustdoc/fold.rs | 2 +- src/librustdoc/formats/cache.rs | 4 ++-- src/librustdoc/formats/item_type.rs | 2 +- src/librustdoc/html/render/mod.rs | 6 +++--- src/librustdoc/html/render/print_item.rs | 3 ++- src/librustdoc/html/render/search_index.rs | 5 +++-- src/librustdoc/html/render/sidebar.rs | 2 +- src/librustdoc/json/conversions.rs | 2 +- src/librustdoc/passes/check_doc_test_visibility.rs | 2 +- src/librustdoc/passes/propagate_stability.rs | 2 +- src/librustdoc/passes/stripper.rs | 2 +- src/librustdoc/visit.rs | 2 +- 14 files changed, 25 insertions(+), 23 deletions(-) diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 51ff70a69fe6..6dd6b139b1a1 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -1259,7 +1259,7 @@ fn clean_trait_item<'tcx>(trait_item: &hir::TraitItem<'tcx>, cx: &mut DocContext hir::TraitItemKind::Type(bounds, None) => { let generics = enter_impl_trait(cx, |cx| clean_generics(trait_item.generics, cx)); let bounds = bounds.iter().filter_map(|x| clean_generic_bound(x, cx)).collect(); - TyAssocTypeItem(generics, bounds) + RequiredAssocTypeItem(generics, bounds) } }; Item::from_def_id_and_parts(local_did, Some(trait_item.ident.name), inner, cx) @@ -1493,7 +1493,7 @@ pub(crate) fn clean_middle_assoc_item(assoc_item: &ty::AssocItem, cx: &mut DocCo bounds, ) } else { - TyAssocTypeItem(generics, bounds) + RequiredAssocTypeItem(generics, bounds) } } else { AssocTypeItem( diff --git a/src/librustdoc/clean/types.rs b/src/librustdoc/clean/types.rs index feec8ac5b22c..d48897799f9b 100644 --- a/src/librustdoc/clean/types.rs +++ b/src/librustdoc/clean/types.rs @@ -547,8 +547,8 @@ impl Item { pub(crate) fn is_associated_type(&self) -> bool { matches!(self.kind, AssocTypeItem(..) | StrippedItem(box AssocTypeItem(..))) } - pub(crate) fn is_ty_associated_type(&self) -> bool { - matches!(self.kind, TyAssocTypeItem(..) | StrippedItem(box TyAssocTypeItem(..))) + pub(crate) fn is_required_associated_type(&self) -> bool { + matches!(self.kind, RequiredAssocTypeItem(..) | StrippedItem(box RequiredAssocTypeItem(..))) } pub(crate) fn is_associated_const(&self) -> bool { matches!(self.kind, ProvidedAssocConstItem(..) | ImplAssocConstItem(..) | StrippedItem(box (ProvidedAssocConstItem(..) | ImplAssocConstItem(..)))) @@ -705,7 +705,7 @@ impl Item { | ProvidedAssocConstItem(..) | ImplAssocConstItem(..) | AssocTypeItem(..) - | TyAssocTypeItem(..) + | RequiredAssocTypeItem(..) | TyMethodItem(..) | MethodItem(..) => { let assoc_item = tcx.associated_item(def_id); @@ -878,7 +878,7 @@ pub(crate) enum ItemKind { /// A required associated type in a trait declaration. /// /// The bounds may be non-empty if there is a `where` clause. - TyAssocTypeItem(Generics, Vec), + RequiredAssocTypeItem(Generics, Vec), /// An associated type in a trait impl or a provided one in a trait declaration. AssocTypeItem(Box, Vec), /// An item that has been stripped by a rustdoc pass @@ -921,7 +921,7 @@ impl ItemKind { | RequiredAssocConstItem(..) | ProvidedAssocConstItem(..) | ImplAssocConstItem(..) - | TyAssocTypeItem(..) + | RequiredAssocTypeItem(..) | AssocTypeItem(..) | StrippedItem(_) | KeywordItem => [].iter(), diff --git a/src/librustdoc/fold.rs b/src/librustdoc/fold.rs index d2e3b9ce2e4e..a42c8c94fde9 100644 --- a/src/librustdoc/fold.rs +++ b/src/librustdoc/fold.rs @@ -94,7 +94,7 @@ pub(crate) trait DocFolder: Sized { | RequiredAssocConstItem(..) | ProvidedAssocConstItem(..) | ImplAssocConstItem(..) - | TyAssocTypeItem(..) + | RequiredAssocTypeItem(..) | AssocTypeItem(..) | KeywordItem => kind, } diff --git a/src/librustdoc/formats/cache.rs b/src/librustdoc/formats/cache.rs index a87979ab186e..2ad8c832daf0 100644 --- a/src/librustdoc/formats/cache.rs +++ b/src/librustdoc/formats/cache.rs @@ -340,7 +340,7 @@ impl DocFolder for CacheBuilder<'_, '_> { | clean::RequiredAssocConstItem(..) | clean::ProvidedAssocConstItem(..) | clean::ImplAssocConstItem(..) - | clean::TyAssocTypeItem(..) + | clean::RequiredAssocTypeItem(..) | clean::AssocTypeItem(..) | clean::StrippedItem(..) | clean::KeywordItem => { @@ -454,7 +454,7 @@ fn add_item_to_search_index(tcx: TyCtxt<'_>, cache: &mut Cache, item: &clean::It } clean::TyMethodItem(..) | clean::RequiredAssocConstItem(..) - | clean::TyAssocTypeItem(..) + | clean::RequiredAssocTypeItem(..) | clean::StructFieldItem(..) | clean::VariantItem(..) => { // Don't index if containing module is stripped (i.e., private), diff --git a/src/librustdoc/formats/item_type.rs b/src/librustdoc/formats/item_type.rs index 8f5e26d0104b..f51292a5d5d4 100644 --- a/src/librustdoc/formats/item_type.rs +++ b/src/librustdoc/formats/item_type.rs @@ -99,7 +99,7 @@ impl<'a> From<&'a clean::Item> for ItemType { clean::RequiredAssocConstItem(..) | clean::ProvidedAssocConstItem(..) | clean::ImplAssocConstItem(..) => ItemType::AssocConst, - clean::TyAssocTypeItem(..) | clean::AssocTypeItem(..) => ItemType::AssocType, + clean::RequiredAssocTypeItem(..) | clean::AssocTypeItem(..) => ItemType::AssocType, clean::ForeignTypeItem => ItemType::ForeignType, clean::KeywordItem => ItemType::Keyword, clean::TraitAliasItem(..) => ItemType::TraitAlias, diff --git a/src/librustdoc/html/render/mod.rs b/src/librustdoc/html/render/mod.rs index 436b5422ba9f..2d75d1a4c0e9 100644 --- a/src/librustdoc/html/render/mod.rs +++ b/src/librustdoc/html/render/mod.rs @@ -1127,7 +1127,7 @@ fn render_assoc_item( if parent == ItemType::Trait { 4 } else { 0 }, cx, ), - clean::TyAssocTypeItem(ref generics, ref bounds) => assoc_type( + clean::RequiredAssocTypeItem(ref generics, ref bounds) => assoc_type( w, item, generics, @@ -1763,7 +1763,7 @@ fn render_impl( ); w.write_str(""); } - clean::TyAssocTypeItem(ref generics, ref bounds) => { + clean::RequiredAssocTypeItem(ref generics, ref bounds) => { let source_id = format!("{item_type}.{name}"); let id = cx.derive_id(&source_id); write!(w, "
"); @@ -1839,7 +1839,7 @@ fn render_impl( for trait_item in &impl_.items { match trait_item.kind { clean::MethodItem(..) | clean::TyMethodItem(_) => methods.push(trait_item), - clean::TyAssocTypeItem(..) | clean::AssocTypeItem(..) => { + clean::RequiredAssocTypeItem(..) | clean::AssocTypeItem(..) => { assoc_types.push(trait_item) } clean::RequiredAssocConstItem(..) diff --git a/src/librustdoc/html/render/print_item.rs b/src/librustdoc/html/render/print_item.rs index c2ffd8e764f2..76040bb2daba 100644 --- a/src/librustdoc/html/render/print_item.rs +++ b/src/librustdoc/html/render/print_item.rs @@ -651,7 +651,8 @@ fn item_function(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, f: &clean:: fn item_trait(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, t: &clean::Trait) { let tcx = cx.tcx(); let bounds = bounds(&t.bounds, false, cx); - let required_types = t.items.iter().filter(|m| m.is_ty_associated_type()).collect::>(); + let required_types = + t.items.iter().filter(|m| m.is_required_associated_type()).collect::>(); let provided_types = t.items.iter().filter(|m| m.is_associated_type()).collect::>(); let required_consts = t.items.iter().filter(|m| m.is_required_associated_const()).collect::>(); diff --git a/src/librustdoc/html/render/search_index.rs b/src/librustdoc/html/render/search_index.rs index 2c26ffa76f6a..84bb8056e254 100644 --- a/src/librustdoc/html/render/search_index.rs +++ b/src/librustdoc/html/render/search_index.rs @@ -1207,10 +1207,11 @@ fn simplify_fn_type<'a, 'tcx>( && let Type::Path { path } = arg && let def_id = path.def_id() && let Some(trait_) = cache.traits.get(&def_id) - && trait_.items.iter().any(|at| at.is_ty_associated_type()) + && trait_.items.iter().any(|at| at.is_required_associated_type()) { for assoc_ty in &trait_.items { - if let clean::ItemKind::TyAssocTypeItem(_generics, bounds) = &assoc_ty.kind + if let clean::ItemKind::RequiredAssocTypeItem(_generics, bounds) = + &assoc_ty.kind && let Some(name) = assoc_ty.name { let idx = -isize::try_from(rgen.len() + 1).unwrap(); diff --git a/src/librustdoc/html/render/sidebar.rs b/src/librustdoc/html/render/sidebar.rs index 031510c006ec..af39d15f6717 100644 --- a/src/librustdoc/html/render/sidebar.rs +++ b/src/librustdoc/html/render/sidebar.rs @@ -282,7 +282,7 @@ fn sidebar_trait<'a>( res } - let req_assoc = filter_items(&t.items, |m| m.is_ty_associated_type(), "associatedtype"); + let req_assoc = filter_items(&t.items, |m| m.is_required_associated_type(), "associatedtype"); let prov_assoc = filter_items(&t.items, |m| m.is_associated_type(), "associatedtype"); let req_assoc_const = filter_items(&t.items, |m| m.is_required_associated_const(), "associatedconstant"); diff --git a/src/librustdoc/json/conversions.rs b/src/librustdoc/json/conversions.rs index 36a0aa0fdfac..a6da40d4329e 100644 --- a/src/librustdoc/json/conversions.rs +++ b/src/librustdoc/json/conversions.rs @@ -347,7 +347,7 @@ fn from_clean_item(item: clean::Item, renderer: &JsonRenderer<'_>) -> ItemEnum { type_: ci.type_.into_json(renderer), value: Some(ci.kind.expr(renderer.tcx)), }, - TyAssocTypeItem(g, b) => ItemEnum::AssocType { + RequiredAssocTypeItem(g, b) => ItemEnum::AssocType { generics: g.into_json(renderer), bounds: b.into_json(renderer), type_: None, diff --git a/src/librustdoc/passes/check_doc_test_visibility.rs b/src/librustdoc/passes/check_doc_test_visibility.rs index 2b0af187b2da..0fefd13f7633 100644 --- a/src/librustdoc/passes/check_doc_test_visibility.rs +++ b/src/librustdoc/passes/check_doc_test_visibility.rs @@ -76,7 +76,7 @@ pub(crate) fn should_have_doc_example(cx: &DocContext<'_>, item: &clean::Item) - | clean::RequiredAssocConstItem(..) | clean::ProvidedAssocConstItem(..) | clean::ImplAssocConstItem(..) - | clean::TyAssocTypeItem(..) + | clean::RequiredAssocTypeItem(..) // check for trait impl | clean::ImplItem(box clean::Impl { trait_: Some(_), .. }) ) diff --git a/src/librustdoc/passes/propagate_stability.rs b/src/librustdoc/passes/propagate_stability.rs index 1f9dc7536606..564d196dd019 100644 --- a/src/librustdoc/passes/propagate_stability.rs +++ b/src/librustdoc/passes/propagate_stability.rs @@ -72,7 +72,7 @@ impl DocFolder for StabilityPropagator<'_, '_> { | ItemKind::RequiredAssocConstItem(..) | ItemKind::ProvidedAssocConstItem(..) | ItemKind::ImplAssocConstItem(..) - | ItemKind::TyAssocTypeItem(..) + | ItemKind::RequiredAssocTypeItem(..) | ItemKind::AssocTypeItem(..) | ItemKind::PrimitiveItem(..) | ItemKind::KeywordItem => own_stability, diff --git a/src/librustdoc/passes/stripper.rs b/src/librustdoc/passes/stripper.rs index 7dc7856405ee..c992d8d94775 100644 --- a/src/librustdoc/passes/stripper.rs +++ b/src/librustdoc/passes/stripper.rs @@ -123,7 +123,7 @@ impl DocFolder for Stripper<'_, '_> { // tymethods etc. have no control over privacy clean::TyMethodItem(..) | clean::RequiredAssocConstItem(..) - | clean::TyAssocTypeItem(..) => {} + | clean::RequiredAssocTypeItem(..) => {} // Proc-macros are always public clean::ProcMacroItem(..) => {} diff --git a/src/librustdoc/visit.rs b/src/librustdoc/visit.rs index 397ff8873a34..293e1f3af4e1 100644 --- a/src/librustdoc/visit.rs +++ b/src/librustdoc/visit.rs @@ -47,7 +47,7 @@ pub(crate) trait DocVisitor<'a>: Sized { | RequiredAssocConstItem(..) | ProvidedAssocConstItem(..) | ImplAssocConstItem(..) - | TyAssocTypeItem(..) + | RequiredAssocTypeItem(..) | AssocTypeItem(..) | KeywordItem => {} }