]> git.lizzy.rs Git - rust.git/commit
Suggest using enum when a variant is used as a type
authorEsteban Küber <esteban@kuber.com.ar>
Thu, 23 Mar 2017 22:14:45 +0000 (15:14 -0700)
committerEsteban Küber <esteban@kuber.com.ar>
Sun, 2 Apr 2017 16:33:41 +0000 (09:33 -0700)
commitb946ecd02018d1671c990057d7136176df60da35
treecbce6be0c58b69cef93fa14656a0e13a9b5c0291
parent5e122f59ba23494d460466cca53c71646d99c767
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;`
```
src/librustc_resolve/lib.rs
src/test/ui/did_you_mean/issue-35675.rs [new file with mode: 0644]
src/test/ui/did_you_mean/issue-35675.stderr [new file with mode: 0644]