Summary
Allow to merge various impl blocks in the HTML output
Motivation
There is only one usecase in mind – currently RustDoc generates separate impl docs for every impl block. Example:
Implementing this RFC would allow to merge said blocks into one by using new #[doc(merge)] attribute (they will be separate if said block won't be specified).
Guide-level explanation
I guess it would go there – The #[doc] attribute - The rustdoc book. Something along the lines of:
At the item level
merge
Docs of Inherent Implementations annotated with #[doc(merge)] attribute will be merged into one impl Ty block.
#[doc(merge)]
impl Foo {}
#[doc(merge)]
impl Foo {}
Drawbacks
I can't really think of anything. Feel free to suggest.
Rationale and Alternatives
Leaking implementation details into user docs is silly! To elaborate:
If a lot of macros are involved because of reasons it forces people to write code such as
impl Foo {
(...)
make_fn_a!(
/// Docs docs docs
);
make_fn_b!();
make_fn_c!();
}
which is harder to grasp and reason about than
impl Foo {...}
impl_a!(
/// Docs docs docs
Foo
);
impl_b!(
/// Docs docs docs
Foo
);
impl_c!(Foo);
There are also cases similar to:
impl_some_traits_but_imagine_that_it_generates_fns_in_impl_Bar_block! {
for Bar {
Clone => bar_construct_copy;
Drop => bar_destroy;
PartialEq => bar_operator_equal;
}
}
which ends up cluttering docs or actual implementation. Choose yer poison.
EDIT: I think being able to specify doc merge groups could be a very nice feature too:
// Will be merged with other docs with `#[doc(merge)]` attribute.
#[doc(merge)]
impl Foo {...}
// Will be merged with other docs with `#[doc(merge = A)]` attribute.
#[doc(merge = A)]
impl Foo {...}
but I'm unsure if it wouldn't be too messy
I'm new here, so feel to tell me if I've got something wrong!!
best,
Y


