]> git.lizzy.rs Git - rust.git/commitdiff
Auto merge of #40775 - estebank:variant-as-type, r=petrochenkov
authorbors <bors@rust-lang.org>
Sat, 8 Apr 2017 09:23:28 +0000 (09:23 +0000)
committerbors <bors@rust-lang.org>
Sat, 8 Apr 2017 09:23:28 +0000 (09:23 +0000)
Suggest using enum when a variant is used as a type

Given a file:

```rust
enum Fruit {
    Apple(i64),
    Orange(i64),
}

fn should_return_fruit() -> Apple {
    Apple(5)
}
```

Provide the following output:

```rust
error[E0412]: cannot find type `Apple` in this scope
  --> file.rs:16:29
   |
16 | fn should_return_fruit() -> Apple {
   |                             ^^^^^ not found in this scope
   |
help: there is an enum variant `Fruit::Apple`, did you mean to use `Fruit`?
  --> file.rs:12:5
   |
12 |     Apple(i64),
   |     ^^^^^^^^^^

error[E0425]: cannot find function `Apple` in this scope
  --> file.rs:17:5
   |
17 |     Apple(5)
   |     ^^^^^ not found in this scope
   |
   = help: possible candidate is found in another module, you can import it into scope:
             `use Fruit::Apple;`
```

Fix #35675.

1  2 
src/librustc_resolve/lib.rs

Simple merge