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
The message is technically correct, but it refers to a generic name U that is not present in user's source code, and has no meaning in the current context.
fnmain(){assert_eq!("bar".into(),"foo".into());}
error[E0282]: unable to infer enough type information about U
cannot infer type for U
It's even weirder that the type U is not in Into<T>'s definition, but comes from somewhere else inside stdlib.
pubtraitInto<T>{fninto(self) -> T;}
It would be clearer if rustc has shown Into<U> instead, or perhaps the stdlib implementation could rename the cryptic U to something self-explanatory like TypeToBeConvertedInto.
The text was updated successfully, but these errors were encountered:
I think this can be troublesome for beginners, since this can pop up anywhere. Other example:
fn main() {
use std::collections::HashMap;
let h = HashMap::new();
}
Error message using nightly:
error[E0282]: type annotations needed
--> <anon>:4:12
|
4 | let h = HashMap::new();
| - ^^^^^^^^^^^^ cannot infer type for `K`
| |
| consider giving `h` a type
The message is technically correct, but it refers to a generic name
U
that is not present in user's source code, and has no meaning in the current context.It's even weirder that the type
U
is not inInto<T>
's definition, but comes from somewhere else inside stdlib.It would be clearer if rustc has shown
Into<U>
instead, or perhaps the stdlib implementation could rename the crypticU
to something self-explanatory likeTypeToBeConvertedInto
.The text was updated successfully, but these errors were encountered: