rust-lang / rust-lang/rust-analyzer
"Function 'resolve_variant' is private" error when running on rust-analyzer itself
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
Description
I'm using rust-analyzer while trying to make changes to rust-analyzer, and getting an error reported here: https://github.com/rust-lang/rust-analyzer/blob/cd413d0cac0a820d2b107ba92e77e1fb77bb2de6/crates/ide-diagnostics/src/handlers/no_such_field.rs#L60
function
resolve_variantis private (E0624)
But Semantics::resolve_variant is public. rust-analyzer seems to think this line is actually calling SemanticsImpl::resolve_variant, which indeed is private. But it's accessible (or rather, would be if it were public) becase Semantics implements Deref<Target=SemanticsImpl> so that's confusing rust-analyzer I guess.
Tried making a minimal repro but I'm not getting the error here so maybe it only happens when you're accessing methods across a crate boundary or something. https://play.rust-lang.org/?version=stable&mode=debug&edition=2024&gist=a90984eb9d3bbabc1e0c570422e77388
Version 0.4.2477, Server Version 0.4.2477-standalone
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with crates/ide-diagnostics/src/handlers/no_such_field.rs at the linked line, then compare the public Semantics::resolve_variant call with the private SemanticsImpl::resolve_variant reached through Deref. Try the linked Rust Playground reproduction and investigate whether the error depends on a crate boundary. Done means the reported call resolves correctly without E0624, with a regression test if the behavior can be reproduced.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100