rust-analyzer icon indicating copy to clipboard operation
rust-analyzer copied to clipboard

Cannot complete variant in hidden enum alias

Open A4-Tacks opened this issue 8 months ago • 5 comments

rust-analyzer version: rust-analyzer 0.4.2833-standalone

rustc version: rustc 1.95.0-nightly (a293cc4af 2026-01-30)

editor or extension: Vim

code snippet to reproduce:

src/lib.rs:

#[doc(hidden)]
pub enum Foo {
    Variant,
}

pub type Bar = Foo;

src/main.rs:

fn main() {
    let x = mycrate::Bar::Var$0; // cannot complete Variant
}

A4-Tacks avatar Mar 28 '26 02:03 A4-Tacks

I think, when you try to expose Bar as a public type, it gets code completion. But Foo as it has the #[doc(hidden)] attribute, RA doesn't give it code completion even for the inner variant exposed via Bar. The type Foo doesn't get code completion at all.

This is a feature of RA which was completed in this pr.

wesley-lewis avatar Mar 28 '26 14:03 wesley-lewis

From the test of #19034, it appears that this is for attributes on variants rather than attributes on enum

A4-Tacks avatar Mar 28 '26 21:03 A4-Tacks

I got your point now! While exposing "hidden" enums RA must complete the variant of the non-hidden public enum. May I work on this?

wesley-lewis avatar Mar 30 '26 07:03 wesley-lewis

@ChayimFriedman2 Is this feature expected?

A4-Tacks avatar Mar 30 '26 08:03 A4-Tacks

I don't remember my reasoning back then, however today hiding a non-#[doc(hidden)] variant from a #[doc(hidden)] enum looks obviously incorrect to me.

ChayimFriedman2 avatar Mar 30 '26 09:03 ChayimFriedman2