Open
Description
Code
enum A<T> {
X(T)
}
fn f() -> A<()> {
A::X(0_u32)
}
fn main() {}
Current output
error[E0308]: mismatched types
--> src/main.rs:6:10
|
6 | A::X(0_u32)
| ---- ^^^^^ expected `()`, found `u32`
| |
| arguments to this enum variant are incorrect
|
note: tuple variant defined here
--> src/main.rs:2:5
|
2 | X(T)
| ^
Due to the use of generics, seeing the definition of the enum variant doesn't really get at the root of the problem.
Ideal output
error[E0308]: mismatched types
--> src/main.rs:6:10
|
6 | A::X(0_u32)
| ---- ^^^^^ expected `()`, found `u32`
| |
| arguments to this enum variant are incorrect
note: expected `()` due to the function signature specifying the generic type for `A`:
|
5 | fn f() -> A<()> {
| ^^
Impact
This can happen with Option
or Result
, which are common return types.