-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Open
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
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.
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.