Skip to content
Closed
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
af79a63
time.rs: remove "Basic usage text"
tshepang Aug 2, 2024
7dd5ad2
rustdoc: Extract helper function to add item to search index
camelid Aug 2, 2024
2721e97
rustdoc: Clarify construction of name for search index
camelid Aug 2, 2024
4e20847
rustdoc: Simplify some search index code
camelid Aug 2, 2024
015aa8d
Restructure a confusing `match`
camelid Aug 2, 2024
08f4d54
Extract local variables
camelid Aug 2, 2024
220c2d8
Restructure `add_item_to_search_index` to eliminate code paths
camelid Aug 2, 2024
5ce554f
allow setting `link-shared` and `static-libstdcpp` with CI LLVM
onur-ozkan Aug 3, 2024
21c0251
Miri: add a flag to do recursive validity checking
RalfJung Aug 2, 2024
9061915
add test for symbol visibility of `#[naked]` functions
folkertdev Jul 29, 2024
940a109
add test that tracks that functions defined in extern blocks are not …
folkertdev Jul 30, 2024
eb2de64
rustdoc: make the hover trail for doc anchors a bit bigger
notriddle Aug 3, 2024
cb7c596
Update rinja version to 0.3.0
GuillaumeGomez Aug 3, 2024
007d9e1
rustdoc: Re-add missing `stripped_mod` check; explain orphan impls
camelid Aug 4, 2024
5bd28a2
Rollup merge of #128362 - folkertdev:naked-function-symbol-visibility…
matthiaskrgr Aug 4, 2024
41555bd
Rollup merge of #128526 - tshepang:patch-1, r=Amanieu
matthiaskrgr Aug 4, 2024
3927e04
Rollup merge of #128531 - RalfJung:miri-recursive-validity, r=saethlin
matthiaskrgr Aug 4, 2024
60dc66b
Rollup merge of #128578 - camelid:cache-index-cleanup, r=notriddle
matthiaskrgr Aug 4, 2024
318bc4a
Rollup merge of #128589 - onur-ozkan:llvm-configs, r=cuviper
matthiaskrgr Aug 4, 2024
9d00c8c
Rollup merge of #128615 - notriddle:notriddle/anchor-a11y, r=Guillaum…
matthiaskrgr Aug 4, 2024
08f3693
Rollup merge of #128620 - GuillaumeGomez:update-rinja, r=notriddle
matthiaskrgr Aug 4, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Restructure a confusing match
  • Loading branch information
camelid committed Aug 3, 2024
commit 015aa8d0fba2247da33967a93fad9a2bea16037f
124 changes: 62 additions & 62 deletions src/librustdoc/formats/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> {
}

fn add_item_to_search_index(tcx: TyCtxt<'_>, cache: &mut Cache, item: &clean::Item, name: Symbol) {
let (parent, is_impl_child) = match *item.kind {
let ((parent_did, parent_path), is_impl_child) = match *item.kind {
clean::StrippedItem(..) => return,
clean::AssocConstItem(..) | clean::AssocTypeItem(..)
if cache.parent_stack.last().is_some_and(|parent| parent.is_trait_impl()) =>
Expand Down Expand Up @@ -496,77 +496,77 @@ fn add_item_to_search_index(tcx: TyCtxt<'_>, cache: &mut Cache, item: &clean::It
_ => ((None, Some(&*cache.stack)), false),
};

match parent {
(parent, Some(path)) if is_impl_child || !cache.stripped_mod => {
debug_assert!(!item.is_stripped());

// A crate has a module at its root, containing all items,
// which should not be indexed. The crate-item itself is
// inserted later on when serializing the search-index.
if item.item_id.as_def_id().is_some_and(|idx| !idx.is_crate_root())
&& let ty = item.type_()
&& (ty != ItemType::StructField || u16::from_str_radix(name.as_str(), 10).is_err())
if let Some(parent_did) = parent_did
&& parent_path.is_none()
&& is_impl_child
{
// We have a parent, but we don't know where they're
// defined yet. Wait for later to index this item.
let impl_generics = clean_impl_generics(cache.parent_stack.last());
cache.orphan_impl_items.push(OrphanImplItem {
parent: parent_did,
item: item.clone(),
impl_generics,
impl_id: if let Some(ParentStackItem::Impl { item_id, .. }) = cache.parent_stack.last()
{
let desc = short_markdown_summary(&item.doc_value(), &item.link_names(cache));
// For searching purposes, a re-export is a duplicate if:
//
// - It's either an inline, or a true re-export
// - It's got the same name
// - Both of them have the same exact path
let defid = (match &*item.kind {
&clean::ItemKind::ImportItem(ref import) => import.source.did,
_ => None,
})
.or_else(|| item.item_id.as_def_id());
// In case this is a field from a tuple struct, we don't add it into
// the search index because its name is something like "0", which is
// not useful for rustdoc search.
cache.search_index.push(IndexItem {
ty,
defid,
name,
path: join_with_double_colon(path),
desc,
parent,
parent_idx: None,
exact_path: None,
impl_id: if let Some(ParentStackItem::Impl { item_id, .. }) =
cache.parent_stack.last()
{
item_id.as_def_id()
} else {
None
},
search_type: get_function_type_for_search(
&item,
tcx,
clean_impl_generics(cache.parent_stack.last()).as_ref(),
parent,
cache,
),
aliases: item.attrs.get_doc_aliases(),
deprecation: item.deprecation(tcx),
});
}
}
(Some(parent), None) if is_impl_child => {
// We have a parent, but we don't know where they're
// defined yet. Wait for later to index this item.
let impl_generics = clean_impl_generics(cache.parent_stack.last());
cache.orphan_impl_items.push(OrphanImplItem {
parent,
item: item.clone(),
impl_generics,
item_id.as_def_id()
} else {
None
},
});
} else if let Some(path) = parent_path
&& (is_impl_child || !cache.stripped_mod)
{
debug_assert!(!item.is_stripped());

// A crate has a module at its root, containing all items,
// which should not be indexed. The crate-item itself is
// inserted later on when serializing the search-index.
if item.item_id.as_def_id().is_some_and(|idx| !idx.is_crate_root())
&& let ty = item.type_()
&& (ty != ItemType::StructField || u16::from_str_radix(name.as_str(), 10).is_err())
{
let desc = short_markdown_summary(&item.doc_value(), &item.link_names(cache));
// For searching purposes, a re-export is a duplicate if:
//
// - It's either an inline, or a true re-export
// - It's got the same name
// - Both of them have the same exact path
let defid = (match &*item.kind {
&clean::ItemKind::ImportItem(ref import) => import.source.did,
_ => None,
})
.or_else(|| item.item_id.as_def_id());
// In case this is a field from a tuple struct, we don't add it into
// the search index because its name is something like "0", which is
// not useful for rustdoc search.
cache.search_index.push(IndexItem {
ty,
defid,
name,
path: join_with_double_colon(path),
desc,
parent: parent_did,
parent_idx: None,
exact_path: None,
impl_id: if let Some(ParentStackItem::Impl { item_id, .. }) =
cache.parent_stack.last()
{
item_id.as_def_id()
} else {
None
},
search_type: get_function_type_for_search(
&item,
tcx,
clean_impl_generics(cache.parent_stack.last()).as_ref(),
parent_did,
cache,
),
aliases: item.attrs.get_doc_aliases(),
deprecation: item.deprecation(tcx),
});
}
_ => {}
}
}

Expand Down