codegraph icon indicating copy to clipboard operation
codegraph copied to clipboard

Rust: a call through a module that `use super::*` brings in has no edge on main (works in 1.6.2)

Open Egrn opened this issue 3 weeks ago • 2 comments

Environment

codegraph 1.6.2 from npm, and current main (f72c9d2) built from source and run on Node 22.23.4. Linux, rustc 1.99.1, fresh codegraph init. The repro crate passes cargo check.

Problem

In a mod tests with use super::*, a call like gzip::write() (the parent declares pub mod gzip;) gets a call edge in 1.6.2, but not on current main. The same module path called from the parent itself still works. Maybe it came with #3014 (use bindings follow Rust's scopes).

Minimal repro

Cargo.toml:

[package]
name = "repro_superglob"
version = "0.1.0"
edition = "2021"

src/lib.rs:

pub mod store;

src/store/mod.rs:

pub mod gzip;

pub fn load() -> u8 {
    gzip::read()
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn writes() {
        gzip::write();
        let _ = load();
    }
}

src/store/gzip.rs:

pub fn read() -> u8 {
    1
}

pub fn write() {}

Actual

1.6.2:

load   -> read    resolvedBy import,      confidence 0.9, refName gzip::read    (ok)
writes -> load    resolvedBy exact-match, confidence 0.9, refName load          (ok)
writes -> write   resolvedBy import,      confidence 0.9, refName gzip::write   (ok)

Current main:

load   -> read   resolvedBy import,      confidence 0.9, refName gzip::read   (ok)
writes -> load   resolvedBy exact-match, confidence 0.9, refName load         (ok, the test fn is indexed)

writes -> write is gone, while writes -> load stays.

Expected

writes -> gzip::write on main too, as in 1.6.2. rust-analyzer resolves it to src/store/gzip.rs.

Notes

In our crate (42 files) this is the only call through a glob-imported module, and it is a test (gzip::write_single(…) in src/load/mod.rs). Related, I checked before posting: #3014 (merged), #1892 (closed, use super::* in #[path] modules).

Egrn avatar Nov 06 '26 11:11 Egrn

I can reproduce this regression on main. I'm working on propagating parent module child declarations into submodule scopes when imported via use super::*. I'll open a PR with the reproduction test case.

mohitdixit02 avatar Nov 09 '26 13:11 mohitdixit02

Thanks for the precise report. The regression came from 1.6.3's rewrite of how Rust paths walk a crate's modules: it stopped looking through glob uses like use super::*. PR #3334 restores it, and also follows a use written inside a function, with your repro as a test. On tokio it brings back 126 call edges (and 29 on dioxus), with nothing removed.

It's merged to main today and ships in the next release.

colbymchenry avatar Nov 17 '26 23:11 colbymchenry