Skip to content

Incorrect dereferencing suggestion when using init shorthand #52965

Closed
@estebank

Description

@estebank

The following suggestion is incorrect:

error[E0308]: mismatched types
   -->
    |
793 |         Condition::Function { function, description, expressions: exprs? }
    |                               ^^^^^^^^
    |                               |
    |                               expected enum `policy::MatchFunction`, found reference
    |                               help: consider dereferencing the borrow: `*function`
    |
    = note: expected type `policy::MatchFunction`
               found type `&policy::MatchFunction`

As the code is using the init shorthand syntax to create the Function variant, the suggestion should instead be:

error[E0308]: mismatched types
   -->
    |
793 |         Condition::Function { function, description, expressions: exprs? }
    |                               ^^^^^^^^
    |                               |
    |                               expected enum `policy::MatchFunction`, found reference
    |                               help: consider dereferencing the borrow: `function: *function`
    |
    = note: expected type `policy::MatchFunction`
               found type `&policy::MatchFunction`

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`C-bugCategory: This is a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions