Rollup merge of #132123 - lolbinarycat:rustdoc-search-foreign-func, r=notriddle

allow type-based search on foreign functions

fixes https://github.com/rust-lang/rust/issues/131804

preferably will be merged after #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.
This commit is contained in:
Jubilee 2024-10-26 21:58:39 -07:00 committed by GitHub
commit 05f784c955
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 17 additions and 1 deletions

View File

@ -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,

View File

@ -0,0 +1,8 @@
const EXPECTED = [
{
'query': 'c_float -> c_float',
'others': [
{ 'path': 'extern_func', 'name': 'sqrt' }
],
},
];

View File

@ -0,0 +1,5 @@
use std::ffi::c_float;
extern "C" {
pub fn sqrt(x: c_float) -> c_float;
}