Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

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

Aperta Adatta ai principianti
#4,064 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
78/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
python, rust
Ambito
devtools

Direzione di ricerca

Inizia in extractors/rust.py al ramo static_item / const_item, poi leggi _make_id, make_id, normalize_id e _file_node_id per tracciare la collisione. Riproduci con il file src/codec.rs fornito e i punti di ingresso extract() e build_from_json(). Fatto significa che il file mantiene la propria identità di nodo e la propria etichetta, le costanti anonime non creano una collisione nodo-file, e non viene prodotto alcun autoanello.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
Python
Stelle
124k
Fork
11.9k
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di Graphify-Labs/graphify

Tutte le issue di Graphify-Labs/graphify

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.