fn detect_duplicate_wrapper_defs(
content: &str,
accessor_producers: &HashMap<String, String>,
) -> Result<(), String>Expand description
Detect a second top-level name <- function definition of any wrapper
function in the assembled R wrapper text.
This is the write-time counterpart to the compile-time
check_s7_shortcut_collisions (in miniextendr-macros): it catches name
collisions that span separate macro expansions and are therefore invisible
to any single proc-macro invocation. The two motivating cases (#991):
- An S7 fast-path shortcut
<Class>_<method>colliding with a#[derive(ExternalPtr)]sidecar accessor<Class>_get_<field>/<Class>_set_<field>– the sidecar field names live in theMX_S7_SIDECAR_PROPSslice, which the impl-block macro can’t see. - Two
#[miniextendr(s7)]impl blocks on the same type each emitting a<Class>_<method>shortcut – cross-impl-block, also invisible to a single expansion.
Without this check the second definition silently clobbers the first (last-write-wins in R), so a call dispatches to the wrong implementation.
accessor_producers maps a known sidecar-accessor name to a description of
its producing derive; when a duplicate matches one we name the derive in the
message, otherwise we report the generic “defined more than once” form.
Returns Err(message) naming the offending function on the first collision
found; Ok(()) when every top-level definition name is unique.