about summary refs log tree commit diff
path: root/src/test/ui/span
diff options
context:
space:
mode:
authorEsteban Küber <esteban@kuber.com.ar>2019-05-30 10:19:58 -0700
committerEsteban Küber <esteban@kuber.com.ar>2019-05-31 18:33:59 -0700
commit8bb094dac596a98cd3347979984834fe67bf3fcb (patch)
tree47aaf9ba899ba93541dc261700c641d90ba62b33 /src/test/ui/span
parent7840a0b753a065a41999f1fb6028f67d33e3fdd5 (diff)
downloadrust-8bb094dac596a98cd3347979984834fe67bf3fcb.tar.gz
rust-8bb094dac596a98cd3347979984834fe67bf3fcb.zip
Add more detail to type inference error
When encountering code where type inference fails, add more actionable
information:

```
fn main() {
    let foo = Vec::new();
}
```

```
error[E0282]: type annotations needed for `std::vec::Vec<_>`
  --> $DIR/vector-no-ann.rs:2:16
   |
LL |     let foo = Vec::new();
   |         ---   ^^^^^^^^ cannot infer type for `T`
   |         |
   |         consider giving `foo` the type `std::vec::Vec<_>` with the type parameter `T` specified
```

We still need to modify type printing to optionally accept a
`TypeVariableTable` in order to properly print `std::vec::Vec<T>`.

CC #25633.
Diffstat (limited to 'src/test/ui/span')
-rw-r--r--src/test/ui/span/issue-42234-unknown-receiver-type.stderr4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/test/ui/span/issue-42234-unknown-receiver-type.stderr b/src/test/ui/span/issue-42234-unknown-receiver-type.stderr
index 8923de5705b..9b0d56e38b7 100644
--- a/src/test/ui/span/issue-42234-unknown-receiver-type.stderr
+++ b/src/test/ui/span/issue-42234-unknown-receiver-type.stderr
@@ -1,8 +1,8 @@
-error[E0282]: type annotations needed
+error[E0282]: type annotations needed for `std::option::Option<_>`
   --> $DIR/issue-42234-unknown-receiver-type.rs:7:5
    |
 LL |     let x: Option<_> = None;
-   |         - consider giving `x` a type
+   |         - consider giving `x` the type `std::option::Option<_>` with the type parameter `T` specified
 LL |     x.unwrap().method_that_could_exist_on_some_type();
    |     ^^^^^^^^^^ cannot infer type for `T`
    |