Skip to content
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

Reword error when data-less enum variant called as function #36520

Merged
merged 1 commit into from
Nov 9, 2016

Commits on Oct 22, 2016

  1. Reword error when data-less enum variant called as function

    Given a file like:
    
    ```rust
    enum Test {
        Variant,
        Variant2 {a: u32},
    }
    
    fn main(){
        let x = Test::Variant("Hello");
        let y = Test::Variant2("World");
    }
    ```
    
    The errors now look this way:
    
    ```bash
    error[E0423]: `Test::Variant2` is the name of a struct or struct variant, but this expression uses it like a function name
      --> file3.rs:10:13
       |
    10 |     let y = Test::Variant2("Hello");
       |             ^^^^^^^^^^^^^^ struct called like a function
       |
       = help: did you mean to write: `Test::Variant2 { /* fields */ }`?
    
    error: `Test::Variant` is being called, but it is not a function
     --> file3.rs:9:13
      |
    9 |     let x = Test::Variant("World");
      |             ^^^^^^^^^^^^^^^^^^^^^^
      |
      = help: did you mean to write: `Test::Variant`?
    note: defined here
     --> file3.rs:2:5
      |
    2 |     Variant,
      |     ^^^^^^^
    
    error: aborting due to previous error
    ```
    estebank committed Oct 22, 2016
    Configuration menu
    Copy the full SHA
    a449bdb View commit details
    Browse the repository at this point in the history