Skip to content

Commit bcb0717

Browse files
committed
Always insert methods into the search index, even if we're currently in a private module.
Previously, this caused methods of re-exported types to not be inserted into the search index. This fix may introduce some false positives, but in my testing they appear as orphaned methods and end up not being inserted into the final search index at a later stage. Fixes issue #11943
1 parent 7932b71 commit bcb0717

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/librustdoc/html/render.rs

+10-8
Original file line numberDiff line numberDiff line change
@@ -819,16 +819,17 @@ impl DocFolder for Cache {
819819
// Index this method for searching later on
820820
match item.name {
821821
Some(ref s) => {
822-
let parent = match item.inner {
822+
let (parent, is_method) = match item.inner {
823823
clean::TyMethodItem(..) |
824824
clean::StructFieldItem(..) |
825825
clean::VariantItem(..) => {
826-
(Some(*self.parent_stack.last().unwrap()),
827-
Some(self.stack.slice_to(self.stack.len() - 1)))
826+
((Some(*self.parent_stack.last().unwrap()),
827+
Some(self.stack.slice_to(self.stack.len() - 1))),
828+
false)
828829
}
829830
clean::MethodItem(..) => {
830831
if self.parent_stack.len() == 0 {
831-
(None, None)
832+
((None, None), false)
832833
} else {
833834
let last = self.parent_stack.last().unwrap();
834835
let did = *last;
@@ -844,17 +845,18 @@ impl DocFolder for Cache {
844845
Some(..) => Some(self.stack.as_slice()),
845846
None => None
846847
};
847-
(Some(*last), path)
848+
((Some(*last), path), true)
848849
}
849850
}
850-
_ => (None, Some(self.stack.as_slice()))
851+
_ => ((None, Some(self.stack.as_slice())), false)
851852
};
852853
let hidden_field = match item.inner {
853854
clean::StructFieldItem(clean::HiddenStructField) => true,
854855
_ => false
855856
};
857+
856858
match parent {
857-
(parent, Some(path)) if !self.privmod && !hidden_field => {
859+
(parent, Some(path)) if is_method || (!self.privmod && !hidden_field) => {
858860
self.search_index.push(IndexItem {
859861
ty: shortty(&item),
860862
name: s.to_string(),
@@ -863,7 +865,7 @@ impl DocFolder for Cache {
863865
parent: parent,
864866
});
865867
}
866-
(Some(parent), None) if !self.privmod => {
868+
(Some(parent), None) if is_method || (!self.privmod && !hidden_field)=> {
867869
if ast_util::is_local(parent) {
868870
// We have a parent, but we don't know where they're
869871
// defined yet. Wait for later to index this item.

0 commit comments

Comments
 (0)