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
This commit is contained in:
SiegeLord 2014-08-26 14:41:25 -04:00
parent 7932b719ec
commit bcb07175ce

View File

@ -819,16 +819,17 @@ fn fold_item(&mut self, item: clean::Item) -> Option<clean::Item> {
// Index this method for searching later on
match item.name {
Some(ref s) => {
let parent = match item.inner {
let (parent, is_method) = match item.inner {
clean::TyMethodItem(..) |
clean::StructFieldItem(..) |
clean::VariantItem(..) => {
(Some(*self.parent_stack.last().unwrap()),
Some(self.stack.slice_to(self.stack.len() - 1)))
((Some(*self.parent_stack.last().unwrap()),
Some(self.stack.slice_to(self.stack.len() - 1))),
false)
}
clean::MethodItem(..) => {
if self.parent_stack.len() == 0 {
(None, None)
((None, None), false)
} else {
let last = self.parent_stack.last().unwrap();
let did = *last;
@ -844,17 +845,18 @@ fn fold_item(&mut self, item: clean::Item) -> Option<clean::Item> {
Some(..) => Some(self.stack.as_slice()),
None => None
};
(Some(*last), path)
((Some(*last), path), true)
}
}
_ => (None, Some(self.stack.as_slice()))
_ => ((None, Some(self.stack.as_slice())), false)
};
let hidden_field = match item.inner {
clean::StructFieldItem(clean::HiddenStructField) => true,
_ => false
};
match parent {
(parent, Some(path)) if !self.privmod && !hidden_field => {
(parent, Some(path)) if is_method || (!self.privmod && !hidden_field) => {
self.search_index.push(IndexItem {
ty: shortty(&item),
name: s.to_string(),
@ -863,7 +865,7 @@ fn fold_item(&mut self, item: clean::Item) -> Option<clean::Item> {
parent: parent,
});
}
(Some(parent), None) if !self.privmod => {
(Some(parent), None) if is_method || (!self.privmod && !hidden_field)=> {
if ast_util::is_local(parent) {
// We have a parent, but we don't know where they're
// defined yet. Wait for later to index this item.