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. 🍻
This commit is contained in:
commit
84be2df0e9
17 changed files with 223 additions and 286 deletions
|
|
@ -1,15 +0,0 @@
|
|||
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
fn main() {
|
||||
let x = |_| {};
|
||||
//~^ ERROR E0101
|
||||
//~| NOTE cannot resolve type of expression
|
||||
}
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
fn main() {
|
||||
let x = [];
|
||||
//~^ ERROR type annotations needed
|
||||
//~| NOTE consider giving `x` a type
|
||||
//~| NOTE cannot infer type for `_`
|
||||
}
|
||||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,19 +0,0 @@
|
|||
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
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
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue