Skip to content

Poor error message for variant value being used as type. #17546

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
Ryman opened this issue Sep 26, 2014 · 1 comment
Closed

Poor error message for variant value being used as type. #17546

Ryman opened this issue Sep 26, 2014 · 1 comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints

Comments

@Ryman
Copy link
Contributor

Ryman commented Sep 26, 2014

Couldn't find another issue for this.

use self::MyEnum::*;

enum MyEnum {
    Result,
    NoResult
}

fn new() -> Result<MyEnum, String> {
    unimplemented!()
}

fn main() {
    let _ = new();
}

The error message for this is poor and should suggest qualifying the type, or at least clearly saying that a value from MyEnum cannot be used as a type, and the span should then help the user understand (it is currently fine):

<anon>:6:13: 6:35 error: found value name used as a type: DefVariant(syntax::ast::DefId{krate: 0u32, node: 4u32}, syntax::ast::DefId{krate: 0u32, node: 5u32}, false)
<anon>:6 fn new() -> Result<MyEnum, String> {
                     ^~~~~~~~~~~~~~~~~~~~~~

Error message comes from astconv, so we could probably catch this in resolve?

@pnkfelix
Copy link
Member

(I'll update the example so that the bug is still demonstrable.)

Ryman added a commit to Ryman/rust that referenced this issue Jul 17, 2015
This also changes how variant values are printed in errors, they are no
longer printed in their parent scope. As far as I can tell, this is
leftover from pre-namespacing of enums.

Closes rust-lang#17546.
bors added a commit that referenced this issue Jul 18, 2015
This also changes how variant values are printed in errors, they are no
longer printed in their parent scope. As far as I can tell, this is
leftover from pre-namespacing of enums.

Closes #17546.
lnicola pushed a commit to lnicola/rust that referenced this issue Jul 11, 2024
internal: Diagnose unresolved self value in path expression
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
Projects
None yet
Development

No branches or pull requests

3 participants