Closed
Description
Consider this code:
pub fn foo(num: i32) -> i32 {
let foo: i32::from_be(num);
}
The compiler complains like this:
error[E0573]: expected type, found local variable `num`
--> <source>:2:27
|
2 | let foo: i32::from_be(num);
| ^^^ not a type
error: parenthesized parameters may only be used with a trait
--> <source>:2:26
|
2 | let foo: i32::from_be(num);
| ^^^^^
|
= note: #[deny(parenthesized_params_in_types_and_modules)] on by default
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #42238 <https://github.com/rust-lang/rust/issues/42238>
error[E0223]: ambiguous associated type
--> <source>:2:14
|
2 | let foo: i32::from_be(num);
| ^^^^^^^^^^^^^^^^^ help: use fully-qualified syntax: `<i32 as Trait>::from_be`
error[E0308]: mismatched types
--> <source>:1:29
|
1 | pub fn foo(num: i32) -> i32 {
| _____________________________^
2 | | let foo: i32::from_be(num);
3 | | }
| |_^ expected i32, found ()
|
= note: expected type `i32`
found type `()`
error: aborting due to 4 previous errors
Some errors occurred: E0223, E0308, E0573.
For more information about an error, try `rustc --explain E0223`.
It would be good if the compiler was able to suggest that you may want to replace :
with =
instead of just making suggestions based on the premise that :
was right.