Skip to content

Local code intelligence for developers and AI agents. Connect code, docs and infrastructure in a persistent graph, with CBM Lens, MCP tools, agent integrations and change-aware test selection.

Strip generic args from Rust impl trait/type names so INHERITS resolves

Martin Vogel035f4395e7d3
diff --git a/internal/cbm/extract_defs.c b/internal/cbm/extract_defs.c
index b5b9abbc6..b61b0c176 100644
--- a/internal/cbm/extract_defs.c
+++ b/internal/cbm/extract_defs.c
@@ -3569,11 +3569,28 @@ static void extract_rust_impl(CBMExtractCtx *ctx, TSNode node, const CBMLangSpec
if (!type_name || !type_name[0]) {
return;
}
+ /* Strip generic args from the implementing type: `Buffer<T>` → `Buffer`,
+ * `Wrapper<T>` → `Wrapper`. The struct identity is the base name. */
+ {
+ char *lt = strchr(type_name, '<');
+ if (lt) {
+ *lt = '\0';
+ }
+ }
// Check for "impl Trait for Struct" pattern
TSNode trait_node = ts_node_child_by_field_name(node, TS_FIELD("trait"));
if (!ts_node_is_null(trait_node)) {
char *trait_name = cbm_node_text(a, trait_node, ctx->source);
+ /* Strip generic args from the trait: `From<Feet>` → `From`,
+ * `Index<usize>` → `Index`, `AsRef<str>` → `AsRef`. Qualified paths
+ * like `io::Write` / `fmt::Display` have no `<` and are preserved. */
+ if (trait_name) {
+ char *lt = strchr(trait_name, '<');
+ if (lt) {
+ *lt = '\0';
+ }
+ }
if (trait_name && trait_name[0]) {
CBMImplTrait it;
it.trait_name = trait_name;
diff --git a/internal/cbm/lang_specs.c b/internal/cbm/lang_specs.c
index e69c879b9..a086de7d9 100644
--- a/internal/cbm/lang_specs.c
+++ b/internal/cbm/lang_specs.c
@@ -372,7 +372,7 @@ static const char *cs_branch_types[] = {"if_statement", "for_statement", "
"try_statement", "catch_clause", NULL};
static const char *cs_var_types[] = {"field_declaration", "local_declaration_statement", NULL};
static const char *cs_field_types[] = {"field_declaration", "property_declaration", NULL};
-static const char *cs_assign_types[] = {"assignment_expression", NULL};
+static const char *cs_assign_types[] = {"assignment_expression", "update_expression", NULL};
static const char *cs_throw_types[] = {"throw_statement", "throw_expression", NULL};
static const char *cs_decorator_types[] = {"attribute", NULL};