diff --git a/src/librustdoc/html/render/search_index.rs b/src/librustdoc/html/render/search_index.rs
index c958458b662..d1939adc1a5 100644
--- a/src/librustdoc/html/render/search_index.rs
+++ b/src/librustdoc/html/render/search_index.rs
@@ -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,
diff --git a/tests/rustdoc-js/extern-func.js b/tests/rustdoc-js/extern-func.js
new file mode 100644
index 00000000000..a3fe2d8ea42
--- /dev/null
+++ b/tests/rustdoc-js/extern-func.js
@@ -0,0 +1,8 @@
+const EXPECTED = [
+ {
+ 'query': 'c_float -> c_float',
+ 'others': [
+ { 'path': 'extern_func', 'name': 'sqrt' }
+ ],
+ },
+];
diff --git a/tests/rustdoc-js/extern-func.rs b/tests/rustdoc-js/extern-func.rs
new file mode 100644
index 00000000000..ab1e3e75da7
--- /dev/null
+++ b/tests/rustdoc-js/extern-func.rs
@@ -0,0 +1,5 @@
+use std::ffi::c_float;
+
+extern "C" {
+ pub fn sqrt(x: c_float) -> c_float;
+}