Skip to content

Support importing enum variants through type aliases #83248

Open
@bstrie

Description

@bstrie

RFC 2338 made it possible to access enum variants through type aliases, like so:

enum Foo { F1, F2 }
type Bar = Foo;
let x = Bar::F1;

However, the following code still fails to compile:

enum Foo { F1, F2 }
type Bar = Foo;
use Bar::F1;

with:

error[E0432]: unresolved import `Bar`
 --> src/main.rs:6:5
  |
6 | use Bar::F1;
  |     ^^^ `Bar` is a type alias, not a module

Type aliases being limited in this way is a problem for libstd because it means that deprecating/renaming any enum must inevitably involve a breaking change, since re-exporting cannot be used (#30827). This was encountered in #82122 (review) .

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-resolveArea: Name/path resolution done by `rustc_resolve` specificallyC-bugCategory: This is a bug.T-langRelevant to the language team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions