diff options
author | bors <bors@rust-lang.org> | 2018-12-29 21:03:11 +0000 |
---|---|---|
committer | bors <bors@rust-lang.org> | 2018-12-29 21:03:11 +0000 |
commit | 59183180f718fc2212828e180f2f856f0db1bb9c (patch) | |
tree | 23910eebcb2479fd05771ffaa6a447d9b73371e2 /src/test/ui/issues/issue-3973.stderr | |
parent | 007115746c6d0234742719dd67efba054abe97ce (diff) | |
parent | a4fa7ef2b90880623499e86324b7b40626a02f9d (diff) | |
download | rust-59183180f718fc2212828e180f2f856f0db1bb9c.tar.gz |
Auto merge of #56225 - alexreg:type_alias_enum_variants, r=petrochenkov
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.
Diffstat (limited to 'src/test/ui/issues/issue-3973.stderr')
-rw-r--r-- | src/test/ui/issues/issue-3973.stderr | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/test/ui/issues/issue-3973.stderr b/src/test/ui/issues/issue-3973.stderr index 0f9c1564749..8e46d880181 100644 --- a/src/test/ui/issues/issue-3973.stderr +++ b/src/test/ui/issues/issue-3973.stderr @@ -8,13 +8,15 @@ LL | | } | |_____^ not a member of trait `ToString_` error[E0599]: no function or associated item named `new` found for type `Point` in the current scope - --> $DIR/issue-3973.rs:22:13 + --> $DIR/issue-3973.rs:22:20 | LL | struct Point { | ------------ function or associated item `new` not found for this ... LL | let p = Point::new(0.0, 0.0); - | ^^^^^^^^^^ function or associated item not found in `Point` + | -------^^^ + | | + | function or associated item not found in `Point` error: aborting due to 2 previous errors |