From fed5cbf9cc0d11affde9030f640c697df3edd6dc Mon Sep 17 00:00:00 2001 From: Martin Vogel Date: Sun, 18 Oct 2026 16:49:36 +0200 Subject: [PATCH] fix(extract): test the empty Rust impl name before the cut cppcheck 2.20 reports the post-cut `if (!name[0])` as always false (knownConditionTrueFalse): it cannot see that writing through `lt` may empty `name`. The name is non-empty here, so the cut empties it only when `<` is the first character. Test exactly that before the cut. The behaviour is unchanged. Signed-off-by: Martin Vogel --- internal/cbm/extract_unified.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/cbm/extract_unified.c b/internal/cbm/extract_unified.c index ce7be6d29..b96e60a91 100644 --- a/internal/cbm/extract_unified.c +++ b/internal/cbm/extract_unified.c @@ -1166,12 +1166,12 @@ static const char *compute_class_qn(CBMExtractCtx *ctx, TSNode node, const WalkS * and all its calls fall back to the File node. */ if (ctx->language == CBM_LANG_RUST && strcmp(ts_node_type(node), "impl_item") == 0) { char *lt = strchr(name, '<'); + if (lt == name) { + return NULL; /* ``-style self type: no name to scope by */ + } if (lt) { *lt = '\0'; } - if (!name[0]) { - return NULL; - } } /* Nested class: prefix with the enclosing class QN (Outer.Inner) so this