about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorTim Neumann <mail@timnn.me>2017-04-12 14:45:45 +0200
committerGitHub <noreply@github.com>2017-04-12 14:45:45 +0200
commitafb300d831408d9ba8024ee25ab0ccb5656d94a4 (patch)
tree64906f25197e1b7a843bbce4225742fb6bb3e9c2 /src/libstd
parent5c23e7089d7e3f7335ae6b4a8ae07e809302c769 (diff)
parent2389830deaf39b736e35c471e39543d30f708972 (diff)
downloadrust-afb300d831408d9ba8024ee25ab0ccb5656d94a4.tar.gz
rust-afb300d831408d9ba8024ee25ab0ccb5656d94a4.zip
Rollup merge of #41205 - estebank:shorter-mismatched-types-2, r=nikomatsakis
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`
```

Fix #21025. Re: #40186. Follow up to #39906.

I'm looking to change how this output is accomplished so that it doesn't create list of strings to pass around, but rather add an elided `Ty` placeholder, and use the same string formatting for normal types. I'll be doing that soonish.

r? @nikomatsakis
Diffstat (limited to 'src/libstd')
0 files changed, 0 insertions, 0 deletions