diff options
| author | Martin Nordholts <enselic@gmail.com> | 2022-11-16 20:13:45 +0100 |
|---|---|---|
| committer | Martin Nordholts <enselic@gmail.com> | 2022-11-16 20:24:03 +0100 |
| commit | 8b5bfaf662916deda37254a0eeec78e9b7d1c444 (patch) | |
| tree | aec130381e26c32c28c8d3cb341b4497ffadd092 /src/librustdoc | |
| parent | 6d651a295e0e0c331153288b10b78344a4ede20b (diff) | |
rustdoc JSON: Use `Function` everywhere and remove `Method`
Diffstat (limited to 'src/librustdoc')
| -rw-r--r-- | src/librustdoc/json/conversions.rs | 26 | ||||
| -rw-r--r-- | src/librustdoc/json/mod.rs | 3 |
2 files changed, 7 insertions, 22 deletions
diff --git a/src/librustdoc/json/conversions.rs b/src/librustdoc/json/conversions.rs index acfbd072121..6995778a93d 100644 --- a/src/librustdoc/json/conversions.rs +++ b/src/librustdoc/json/conversions.rs @@ -257,12 +257,12 @@ fn from_clean_item(item: clean::Item, tcx: TyCtxt<'_>) -> ItemEnum { StructFieldItem(f) => ItemEnum::StructField(f.into_tcx(tcx)), EnumItem(e) => ItemEnum::Enum(e.into_tcx(tcx)), VariantItem(v) => ItemEnum::Variant(v.into_tcx(tcx)), - FunctionItem(f) => ItemEnum::Function(from_function(f, header.unwrap(), tcx)), - ForeignFunctionItem(f) => ItemEnum::Function(from_function(f, header.unwrap(), tcx)), + FunctionItem(f) => ItemEnum::Function(from_function(f, true, header.unwrap(), tcx)), + ForeignFunctionItem(f) => ItemEnum::Function(from_function(f, false, header.unwrap(), tcx)), TraitItem(t) => ItemEnum::Trait((*t).into_tcx(tcx)), TraitAliasItem(t) => ItemEnum::TraitAlias(t.into_tcx(tcx)), - MethodItem(m, _) => ItemEnum::Method(from_function_method(m, true, header.unwrap(), tcx)), - TyMethodItem(m) => ItemEnum::Method(from_function_method(m, false, header.unwrap(), tcx)), + MethodItem(m, _) => ItemEnum::Function(from_function(m, true, header.unwrap(), tcx)), + TyMethodItem(m) => ItemEnum::Function(from_function(m, false, header.unwrap(), tcx)), ImplItem(i) => ItemEnum::Impl((*i).into_tcx(tcx)), StaticItem(s) => ItemEnum::Static(s.into_tcx(tcx)), ForeignStaticItem(s) => ItemEnum::Static(s.into_tcx(tcx)), @@ -618,6 +618,7 @@ impl FromWithTcx<clean::Impl> for Impl { pub(crate) fn from_function( function: Box<clean::Function>, + has_body: bool, header: rustc_hir::FnHeader, tcx: TyCtxt<'_>, ) -> Function { @@ -626,20 +627,6 @@ pub(crate) fn from_function( decl: decl.into_tcx(tcx), generics: generics.into_tcx(tcx), header: from_fn_header(&header), - } -} - -pub(crate) fn from_function_method( - function: Box<clean::Function>, - has_body: bool, - header: rustc_hir::FnHeader, - tcx: TyCtxt<'_>, -) -> Method { - let clean::Function { decl, generics } = *function; - Method { - decl: decl.into_tcx(tcx), - generics: generics.into_tcx(tcx), - header: from_fn_header(&header), has_body, } } @@ -759,14 +746,13 @@ impl FromWithTcx<ItemType> for ItemKind { Struct => ItemKind::Struct, Union => ItemKind::Union, Enum => ItemKind::Enum, - Function => ItemKind::Function, + Function | TyMethod | Method => ItemKind::Function, Typedef => ItemKind::Typedef, OpaqueTy => ItemKind::OpaqueTy, Static => ItemKind::Static, Constant => ItemKind::Constant, Trait => ItemKind::Trait, Impl => ItemKind::Impl, - TyMethod | Method => ItemKind::Method, StructField => ItemKind::StructField, Variant => ItemKind::Variant, Macro => ItemKind::Macro, diff --git a/src/librustdoc/json/mod.rs b/src/librustdoc/json/mod.rs index beb70540091..e4df1332521 100644 --- a/src/librustdoc/json/mod.rs +++ b/src/librustdoc/json/mod.rs @@ -223,7 +223,7 @@ impl<'tcx> FormatRenderer<'tcx> for JsonRenderer<'tcx> { false } - types::ItemEnum::Method(_) + types::ItemEnum::Function(_) | types::ItemEnum::Module(_) | types::ItemEnum::AssocConst { .. } | types::ItemEnum::AssocType { .. } => true, @@ -231,7 +231,6 @@ impl<'tcx> FormatRenderer<'tcx> for JsonRenderer<'tcx> { | types::ItemEnum::Import(_) | types::ItemEnum::StructField(_) | types::ItemEnum::Variant(_) - | types::ItemEnum::Function(_) | types::ItemEnum::TraitAlias(_) | types::ItemEnum::Impl(_) | types::ItemEnum::Typedef(_) |
