2017-02-17 09:32:25 -06:00
|
|
|
error[E0308]: mismatched types
|
|
|
|
--> $DIR/ex2b-push-no-existing-names.rs:16:12
|
|
|
|
|
|
|
|
|
16 | x.push(y);
|
|
|
|
| ^ lifetime mismatch
|
|
|
|
|
|
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`
```
2017-02-17 16:31:59 -06:00
|
|
|
= note: expected type `Ref<'_, _>`
|
|
|
|
found type `Ref<'_, _>`
|
2017-05-17 14:27:58 -05:00
|
|
|
note: the anonymous lifetime #3 defined on the function body at 15:1...
|
2017-05-07 11:57:51 -05:00
|
|
|
--> $DIR/ex2b-push-no-existing-names.rs:15:1
|
2017-02-17 09:32:25 -06:00
|
|
|
|
|
2017-05-07 11:57:51 -05:00
|
|
|
15 | / fn foo(x: &mut Vec<Ref<i32>>, y: Ref<i32>) {
|
2017-02-17 09:32:25 -06:00
|
|
|
16 | | x.push(y);
|
|
|
|
17 | | }
|
2017-04-14 18:38:10 -05:00
|
|
|
| |_^
|
2017-05-17 14:27:58 -05:00
|
|
|
note: ...does not necessarily outlive the anonymous lifetime #2 defined on the function body at 15:1
|
2017-05-07 11:57:51 -05:00
|
|
|
--> $DIR/ex2b-push-no-existing-names.rs:15:1
|
2017-02-17 09:32:25 -06:00
|
|
|
|
|
2017-05-07 11:57:51 -05:00
|
|
|
15 | / fn foo(x: &mut Vec<Ref<i32>>, y: Ref<i32>) {
|
2017-02-17 09:32:25 -06:00
|
|
|
16 | | x.push(y);
|
|
|
|
17 | | }
|
2017-04-14 18:38:10 -05:00
|
|
|
| |_^
|
2017-02-17 09:32:25 -06:00
|
|
|
|
2017-07-02 05:49:30 -05:00
|
|
|
error: aborting due to previous error
|
2017-02-17 09:32:25 -06:00
|
|
|
|