Add module population and case of enum in place of expression

This commit is contained in:
Maxim Zholobak 2017-11-23 15:10:23 +02:00
parent 08c81c1a79
commit 39f848efb0
3 changed files with 31 additions and 9 deletions

View file

@ -8,12 +8,20 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
enum Example { Ex(String), NotEx }
fn result_test() {
let x = Option(1);
if let Option(_) = x {
println!("It is OK.");
}
let y = Example::Ex(String::from("test"));
if let Example(_) = y {
println!("It is OK.");
}
}
fn main() {}

View file

@ -1,21 +1,32 @@
error[E0423]: expected function, found enum `Option`
--> $DIR/issue-43871-enum-instead-of-variant.rs:12:13
--> $DIR/issue-43871-enum-instead-of-variant.rs:14:13
|
14 | let x = Option(1);
| ^^^^^^
|
12 | let x = Option(1);
| ^^^^^^ not a function
= note: did you mean to use one of the following variants?
- `std::prelude::v1::Option::None`
- `std::prelude::v1::Option::Some`
error[E0532]: expected tuple struct/variant, found enum `Option`
--> $DIR/issue-43871-enum-instead-of-variant.rs:14:12
--> $DIR/issue-43871-enum-instead-of-variant.rs:16:12
|
14 | if let Option(_) = x {
16 | if let Option(_) = x {
| ^^^^^^
|
= note: did you mean to use one of the following variants?
- `std::prelude::v1::Option::None`
- `std::prelude::v1::Option::Some`
error: aborting due to previous error
error[E0532]: expected tuple struct/variant, found enum `Example`
--> $DIR/issue-43871-enum-instead-of-variant.rs:22:12
|
22 | if let Example(_) = y {
| ^^^^^^^
|
= note: did you mean to use one of the following variants?
- `Example::Ex`
- `Example::NotEx`
error: aborting due to 3 previous errors