From 30ecde0bebbf235867eb8652e5745c7efd771340 Mon Sep 17 00:00:00 2001 From: Rune Tynan Date: Fri, 29 Jan 2021 01:07:50 -0500 Subject: [PATCH] Add abi field to `Method` --- src/librustdoc/json/conversions.rs | 2 ++ src/rustdoc-json-types/lib.rs | 1 + src/test/rustdoc-json/method_abi.rs | 25 +++++++++++++++++++++++++ 3 files changed, 28 insertions(+) create mode 100644 src/test/rustdoc-json/method_abi.rs diff --git a/src/librustdoc/json/conversions.rs b/src/librustdoc/json/conversions.rs index 026d8f96dee..d9f52cbf34c 100644 --- a/src/librustdoc/json/conversions.rs +++ b/src/librustdoc/json/conversions.rs @@ -434,12 +434,14 @@ impl From for Impl { } } +<<<<<<< HEAD crate fn from_function_method(function: clean::Function, has_body: bool) -> Method { let clean::Function { header, decl, generics, all_types: _, ret_types: _ } = function; Method { decl: decl.into(), generics: generics.into(), header: stringify_header(&header), + abi: header.abi.to_string(), has_body, } } diff --git a/src/rustdoc-json-types/lib.rs b/src/rustdoc-json-types/lib.rs index 083f99e4a68..f4b8dc9a3ad 100644 --- a/src/rustdoc-json-types/lib.rs +++ b/src/rustdoc-json-types/lib.rs @@ -294,6 +294,7 @@ pub struct Method { pub decl: FnDecl, pub generics: Generics, pub header: String, + pub abi: String, pub has_body: bool, } diff --git a/src/test/rustdoc-json/method_abi.rs b/src/test/rustdoc-json/method_abi.rs new file mode 100644 index 00000000000..6fabbc83611 --- /dev/null +++ b/src/test/rustdoc-json/method_abi.rs @@ -0,0 +1,25 @@ +// @has method_abi.json "$.index[*][?(@.name=='Foo')]" +pub struct Foo; + +impl Foo { + // @has - "$.index[*][?(@.name=='abi_rust')].inner.abi" '"\"Rust\""' + pub fn abi_rust() {} + + // @has - "$.index[*][?(@.name=='abi_c')].inner.abi" '"\"C\""' + pub extern "C" fn abi_c() {} + + // @has - "$.index[*][?(@.name=='abi_system')].inner.abi" '"\"system\""' + pub extern "system" fn abi_system() {} +} + +// @has method_abi.json "$.index[*][?(@.name=='Bar')]" +pub trait Bar { + // @has - "$.index[*][?(@.name=='trait_abi_rust')].inner.abi" '"\"Rust\""' + fn trait_abi_rust(); + + // @has - "$.index[*][?(@.name=='trait_abi_c')].inner.abi" '"\"C\""' + extern "C" fn trait_abi_c(); + + // @has - "$.index[*][?(@.name=='trait_abi_system')].inner.abi" '"\"system\""' + extern "system" fn trait_abi_system(); +}