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 <martin.vogel.tech@gmail.com>
This commit is contained in:
Martin Vogel
2026-10-18 16:49:36 +02:00
parent f75af00a8b
commit fed5cbf9cc
+3 -3
View File
@@ -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; /* `<T as Tr>`-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