Implement RFC 2338, "Type alias enum variants" This PR implements [RFC 2338](https://github.com/rust-lang/rfcs/pull/2338), allowing one to write code like the following. ```rust #![feature(type_alias_enum_variants)] enum Foo { Bar(i32), Baz { i: i32 }, } type Alias = Foo; fn main() { let t = Alias::Bar(0); let t = Alias::Baz { i: 0 }; match t { Alias::Bar(_i) => {} Alias::Baz { i: _i } => {} } } ``` Since `Self` can be considered a type alias in this context, it also enables using `Self::Variant` as both a constructor and pattern. Fixes issues #56199 and #56611. N.B., after discussing the syntax for type arguments on enum variants with @petrochenkov and @eddyb (there are also a few comments on the [tracking issue](https://github.com/rust-lang/rust/issues/49683)), the consensus seems to be treat the syntax as follows, which ought to be backwards-compatible. ```rust Option::<u8>::None; // OK Option::None::<u8>; // OK, but lint in near future (hard error next edition?) Alias::<u8>::None; // OK Alias::None::<u8>; // Error ``` I do not know if this will need an FCP, but let's start one if so. |
||
|---|---|---|
| .. | ||
| check | ||
| coherence | ||
| outlives | ||
| variance | ||
| astconv.rs | ||
| Cargo.toml | ||
| check_unused.rs | ||
| collect.rs | ||
| constrained_type_params.rs | ||
| diagnostics.rs | ||
| impl_wf_check.rs | ||
| lib.rs | ||
| namespace.rs | ||
| README.md | ||
| structured_errors.rs | ||
For high-level intro to how type checking works in rustc, see the type checking chapter of the rustc guide.