fn merge_class_blocks(
blocks: &[ClassBlockEntry],
) -> Result<Vec<WrapperFragment>, String>Expand description
Merge the impl blocks of each Rust type into one class fragment (#1776).
Blocks are grouped by ClassBlockEntry::type_path and taken in source
order. A type’s fragment is the defining block’s head, with the
class_docs of every block (the defining block’s first) at its
CLASS_DOCS_MARKER line and the class_doc_lines of every block at its
CLASS_DOC_LINES_MARKER line, then each block’s members, then the
defining block’s tail. A tag repeated exactly is written once, and a
generated CLASS_DEFAULT_PREFIX line gives way to the same tag on
another block. A # Generated from Rust impl header precedes each
part whose block differs from the previous part’s, so the
duplicate-definition scan of the written file
(detect_duplicate_wrapper_defs) names the block a definition comes from.
Every problem is collected into one message:
- two Rust types claim one R class name: their class objects and methods would overwrite each other when the package loads (#1677);
- the blocks of a type disagree on the class settings
(
ClassBlockEntry::settings), which shape every block’s members; - two blocks of a type each have something only the defining block may
have (
ClassBlockEntry::defines); - the doc comments of a type’s blocks give the class two titles, or a
page other than the defining block’s (
class_doc_conflicts); - two blocks of a type bind the same member name
(
ClassBlockEntry::member_names), the later replacing the earlier; - a type without a declared constructor has several methods that could be
one (
resolve_class_constructor, which first picks each block’s rendering).