Skip to content

Commit

Permalink
Rollup merge of rust-lang#132123 - lolbinarycat:rustdoc-search-foreig…
Browse files Browse the repository at this point in the history
…n-func, r=notriddle

allow type-based search on foreign functions

fixes rust-lang#131804

preferably will be merged after rust-lang#129708, but that may take a while to be approved due to being a new feature, whereas this is definitely a bug, and should be fixed.
  • Loading branch information
workingjubilee authored Oct 27, 2024
2 parents f7cf41c + 09773b4 commit 05f784c
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 05f784c

Please sign in to comment.