Skip to content

Error for unknown variant talks about associated items #28972

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Manishearth opened this issue Oct 11, 2015 · 0 comments
Closed

Error for unknown variant talks about associated items #28972

Manishearth opened this issue Oct 11, 2015 · 0 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-enhancement Category: An issue proposing an enhancement or a PR with one. WG-diagnostics Working group: Diagnostics

Comments

@Manishearth
Copy link
Member

enum Foo {
 Bar(u8), Baz(u8)
}

fn main() {
    match Foo::Bar(1) {
        Foo::Quux(..) =>(),
        _ => ()
    }
}

(playpen)

Currently gives the error message:

<anon>:7:9: 7:22 error: no associated item named `Quux` found for type `Foo` in the current scope
<anon>:7         Foo::Quux(..) =>(),

This should be "no associated item or variant", or perhaps just "no variant" (if we can detect that its in a match statement)

@steveklabnik steveklabnik added the A-diagnostics Area: Messages for errors, warnings, and lints label Oct 29, 2015
@steveklabnik steveklabnik removed the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Mar 9, 2017
@Mark-Simulacrum Mark-Simulacrum added the C-enhancement Category: An issue proposing an enhancement or a PR with one. label Jul 24, 2017
@estebank estebank added the WG-diagnostics Working group: Diagnostics label Nov 16, 2017
bors added a commit that referenced this issue Nov 23, 2017
Use the proper term when using non-existing variant

When using a non-existing variant, function or associated item, refer to
the proper term, instead of defaulting to "associated item" in
diagnostics.

Fix #28972.

```
error[E0599]: no variant named `Quux` found for type `Foo` in the current scope
 --> file.rs:7:9
  |
7 |         Foo::Quux(..) =>(),
  |         ^^^^^^^^^^^^^
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-enhancement Category: An issue proposing an enhancement or a PR with one. WG-diagnostics Working group: Diagnostics
Projects
None yet
Development

No branches or pull requests

4 participants