Repository navigation
Open
Description
Version: graphifyy 0.9.111 (latest on PyPI), Python 3.14, Linux
Summary
In a Cargo workspace with two crates that each define a type of the same name, a use crate::… import in one crate resolves to the other crate's type. It happens once the other crate has a file that itself imports its own type with use crate::… inside a nested mod tests. The correct edge is then missing entirely, so the import lands only on the wrong type.
Reproduction
Cargo.toml [workspace] members = ["crates/*"]
crates/core/Cargo.toml [package] name = "app-core"
crates/core/src/api/mod.rs
crates/core/src/client/calls.rs
crates/server/Cargo.toml [package] name = "app-server"
crates/server/src/error.rs
crates/server/src/auth/dpop.rs
crates/core/src/api/mod.rs
pub enum ApiError { Network }
pub trait ServerApi {}crates/core/src/client/calls.rs
use crate::api::ApiError;crates/server/src/error.rs
pub enum ApiError { NotFound }crates/server/src/auth/dpop.rs
pub fn check() {}
#[cfg(test)]
mod tests {
use crate::error::ApiError;
fn t() -> Option<ApiError> { None }
}Script:
import sys
from pathlib import Path
from graphify.extract import extract
root = Path(sys.argv[1]).resolve()
r = extract(sorted(root.rglob("*.rs")), cache_root=root, root=root)
for e in r["edges"]:
if e["target"].endswith("apierror") and e["relation"] in ("imports_from", "references"):
print(e["relation"], e["source"], "->", e["target"], e.get("source_location"))Actual
imports_from crates_core_src_client_calls -> crates_server_src_error_apierror L1
imports_from crates_server_src_auth_dpop -> crates_server_src_error_apierror L5
references crates_server_src_auth_dpop_t -> crates_server_src_error_apierror L7
crates/core/src/client/calls.rs imports app-server's ApiError, although crate:: there can only mean app-core.
Expected
imports_from crates_core_src_client_calls -> crates_core_src_api_mod_apierror L1
Notes
- Deleting
crates/server/src/auth/dpop.rsgives the expected edge, so the nesteduse crate::error::ApiErrorin the other crate is what takes over the resolution. - The Cargo manifests are needed: without them both crates are not told apart and the edge goes to a stub.
- Adding a function in
calls.rsthat usesApiErrorin its signature (pub fn ring() -> Result<(), ApiError>) or a second import (use crate::error::CoreError;) makes the bug disappear in this small case, but in a real workspace (about 3,000 Rust files) 8 files were affected, all importing their own crate'sApiErrorwhile another crate had a test-moduleuse crate::error::ApiError. - Related, but not the same: Rust:
useof an external crate item resolves to an unrelated same-named local symbol (falseimports_fromedges, phantom import cycles) #4699 (external crate item resolving to a local symbol, closed) and Rust extractor: lossy structure and name-only call resolution (generic impls, traits, mods, use-lists, receivers) #4285 (generalusehandling in the Rust extractor).
Metadata
Metadata
Assignees
Labels
No labels
Activity
github-actions commentedon Nov 16, 2026
Thanks for opening this issue, @unbekannt3. A maintainer will take a look soon.
If you would like to discuss it in real time, come say hi on our Discord server. For longer-form questions and ideas there is also GitHub Discussions.
To help us triage, please make sure the report includes what you expected, what actually happened, and the steps (and a small sample) to reproduce it.