You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
error[E0282]: type annotations needed for `std::result::Result<i32, E>`
--> src/main.rs:6:37
|
4 | let result = {
| ------ consider giving `result` the explicit type `std::result::Result<i32, E>`, where the type parameter `F` is specified
5 | let spawned_result = thread::spawn(|| 3).join();
6 | let result = spawned_result.map_err(|e| e.into());
| ^^^^^^^ cannot infer type for `F`
Which is a little bit confusing because there's no type parameter F in std::result::Result<i32, E>.
On the other hand, if we place let handler = |a| Ok(a + 1); before let result = spawned_result.map_err(|e| e.into());, we will receive correct message:
error[E0282]: type annotations needed for `std::result::Result<i32, E>`
--> src/main.rs:6:27
|
4 | let result = {
| ------ consider giving `result` the explicit type `std::result::Result<i32, E>`, where the type parameter `E` is specified
5 | let spawned_result = thread::spawn(|| 3).join();
6 | let handler = |a| Ok(a + 1);
| ^^ cannot infer type for `E`
I believe the F it's referring to here is the one in thread::spawn<F, T>(f: F), while the E it should be talking about is the one in Result<T, E>. I believe we're mixing the type argument name from the return and the input.
error[E0282]: type annotations needed for `Result<i32, _>`
--> f71.rs:6:13
|
6 | let result = spawned_result.map_err(|e| e.into());
| ^^^^^^
|
help: consider giving `result` an explicit type, where the type for type parameter `F` is specified
|
6 | let result: Result<i32, _> = spawned_result.map_err(|e| e.into());
| ++++++++++++++++
error[E0283]: type annotations needed for `Result<i32, _>`
--> f71.rs:6:13
|
6 | let result = spawned_result.map_err(|e| e.into());
| ^^^^^^ ---- type must be known at this point
|
= note: cannot satisfy `_: From<Box<dyn Any + Send>>`
= note: required for `Box<dyn Any + Send>` to implement `Into<_>`
help: consider giving `result` an explicit type, where the type for type parameter `U` is specified
|
6 | let result: Result<i32, _> = spawned_result.map_err(|e| e.into());
| ++++++++++++++++
Activity
estebank commentedon Sep 16, 2019
I believe the
Fit's referring to here is the one inthread::spawn<F, T>(f: F), while theEit should be talking about is the one inResult<T, E>. I believe we're mixing the type argument name from the return and the input.Spoonbender commentedon Mar 22, 2022
Triage: no change
estebank commentedon Aug 14, 2023
Current output:
After #114811: