You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Rust: enum variant paths (Mode::A) are not references to the enum #2328
Using an enum only through its variants, in an expression or a match pattern (mode::Mode::A, Mode::B => …), records no reference to the enum. A type annotation (fn takes(_m: Mode)) does. Code that constructs or matches variants without naming the type in a signature (tests, handlers, call sites) is therefore invisible to callers and impact analysis for the enum.
Reproduction
Run with CODEGRAPH=/path/to/codegraph bash repro.sh (creates and deletes a temporary project):
Thanks @mg-mg-mg for the report and the self-contained repro script.
Fixed on main in #2354, building on #2330 by @danusha2345. Rust wasn't in the pass that turns Type::VALUE-style reads into references, so a variant path that isn't a call or a struct literal reached no extractor at all. Now a variant path, written as a value (mode::Mode::A), in a match pattern (Mode::B =>, Mode::C(x) =>, Mode::D { .. } =>), or as Self::A inside the enum's own impl, references the enum. It resolves through the same module scoping as a type annotation, and it only lands on an enum that actually declares that variant. So ripgrep's Match::None reaches the ignore crate's enum, not a struct Match elsewhere.
What doesn't count: standard-library variants like Some/None/Ok/Err, Option::Some or Ordering::Less, even if your project has its own Option or Ordering; associated functions like Foo::new(), whose call still links the function; and associated consts like Limits::MAX.
On your script, callers Mode now lists takes, code and main. On ripgrep, alacritty and tokio this added 822, 917 and 665 links and removed none. Released builds parse Rust in the native parser, which has the same change.
Not covered yet: variants used bare after use Mode::*, and paths inside macros.
This ships in the next release. Re-index after upgrading (codegraph index) to pick it up. You and @danusha2345 are credited in the changelog.
Activity
Phase 4: resolution and extraction accuracy
fix(rust): a variant path references the enum that declares it (#2328)
fix(rust): a variant path references the enum that declares it (#2328)
fix(rust): a variant path references the enum that declares it (#2328)
fix(rust): a variant path references the enum that declares it (#2328) (
colbymchenry commentedon Oct 5, 2026
Thanks @mg-mg-mg for the report and the self-contained repro script.
Fixed on
mainin #2354, building on #2330 by @danusha2345. Rust wasn't in the pass that turnsType::VALUE-style reads into references, so a variant path that isn't a call or a struct literal reached no extractor at all. Now a variant path, written as a value (mode::Mode::A), in a match pattern (Mode::B =>,Mode::C(x) =>,Mode::D { .. } =>), or asSelf::Ainside the enum's ownimpl, references the enum. It resolves through the same module scoping as a type annotation, and it only lands on an enum that actually declares that variant. So ripgrep'sMatch::Nonereaches theignorecrate's enum, not astruct Matchelsewhere.What doesn't count: standard-library variants like
Some/None/Ok/Err,Option::SomeorOrdering::Less, even if your project has its ownOptionorOrdering; associated functions likeFoo::new(), whose call still links the function; and associated consts likeLimits::MAX.On your script,
callers Modenow liststakes,codeandmain. On ripgrep, alacritty and tokio this added 822, 917 and 665 links and removed none. Released builds parse Rust in the native parser, which has the same change.Not covered yet: variants used bare after
use Mode::*, and paths inside macros.This ships in the next release. Re-index after upgrading (
codegraph index) to pick it up. You and @danusha2345 are credited in the changelog.