Open DavidArchibald opened 6 months ago
Hmm, this feels like a bug to me? Anyway, as a workaround, you can trigger the "Change visibility to pub(crate)" quick assist, then press Undo, which will leave the caret on the function.
The relevant entry point is here https://github.com/rust-lang/rust-analyzer/blob/47a901b9bf1f99b1ec5222d478684fc412d526a5/crates/hir/src/source_analyzer.rs#L1082-L1150, this is where the ide rederives the path resolutions. Presumabily we filter out by visibility inside the calls which is usually the correct thing, though here we'd just want to prefer visible over invisible definitions.
It's a not wholly uncommon occurrence for me to import or otherwise use something that's private within my own code and it always feels clunky to have to manually go to the symbol because Go To Definition doesn't work on private symbols.
Here's a minimum example:
If you try to use Go to Definition on
public_module::accidentally_private
you're unable to, despite the fact thatrustc
itself points out the line number. It's not a huge deal, it'd just be nice to have as an improvement.I'd be willing to submit a PR for this but I'd appreciate first knowing if this is a tenable idea as well as a rough direction, e.g. where Go to Definition happens and possibly how to look up private symbols if that's tricky.