Skip to content

Suggestion for hint: wrap in Some #5443

New issue

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

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

Already on GitHub? # to your account

Closed
Lucretiel opened this issue Jul 20, 2020 · 6 comments
Closed

Suggestion for hint: wrap in Some #5443

Lucretiel opened this issue Jul 20, 2020 · 6 comments
Labels
S-actionable Someone could pick this issue up and work on it right now

Comments

@Lucretiel
Copy link

Lucretiel commented Jul 20, 2020

Consider this error:

image

"Expected Option<T>, found T"

A useful hint/suggestion would be to propose wrapping the erroring expression in Some

@detrumi
Copy link
Member

detrumi commented Jul 20, 2020

Rustc does suggest to use Some, but we're currently not showing the suggestion:

help: try using a variant of the expected enum: `Some(...)`

@flodiebold flodiebold added the S-actionable Someone could pick this issue up and work on it right now label Dec 21, 2020
@jonas-schievink
Copy link
Contributor

We now show the rustc hint, and also have a builtin diagnostic + quickfix when this happens in a function's return value

@eminence
Copy link
Contributor

eminence commented Apr 4, 2022

This now mostly works, but there's a small problem when you have serde in scope:

image

@Veykril
Copy link
Member

Veykril commented Apr 4, 2022

The first diagnostic comes from rustc, the Wrap in Some is the diagnostic from rust-analyzer which should hopefully work correctly.

@Veykril
Copy link
Member

Veykril commented Apr 4, 2022

We can actually close this now that wrap in some is a proper type mismatch diagnostic I believe.

@Veykril Veykril closed this as completed Apr 4, 2022
@eminence
Copy link
Contributor

eminence commented Apr 4, 2022

The first diagnostic comes from rustc

Ahh, you're right, thanks. This is currently tracked at rust-lang/rust#26454

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
S-actionable Someone could pick this issue up and work on it right now
Projects
None yet
Development

No branches or pull requests

6 participants