Skip to content

Error message usage of _ is unclear #21042

Closed
@mdinger

Description

@mdinger

Error messages use _ a lot but it's meaning is never explained. This could be improved.

Playpen

fn test(o: Option<i32>) {}

fn main() {
    let i = 7;
    test(i);
}

Error:

// What is `_` supposed to mean? Apparently integral value but it still seems meaningless...
... error ... expected `core::option::Option<i32>`, found `_`  ... found integral variable)
<anon>:5     test(i);
                  ^
error: aborting due to previous error

6/8/2017: updated error message:

error[E0308]: mismatched types
 --> <anon>:5:10
  |
5 |     test(i);
  |          ^ expected enum `std::option::Option`, found integral variable
  |
  = note: expected type `std::option::Option<i32>`
             found type `{integer}`

error: aborting due to previous error

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions