Improve compile errors for type mismatch when encoutering unwrap_or
#127545
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
C-bug
Category: This is a bug.
D-confusing
Diagnostics: Confusing error or lint that should be reworked.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Given this code:
Current error, for the motivating use case above:
It should be possible for rustc to suggest replacing this specific instantiation of
unwrap_or
withmap_or(&[], Vec::as_slice)
. Maybe similarly for some other common cases:map_or("", String::as_str)
.Originally posted by
@dtolnay
in rust-lang/libs-team#407 (comment)@rustbot label -T-rustdoc T-compiler
The text was updated successfully, but these errors were encountered: