Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect dereferencing suggestion when using init shorthand #52965

Closed
estebank opened this issue Aug 1, 2018 · 0 comments
Closed

Incorrect dereferencing suggestion when using init shorthand #52965

estebank opened this issue Aug 1, 2018 · 0 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix`. C-bug Category: This is a bug.

Comments

@estebank
Copy link
Contributor

estebank commented Aug 1, 2018

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`
@estebank estebank added the A-diagnostics Area: Messages for errors, warnings, and lints label Aug 1, 2018
@estebank estebank added C-bug Category: This is a bug. A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix`. labels Mar 19, 2019
Centril added a commit to Centril/rust that referenced this issue Mar 29, 2019
…d, r=davidtwco

Account for short-hand field syntax when suggesting borrow

Fix rust-lang#52965.
Centril added a commit to Centril/rust that referenced this issue Mar 30, 2019
…d, r=davidtwco

Account for short-hand field syntax when suggesting borrow

Fix rust-lang#52965.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix`. C-bug Category: This is a bug.
Projects
None yet
Development

No branches or pull requests

1 participant