Skip to content

Commit fed5cbf

Browse files
committed
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>
1 parent f75af00 commit fed5cbf

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

‎internal/cbm/extract_unified.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1166,12 +1166,12 @@ static const char *compute_class_qn(CBMExtractCtx *ctx, TSNode node, const WalkS
11661166
* and all its calls fall back to the File node. */
11671167
if (ctx->language == CBM_LANG_RUST && strcmp(ts_node_type(node), "impl_item") == 0) {
11681168
char *lt = strchr(name, '<');
1169+
if (lt == name) {
1170+
return NULL; /* `<T as Tr>`-style self type: no name to scope by */
1171+
}
11691172
if (lt) {
11701173
*lt = '\0';
11711174
}
1172-
if (!name[0]) {
1173-
return NULL;
1174-
}
11751175
}
11761176

11771177
/* Nested class: prefix with the enclosing class QN (Outer.Inner) so this

0 commit comments

Comments
 (0)