about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2016-11-09 08:51:23 -0800
committerGitHub <noreply@github.com>2016-11-09 08:51:23 -0800
commitbca365e688f0424fb99d38d477a9b7863bb070d3 (patch)
tree3bd7a0368505a06b28dadf66637979ee2c70cc76 /src/test
parent02aa42860d6e74dfa57824f79bdc9c57665d6af0 (diff)
parenta449bdb20e5fd691f6d2445a6a58f5a089d60dc1 (diff)
Auto merge of #36520 - estebank:dataless-enum, r=brson
Reword error when data-less enum variant called as function

Given a file like:

``` rust
enum Test {
    Variant,
    Variant2 {a: u32},
}

fn main(){
    let x = Test::Variant("Hello");
    let y = Test::Variant2("World");
}
```

Both errors now look similar:

``` bash
error[E0423]: `Test::Variant2` is the name of a struct or struct variant, but this expression uses it like a function name
  --> file3.rs:10:13
   |
10 |     let y = Test::Variant2("Hello");
   |             ^^^^^^^^^^^^^^ struct called like a function
   |
   = help: did you mean to write: `Test::Variant2 { /* fields */ }`?

error: `Test::Variant` is the name of a data-less enum, but this expression uses it like a function name
 --> file3.rs:9:13
  |
9 |     let x = Test::Variant("World");
  |             ^^^^^^^^^^^^^^^^^^^^^^ data-less enum called like a function
  |
  = help: did you mean to write: `Test::Variant`?
note: defined here
 --> file3.rs:2:5
  |
2 |     Variant,
  |     ^^^^^^^

error: aborting due to previous error
```

Re: #28533
Diffstat (limited to 'src/test')
-rw-r--r--src/test/compile-fail/empty-struct-unit-expr.rs8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/test/compile-fail/empty-struct-unit-expr.rs b/src/test/compile-fail/empty-struct-unit-expr.rs
index 350b96c764c..273ce91a7c5 100644
--- a/src/test/compile-fail/empty-struct-unit-expr.rs
+++ b/src/test/compile-fail/empty-struct-unit-expr.rs
@@ -23,7 +23,11 @@ enum E {
 
 fn main() {
     let e2 = Empty2(); //~ ERROR expected function, found `Empty2`
-    let e4 = E::Empty4(); //~ ERROR expected function, found `E`
+    let e4 = E::Empty4();
+    //~^ ERROR `E::Empty4` is being called, but it is not a function
+    //~| HELP did you mean to write `E::Empty4`?
     let xe2 = XEmpty2(); //~ ERROR expected function, found `empty_struct::XEmpty2`
-    let xe4 = XE::XEmpty4(); //~ ERROR  expected function, found `empty_struct::XE`
+    let xe4 = XE::XEmpty4();
+    //~^ ERROR `XE::XEmpty4` is being called, but it is not a function
+    //~| HELP did you mean to write `XE::XEmpty4`?
 }