Skip to content

Rust generic type parameters become references edges to phantom R, T and F nodes #5677

Backlog

Description

@Max17190

On v8 at d249de36 (0.9.124), the Rust extractor treats generic type parameters as referenced types. R in fn spawn<R: Runtime>(..) -> App<R> produces a references edge, and so do parameters in fields, enum payloads, supertrait bounds and impl trait refs. The target is a sourceless stub for each name, or any real node with the same label. That can be the node of a blanket impl<T> Trait for T, or a real struct R in another file.

On tauri this adds 1268 references edges and 321 phantom nodes. 49 of those edges land on real blanket impl nodes, such as RunEvent -> T. The Go, Kotlin, Swift, Scala and C++ extractors already skip type parameters since #4383, #4402, #4403, #4404 and #4405.

Reproduction

src/lib.rs:

pub trait Runtime {}
pub trait Named { fn name(&self) -> String; }
pub struct App<R: Runtime> { runtime: R }
impl<R: Runtime> App<R> { pub fn runtime(&self) -> &R { &self.runtime } }
pub fn spawn<R: Runtime, F: Fn() -> R>(make: F) -> App<R> { App { runtime: make() } }
impl<T: Clone> Named for T { fn name(&self) -> String { String::new() } }
pub fn first<T>(items: Vec<T>) -> Option<T> { items.into_iter().next() }

Run GRAPHIFY_BACKEND=none graphify extract . --no-cluster and list the references edges in graphify-out/graph.json.

The graph has App -> R, .runtime() -> R, spawn() -> F, spawn() -> R and first() -> T. Only spawn() -> App should remain.

Linux, CPython 3.12.3.

Activity

  1. github-actions commented on Dec 1, 2026

    @github-actions

    Thanks for opening this issue, @Max17190. 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions