diff options
| author | bors <bors@rust-lang.org> | 2017-04-19 01:27:08 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2017-04-19 01:27:08 +0000 |
| commit | 84be2df0e9dac63a4e730c4f5652deb872060ad8 (patch) | |
| tree | b3df9b50b25e5689a592be81c7f691c2e325e9f0 /src/test | |
| parent | 9f2abadca2d065bf81772cb84981d0a22d8e98b3 (diff) | |
| parent | 3092ac40b617ec26dc03cd56558267be03c25cbd (diff) | |
| download | rust-84be2df0e9dac63a4e730c4f5652deb872060ad8.tar.gz rust-84be2df0e9dac63a4e730c4f5652deb872060ad8.zip | |
Auto merge of #41236 - cengizIO:master, r=nikomatsakis
Move E0101 and E0102 logic into new E0282 mechanism #40013
Hello there!
## What's this?
Previously, me and @nikomatsakis worked on error messages of uninferred locals. (#38812)
This aims to build up on that by moving certain type checks from `writeback`.
With this, `E0101` and `E0102` errors are getting obsoleted and no longer thrown.
They're replaced with customized versions of `E0282`s instead.
## Sample Error Messages
#### `E0101` is getting converted into:
```rust
error[E0282]: type annotations needed
--> test.rs:2:14
|
2 | let x = |_| {};
| ^ consider giving this closure parameter a type
error: aborting due to previous error
```
#### `E0102` is getting converted into:
```rust
error[E0282]: type annotations needed
--> test.rs:2:9
|
2 | let x = [];
| ^
| |
| consider giving `x` a type
| cannot infer type for `[_; 0]`
error: aborting due to previous error
```
## Annoyances
- I think we need to change our way of type name resolving in relevant places, because that `[_; 0]` looks horrible IMHO.
- I'm not terribly happy with the note ordering of errors. So please do point to code that might help me accomplish this.
## Tests
Tests of `E0101` and `E0102` are getting converted from `compile-fail` to `ui` tests.
## Documentation
Please help me with documentation update. There are some confusing places that needed an update but I'm not sure if I did the right ones.
Please do comment on messages, layouts and other details.
## Appreciation
Huge thanks goes to @nikomatsakis for being a patient and humble mentor along this long journey. 🍻
Diffstat (limited to 'src/test')
13 files changed, 47 insertions, 30 deletions
diff --git a/src/test/compile-fail/issue-12187-1.rs b/src/test/compile-fail/issue-12187-1.rs index 6aeb9442c40..a79021d3cd5 100644 --- a/src/test/compile-fail/issue-12187-1.rs +++ b/src/test/compile-fail/issue-12187-1.rs @@ -16,5 +16,5 @@ fn main() { let &v = new(); //~^ ERROR type annotations needed [E0282] //~| NOTE cannot infer type for `_` - //~| NOTE consider giving a type to pattern + //~| NOTE consider giving the pattern a type } diff --git a/src/test/compile-fail/issue-12187-2.rs b/src/test/compile-fail/issue-12187-2.rs index d52ed06c408..38b3c5d4e9a 100644 --- a/src/test/compile-fail/issue-12187-2.rs +++ b/src/test/compile-fail/issue-12187-2.rs @@ -16,5 +16,5 @@ fn main() { let &v = new(); //~^ ERROR type annotations needed [E0282] //~| NOTE cannot infer type for `_` - //~| NOTE consider giving a type to pattern + //~| NOTE consider giving the pattern a type } diff --git a/src/test/ui/type-check/issue-38812-2.rs b/src/test/ui/type-check/cannot_infer_local_or_array.rs index c476657d207..0b35a9c3dbe 100644 --- a/src/test/ui/type-check/issue-38812-2.rs +++ b/src/test/ui/type-check/cannot_infer_local_or_array.rs @@ -9,5 +9,5 @@ // except according to those terms. fn main() { - let (x,) = (vec![],); + let x = []; } diff --git a/src/test/ui/type-check/cannot_infer_local_or_array.stderr b/src/test/ui/type-check/cannot_infer_local_or_array.stderr new file mode 100644 index 00000000000..8c52bb5a1d3 --- /dev/null +++ b/src/test/ui/type-check/cannot_infer_local_or_array.stderr @@ -0,0 +1,10 @@ +error[E0282]: type annotations needed + --> $DIR/cannot_infer_local_or_array.rs:12:13 + | +12 | let x = []; + | - ^^ cannot infer type for `_` + | | + | consider giving `x` a type + +error: aborting due to previous error + diff --git a/src/test/ui/type-check/issue-38812.rs b/src/test/ui/type-check/cannot_infer_local_or_vec.rs index a9943f75336..a9943f75336 100644 --- a/src/test/ui/type-check/issue-38812.rs +++ b/src/test/ui/type-check/cannot_infer_local_or_vec.rs diff --git a/src/test/ui/type-check/issue-38812.stderr b/src/test/ui/type-check/cannot_infer_local_or_vec.stderr index 6365e761453..4788fad2088 100644 --- a/src/test/ui/type-check/issue-38812.stderr +++ b/src/test/ui/type-check/cannot_infer_local_or_vec.stderr @@ -1,5 +1,5 @@ error[E0282]: type annotations needed - --> $DIR/issue-38812.rs:12:13 + --> $DIR/cannot_infer_local_or_vec.rs:12:13 | 12 | let x = vec![]; | - ^^^^^^ cannot infer type for `T` diff --git a/src/test/compile-fail/E0101.rs b/src/test/ui/type-check/cannot_infer_local_or_vec_in_tuples.rs index 0005da048e4..8d32c1ff683 100644 --- a/src/test/compile-fail/E0101.rs +++ b/src/test/ui/type-check/cannot_infer_local_or_vec_in_tuples.rs @@ -1,4 +1,4 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // @@ -9,7 +9,5 @@ // except according to those terms. fn main() { - let x = |_| {}; - //~^ ERROR E0101 - //~| NOTE cannot resolve type of expression + let (x, ) = (vec![], ); } diff --git a/src/test/ui/type-check/cannot_infer_local_or_vec_in_tuples.stderr b/src/test/ui/type-check/cannot_infer_local_or_vec_in_tuples.stderr new file mode 100644 index 00000000000..ccffadebe9e --- /dev/null +++ b/src/test/ui/type-check/cannot_infer_local_or_vec_in_tuples.stderr @@ -0,0 +1,12 @@ +error[E0282]: type annotations needed + --> $DIR/cannot_infer_local_or_vec_in_tuples.rs:12:18 + | +12 | let (x, ) = (vec![], ); + | ----- ^^^^^^ cannot infer type for `T` + | | + | consider giving the pattern a type + | + = note: this error originates in a macro outside of the current crate + +error: aborting due to previous error + diff --git a/src/test/compile-fail/issue-22897.rs b/src/test/ui/type-check/issue-22897.rs index c6bbf2d4abc..296dc81a89b 100644 --- a/src/test/compile-fail/issue-22897.rs +++ b/src/test/ui/type-check/issue-22897.rs @@ -1,4 +1,4 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // @@ -10,10 +10,6 @@ fn main() { } -// Before these errors would ICE as "cat_expr Errd" because the errors -// were unknown when the bug was triggered. - fn unconstrained_type() { []; - //~^ ERROR cannot determine a type for this expression: unconstrained type } diff --git a/src/test/ui/type-check/issue-22897.stderr b/src/test/ui/type-check/issue-22897.stderr new file mode 100644 index 00000000000..95684118851 --- /dev/null +++ b/src/test/ui/type-check/issue-22897.stderr @@ -0,0 +1,8 @@ +error[E0282]: type annotations needed + --> $DIR/issue-22897.rs:14:5 + | +14 | []; + | ^^ cannot infer type for `[_; 0]` + +error: aborting due to previous error + diff --git a/src/test/ui/type-check/issue-38812-2.stderr b/src/test/ui/type-check/issue-38812-2.stderr deleted file mode 100644 index 156a6bdee99..00000000000 --- a/src/test/ui/type-check/issue-38812-2.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0282]: type annotations needed - --> $DIR/issue-38812-2.rs:12:17 - | -12 | let (x,) = (vec![],); - | ---- ^^^^^^ cannot infer type for `T` - | | - | consider giving a type to pattern - | - = note: this error originates in a macro outside of the current crate - -error: aborting due to previous error - diff --git a/src/test/compile-fail/E0102.rs b/src/test/ui/type-check/unknown_type_for_closure.rs index 6a17ddebd1d..f1d357df12c 100644 --- a/src/test/compile-fail/E0102.rs +++ b/src/test/ui/type-check/unknown_type_for_closure.rs @@ -1,4 +1,4 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // @@ -9,8 +9,5 @@ // except according to those terms. fn main() { - let x = []; - //~^ ERROR type annotations needed - //~| NOTE consider giving `x` a type - //~| NOTE cannot infer type for `_` + let x = |_| { }; } diff --git a/src/test/ui/type-check/unknown_type_for_closure.stderr b/src/test/ui/type-check/unknown_type_for_closure.stderr new file mode 100644 index 00000000000..afbd15ca486 --- /dev/null +++ b/src/test/ui/type-check/unknown_type_for_closure.stderr @@ -0,0 +1,8 @@ +error[E0282]: type annotations needed + --> $DIR/unknown_type_for_closure.rs:12:14 + | +12 | let x = |_| { }; + | ^ consider giving this closure parameter a type + +error: aborting due to previous error + |
