about summary refs log tree commit diff
path: root/src/test/ui/error-codes
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2018-12-29 21:03:11 +0000
committerbors <bors@rust-lang.org>2018-12-29 21:03:11 +0000
commit59183180f718fc2212828e180f2f856f0db1bb9c (patch)
tree23910eebcb2479fd05771ffaa6a447d9b73371e2 /src/test/ui/error-codes
parent007115746c6d0234742719dd67efba054abe97ce (diff)
parenta4fa7ef2b90880623499e86324b7b40626a02f9d (diff)
downloadrust-59183180f718fc2212828e180f2f856f0db1bb9c.tar.gz
rust-59183180f718fc2212828e180f2f856f0db1bb9c.zip
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/error-codes')
-rw-r--r--src/test/ui/error-codes/E0109.stderr4
-rw-r--r--src/test/ui/error-codes/E0110.rs3
-rw-r--r--src/test/ui/error-codes/E0110.stderr4
-rw-r--r--src/test/ui/error-codes/E0599.stderr4
4 files changed, 7 insertions, 8 deletions
diff --git a/src/test/ui/error-codes/E0109.stderr b/src/test/ui/error-codes/E0109.stderr
index 447b106c629..a5508f98085 100644
--- a/src/test/ui/error-codes/E0109.stderr
+++ b/src/test/ui/error-codes/E0109.stderr
@@ -1,8 +1,8 @@
-error[E0109]: type parameters are not allowed on this type
+error[E0109]: type arguments are not allowed on this entity
   --> $DIR/E0109.rs:1:14
    |
 LL | type X = u32<i32>; //~ ERROR E0109
-   |              ^^^ type parameter not allowed
+   |              ^^^ type argument not allowed
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/error-codes/E0110.rs b/src/test/ui/error-codes/E0110.rs
index 2de5da16ad7..764b62b8dfe 100644
--- a/src/test/ui/error-codes/E0110.rs
+++ b/src/test/ui/error-codes/E0110.rs
@@ -1,4 +1,3 @@
 type X = u32<'static>; //~ ERROR E0110
 
-fn main() {
-}
+fn main() {}
diff --git a/src/test/ui/error-codes/E0110.stderr b/src/test/ui/error-codes/E0110.stderr
index 609b8b58276..a644ac92cef 100644
--- a/src/test/ui/error-codes/E0110.stderr
+++ b/src/test/ui/error-codes/E0110.stderr
@@ -1,8 +1,8 @@
-error[E0110]: lifetime parameters are not allowed on this type
+error[E0110]: lifetime arguments are not allowed on this entity
   --> $DIR/E0110.rs:1:14
    |
 LL | type X = u32<'static>; //~ ERROR E0110
-   |              ^^^^^^^ lifetime parameter not allowed
+   |              ^^^^^^^ lifetime argument not allowed
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/error-codes/E0599.stderr b/src/test/ui/error-codes/E0599.stderr
index 5a7cddbf382..85110889e9a 100644
--- a/src/test/ui/error-codes/E0599.stderr
+++ b/src/test/ui/error-codes/E0599.stderr
@@ -1,11 +1,11 @@
 error[E0599]: no associated item named `NotEvenReal` found for type `Foo` in the current scope
-  --> $DIR/E0599.rs:4:15
+  --> $DIR/E0599.rs:4:20
    |
 LL | struct Foo;
    | ----------- associated item `NotEvenReal` not found for this
 ...
 LL |     || if let Foo::NotEvenReal() = Foo {}; //~ ERROR E0599
-   |               ^^^^^^^^^^^^^^^^^^ associated item not found in `Foo`
+   |               -----^^^^^^^^^^^-- associated item not found in `Foo`
 
 error: aborting due to previous error