diff options
| author | Esteban Küber <esteban@kuber.com.ar> | 2019-05-30 10:19:58 -0700 |
|---|---|---|
| committer | Esteban Küber <esteban@kuber.com.ar> | 2019-05-31 18:33:59 -0700 |
| commit | 8bb094dac596a98cd3347979984834fe67bf3fcb (patch) | |
| tree | 47aaf9ba899ba93541dc261700c641d90ba62b33 /src/test/ui/methods | |
| parent | 7840a0b753a065a41999f1fb6028f67d33e3fdd5 (diff) | |
| download | rust-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/methods')
| -rw-r--r-- | src/test/ui/methods/method-ambig-one-trait-unknown-int-type.rs | 2 | ||||
| -rw-r--r-- | src/test/ui/methods/method-ambig-one-trait-unknown-int-type.stderr | 4 |
2 files changed, 3 insertions, 3 deletions
diff --git a/src/test/ui/methods/method-ambig-one-trait-unknown-int-type.rs b/src/test/ui/methods/method-ambig-one-trait-unknown-int-type.rs index 590e98dc353..e33f23c64db 100644 --- a/src/test/ui/methods/method-ambig-one-trait-unknown-int-type.rs +++ b/src/test/ui/methods/method-ambig-one-trait-unknown-int-type.rs @@ -22,7 +22,7 @@ impl Foo for Vec<isize> { fn m1() { // we couldn't infer the type of the vector just based on calling foo()... let mut x = Vec::new(); - //~^ ERROR type annotations needed [E0282] + //~^ ERROR type annotations needed x.foo(); } diff --git a/src/test/ui/methods/method-ambig-one-trait-unknown-int-type.stderr b/src/test/ui/methods/method-ambig-one-trait-unknown-int-type.stderr index 063a4865b19..bae675526bd 100644 --- a/src/test/ui/methods/method-ambig-one-trait-unknown-int-type.stderr +++ b/src/test/ui/methods/method-ambig-one-trait-unknown-int-type.stderr @@ -1,10 +1,10 @@ -error[E0282]: type annotations needed +error[E0282]: type annotations needed for `std::vec::Vec<_>` --> $DIR/method-ambig-one-trait-unknown-int-type.rs:24:17 | LL | let mut x = Vec::new(); | ----- ^^^^^^^^ cannot infer type for `T` | | - | consider giving `x` a type + | consider giving `x` the type `std::vec::Vec<_>` with the type parameter `T` specified error[E0308]: mismatched types --> $DIR/method-ambig-one-trait-unknown-int-type.rs:33:20 |
