diff --git a/src/librustdoc/clean/types.rs b/src/librustdoc/clean/types.rs index 85dd3881593ac..0dd50efd23eab 100644 --- a/src/librustdoc/clean/types.rs +++ b/src/librustdoc/clean/types.rs @@ -1507,6 +1507,11 @@ impl FnDecl { _ => panic!("unexpected desugaring of async function"), } } + + /// Indicates id this function declaration can be used to create the type + pub(crate) fn type_builder(&self) -> bool { + self.inputs.values.get(0).and_then(|v| v.to_self()) + } } #[derive(Clone, PartialEq, Eq, Debug, Hash)] diff --git a/src/librustdoc/html/render/mod.rs b/src/librustdoc/html/render/mod.rs index 6a9a7a6b1a088..c27165e5310c8 100644 --- a/src/librustdoc/html/render/mod.rs +++ b/src/librustdoc/html/render/mod.rs @@ -845,11 +845,12 @@ fn assoc_method( render_attributes_in_code(w, meth); (0, "", Ending::Newline) }; + let takes_self = d.inputs.values.iter().filter(|v| v.to_self().is_some()).count() > 0; w.reserve(header_len + "{".len() + "".len()); write!( w, "{indent}{vis}{constness}{asyncness}{unsafety}{defaultness}{abi}fn {name}\ - {generics}{decl}{notable_traits}{where_clause}", + {generics}{decl}{notable_traits}{where_clause}{no_self}", indent = indent_str, vis = vis, constness = constness, @@ -863,9 +864,21 @@ fn assoc_method( decl = d.full_print(header_len, indent, cx), notable_traits = notable_traits.unwrap_or_default(), where_clause = print_where_clause(g, cx, indent, end_newline), + no_self = if !takes_self { + "⚒️" + } else { + "" + } ); } +/// Returns true if the given function can be used to construct the type. +/// +/// This means the function does not take `self` ad returns the given type (including if Option or Result) +fn fn_is_to_build_type(ty: &clean::Item, fn_item: &clean::FnDecl) -> bool { + todo!() +} + /// Writes a span containing the versions at which an item became stable and/or const-stable. For /// example, if the item became stable at 1.0.0, and const-stable at 1.45.0, this function would /// write a span containing "1.0.0 (const: 1.45.0)". diff --git a/src/librustdoc/html/render/print_item.rs b/src/librustdoc/html/render/print_item.rs index 82a51a8467bcd..95b41aadc31fa 100644 --- a/src/librustdoc/html/render/print_item.rs +++ b/src/librustdoc/html/render/print_item.rs @@ -431,7 +431,7 @@ fn item_module(w: &mut Buffer, cx: &mut Context<'_>, item: &clean::Item, items: write!( w, "