1
Fork 0

rustdoc: simplify clean by removing FnRetTy

The default fn ret ty is always unit. Just use that.

Looking back at the time when `FnRetTy` (then called
`FunctionRetTy`) was first added to rustdoc, it seems to originally
be there because `-> !` was a special form: the never type didn't
exist back then.

eb01b17b06 (diff-384affc1b4190940f114f3fcebbf969e7e18657a71ef9001da6b223a036687d9L921-L924)
This commit is contained in:
Michael Howell 2023-05-30 12:07:03 -07:00
parent a9251b6ce1
commit 1862fcb1df
7 changed files with 49 additions and 81 deletions

View file

@ -844,7 +844,7 @@ fn assoc_method(
+ name.as_str().len()
+ generics_len;
let notable_traits = d.output.as_return().and_then(|output| notable_traits_button(output, cx));
let notable_traits = notable_traits_button(&d.output, cx);
let (indent, indent_str, end_newline) = if parent == ItemType::Trait {
header_len += 4;
@ -1282,6 +1282,11 @@ fn should_render_item(item: &clean::Item, deref_mut_: bool, tcx: TyCtxt<'_>) ->
pub(crate) fn notable_traits_button(ty: &clean::Type, cx: &mut Context<'_>) -> Option<String> {
let mut has_notable_trait = false;
if ty.is_unit() {
// Very common fast path.
return None;
}
let did = ty.def_id(cx.cache())?;
// Box has pass-through impls for Read, Write, Iterator, and Future when the