-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make need_type_info_err
more conservative
#73027
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,13 @@ | ||
error[E0282]: type annotations needed for `Expr<'_, VAR>` | ||
--> $DIR/issue-23046.rs:17:15 | ||
error[E0282]: type annotations needed for the closure `fn(Expr<'_, _>) -> Expr<'_, _>` | ||
--> $DIR/issue-23046.rs:18:9 | ||
| | ||
LL | let ex = |x| { | ||
| ^ consider giving this closure parameter the explicit type `Expr<'_, VAR>`, where the type parameter `VAR` is specified | ||
LL | let_(add(x,x), |y| { | ||
| ^^^^ cannot infer type for type parameter `VAR` declared on the function `let_` | ||
| | ||
help: give this closure an explicit return type without `_` placeholders | ||
| | ||
LL | let_(add(x, x), |x|-> Expr<'_, _> { x })})}; | ||
| ^^^^^^^^^^^^^^^^ ^ | ||
Comment on lines
+1
to
+10
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ...so it could be argued is this (but inference works with either suggestion, so this is acceptable). |
||
|
||
error: aborting due to previous error | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
fn no_err() { | ||
|x: String| x; | ||
let _ = String::from("x"); | ||
} | ||
|
||
fn err() { | ||
String::from("x".as_ref()); //~ ERROR type annotations needed | ||
} | ||
|
||
fn arg_pat_closure_err() { | ||
|x| String::from("x".as_ref()); //~ ERROR type annotations needed | ||
} | ||
|
||
fn local_pat_closure_err() { | ||
let _ = "x".as_ref(); //~ ERROR type annotations needed | ||
} | ||
|
||
fn err_first_arg_pat() { | ||
String::from("x".as_ref()); //~ ERROR type annotations needed | ||
|x: String| x; | ||
} | ||
|
||
fn err_second_arg_pat() { | ||
|x: String| x; | ||
String::from("x".as_ref()); //~ ERROR type annotations needed | ||
} | ||
|
||
fn err_mid_arg_pat() { | ||
|x: String| x; | ||
|x: String| x; | ||
|x: String| x; | ||
|x: String| x; | ||
String::from("x".as_ref()); //~ ERROR type annotations needed | ||
|x: String| x; | ||
|x: String| x; | ||
|x: String| x; | ||
|x: String| x; | ||
} | ||
|
||
fn err_first_local_pat() { | ||
String::from("x".as_ref()); //~ ERROR type annotations needed | ||
let _ = String::from("x"); | ||
} | ||
|
||
fn err_second_local_pat() { | ||
let _ = String::from("x"); | ||
String::from("x".as_ref()); //~ ERROR type annotations needed | ||
} | ||
|
||
fn err_mid_local_pat() { | ||
let _ = String::from("x"); | ||
let _ = String::from("x"); | ||
let _ = String::from("x"); | ||
let _ = String::from("x"); | ||
String::from("x".as_ref()); //~ ERROR type annotations needed | ||
let _ = String::from("x"); | ||
let _ = String::from("x"); | ||
let _ = String::from("x"); | ||
let _ = String::from("x"); | ||
} | ||
|
||
fn main() {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
error[E0283]: type annotations needed | ||
--> $DIR/issue-72690.rs:7:5 | ||
| | ||
LL | String::from("x".as_ref()); | ||
| ^^^^^^^^^^^^ cannot infer type for struct `std::string::String` | ||
| | ||
= note: cannot satisfy `std::string::String: std::convert::From<&_>` | ||
= note: required by `std::convert::From::from` | ||
|
||
error[E0282]: type annotations needed | ||
--> $DIR/issue-72690.rs:11:6 | ||
| | ||
LL | |x| String::from("x".as_ref()); | ||
| ^ consider giving this closure parameter a type | ||
|
||
error[E0283]: type annotations needed | ||
--> $DIR/issue-72690.rs:15:17 | ||
| | ||
LL | let _ = "x".as_ref(); | ||
| ^^^^^^ cannot infer type for type `str` | ||
| | ||
= note: cannot satisfy `str: std::convert::AsRef<_>` | ||
|
||
error[E0283]: type annotations needed | ||
--> $DIR/issue-72690.rs:19:5 | ||
| | ||
LL | String::from("x".as_ref()); | ||
| ^^^^^^^^^^^^ cannot infer type for struct `std::string::String` | ||
| | ||
= note: cannot satisfy `std::string::String: std::convert::From<&_>` | ||
= note: required by `std::convert::From::from` | ||
|
||
error[E0283]: type annotations needed | ||
--> $DIR/issue-72690.rs:25:5 | ||
| | ||
LL | String::from("x".as_ref()); | ||
| ^^^^^^^^^^^^ cannot infer type for struct `std::string::String` | ||
| | ||
= note: cannot satisfy `std::string::String: std::convert::From<&_>` | ||
= note: required by `std::convert::From::from` | ||
|
||
error[E0283]: type annotations needed | ||
--> $DIR/issue-72690.rs:33:5 | ||
| | ||
LL | String::from("x".as_ref()); | ||
| ^^^^^^^^^^^^ cannot infer type for struct `std::string::String` | ||
| | ||
= note: cannot satisfy `std::string::String: std::convert::From<&_>` | ||
= note: required by `std::convert::From::from` | ||
|
||
error[E0283]: type annotations needed for `std::string::String` | ||
--> $DIR/issue-72690.rs:41:5 | ||
| | ||
LL | String::from("x".as_ref()); | ||
| ^^^^^^^^^^^^ cannot infer type for struct `std::string::String` | ||
LL | let _ = String::from("x"); | ||
| - consider giving this pattern a type | ||
| | ||
= note: cannot satisfy `std::string::String: std::convert::From<&_>` | ||
= note: required by `std::convert::From::from` | ||
Comment on lines
+51
to
+60
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems to still give an incorrect suggestion. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For these two incorrect suggestions the immediate solution is to require that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (There's some discussion in this thread) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just looked at the thread. I would feel better about merging this PR as is if we had someone focusing on adding better tracking to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah definitely! If you send me some details about what needs doing/where to start I can get on that right away |
||
|
||
error[E0283]: type annotations needed for `std::string::String` | ||
--> $DIR/issue-72690.rs:47:5 | ||
| | ||
LL | let _ = String::from("x"); | ||
| - consider giving this pattern a type | ||
LL | String::from("x".as_ref()); | ||
| ^^^^^^^^^^^^ cannot infer type for struct `std::string::String` | ||
| | ||
= note: cannot satisfy `std::string::String: std::convert::From<&_>` | ||
= note: required by `std::convert::From::from` | ||
Comment on lines
+62
to
+71
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ...and this. |
||
|
||
error[E0283]: type annotations needed for `std::string::String` | ||
--> $DIR/issue-72690.rs:55:5 | ||
| | ||
LL | let _ = String::from("x"); | ||
| - consider giving this pattern a type | ||
... | ||
LL | String::from("x".as_ref()); | ||
| ^^^^^^^^^^^^ cannot infer type for struct `std::string::String` | ||
| | ||
= note: cannot satisfy `std::string::String: std::convert::From<&_>` | ||
= note: required by `std::convert::From::from` | ||
|
||
error: aborting due to 9 previous errors | ||
|
||
Some errors have detailed explanations: E0282, E0283. | ||
For more information about an error, try `rustc --explain E0282`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is technically a regression, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is the cost of making the suggestion more conservative. The point is at the moment we're struggling with things like this playground which urgently requires attention