Skip to content

Commit

Permalink
allow type-based search on foreign functions
Browse files Browse the repository at this point in the history
fixes #131804
  • Loading branch information
lolbinarycat committed Oct 25, 2024
1 parent bed75e7 commit 09773b4
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/librustdoc/html/render/search_index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,10 @@ pub(crate) fn get_function_type_for_search<'tcx>(
}
});
let (mut inputs, mut output, where_clause) = match item.kind {
clean::FunctionItem(ref f) | clean::MethodItem(ref f, _) | clean::TyMethodItem(ref f) => {
clean::ForeignFunctionItem(ref f, _)
| clean::FunctionItem(ref f)
| clean::MethodItem(ref f, _)
| clean::TyMethodItem(ref f) => {
get_fn_inputs_and_outputs(f, tcx, impl_or_trait_generics, cache)
}
_ => return None,
Expand Down
8 changes: 8 additions & 0 deletions tests/rustdoc-js/extern-func.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const EXPECTED = [
{
'query': 'c_float -> c_float',
'others': [
{ 'path': 'extern_func', 'name': 'sqrt' }
],
},
];
5 changes: 5 additions & 0 deletions tests/rustdoc-js/extern-func.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
use std::ffi::c_float;

extern "C" {
pub fn sqrt(x: c_float) -> c_float;
}

0 comments on commit 09773b4

Please sign in to comment.