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

[WIP] Simplify mismatched types by removing same subtypes #39906

Closed
wants to merge 1 commit into from

Commits on Feb 19, 2017

  1. Highlight and simplify mismatched types

    Shorten mismatched types errors by replacing subtypes that are not
    different with `_`, and highlighting only the subtypes that are
    different.
    
    Given a file
    
    ```rust
    struct X<T1, T2> {
        x: T1,
        y: T2,
    }
    
    fn foo() -> X<X<String, String>, String> {
        X { x: X {x: "".to_string(), y: 2}, y: "".to_string()}
    }
    
    fn bar() -> Option<String> {
        "".to_string()
    }
    ```
    
    provide the following output
    
    ```rust
    error[E0308]: mismatched types
      --> file.rs:6:5
       |
     6 |     X { x: X {x: "".to_string(), y: 2}, y: "".to_string()}
       |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected struct `std::string::String`, found {integer}
       |
       = note: expected type `X<X<_, std::string::String>, _>`
                                     ^^^^^^^^^^^^^^^^^^^^  // < highlighted
                  found type `X<X<_, {integer}>, _>`
                                     ^^^^^^^^^             // < highlighted
    
    error[E0308]: mismatched types
      --> file.rs:6:5
       |
    10 |     "".to_string()
       |     ^^^^^^^^^^^^^^ expected struct `std::option::Option`, found `std::string::String`
       |
       = note: expected type `Option<std::string::String>`
                              ^^^^^^^                   ^  // < highlighted
                  found type `std::string::String`
    ```
    estebank committed Feb 19, 2017
    Configuration menu
    Copy the full SHA
    5ce2d15 View commit details
    Browse the repository at this point in the history