Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Rust: `const _` gets its file's node ID, so the file node is relabelled `_` and gains a self-loop

Closed Beginner friendly
#4,064 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

  • #4108 by @xiehuanyi — closed without merging

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python, rust
Domain
devtools

Research direction

Start in extractors/rust.py at the static_item / const_item branch, then read _make_id, make_id, normalize_id, and _file_node_id to trace the collision. Reproduce with the supplied src/codec.rs and the extract() and build_from_json() entry points. Done means the file keeps its own node identity and label, anonymous constants do not create a file-node collision, and no self-loop is produced.

Written by the indexing model from the issue text.

Description

Version: graphifyy 0.9.69

An anonymous Rust constant (const _: () = assert!(...);, the usual compile-time assertion) gets the same node ID as the file that declares it. When the graph is built, the constant's label and location replace the file node's, and the file's contains edge to the constant becomes a self-loop.

Repro, src/codec.rs:

use core::fmt;

pub const WIDTH: usize = 8;

const _: () = assert!(WIDTH == 1 << 3);

pub fn encode() {}
from pathlib import Path
from graphify.extract import extract
from graphify.build import build_from_json

r = extract([Path("src/codec.rs")], cache_root=Path("."))
G = build_from_json(r, root=".", directed=False)

extract() emits two nodes with the ID src_codec:

N src_codec 'codec.rs' L1
N src_codec '_' L5
E src_codec contains src_codec L5

After build_from_json, G.nodes["src_codec"] has label _ and source_location L5, and (src_codec, src_codec) is a self-loop.

Cause: extractors/rust.py (the static_item / const_item branch) builds the ID with _make_id(stem, item_name). make_id strips _ from each part, so the name _ becomes empty, the join gives src_codec_, and normalize_id strips the trailing underscore. The result is the bare stem, which is also what _file_node_id returns for the file.

Effect on a real project: the file node is shown as _. Every import and contains edge of the file is attached to it, so a module with a few imports ranks as a god node and a cross-community bridge in GRAPH_REPORT.md, and the graph health check reports a self-loop.

Possible fix: skip const _ / static _ in the Rust extractor, since an anonymous constant can't be referenced. Alternatively, have make_id refuse a part that strips to empty, so no symbol can collapse onto its file's ID.

Dominant language
Python
Stars
124k
Forks
11.9k
PR merge metrics
No merged PRs in 30d

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Graphify-Labs/graphify

All issues in Graphify-Labs/graphify

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.