-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-trait-systemArea: Trait systemArea: Trait systemD-confusingDiagnostics: Confusing error or lint that should be reworked.Diagnostics: Confusing error or lint that should be reworked.D-papercutDiagnostics: An error or lint that needs small tweaks.Diagnostics: An error or lint that needs small tweaks.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
Given the following code:
pub fn strip_lf(s: &str) -> &str {
s.strip_suffix(b'\n').unwrap_or(s)
}
The current output is:
error[E0277]: expected a `FnMut<(char,)>` closure, found `u8`
--> src/lib.rs:2:20
|
2 | s.strip_suffix(b'\n').unwrap_or(s)
| ^^^^^ expected an `FnMut<(char,)>` closure, found `u8`
|
= help: the trait `FnMut<(char,)>` is not implemented for `u8`
= note: required because of the requirements on the impl of `Pattern<'_>` for `u8`
Pattern<'a>
has implementations for:
char
&str
&String
&[char]
&&str
F
whereF: FnMut(char) -> bool
While it is true that u8 doesn't match any of the non-generic impls, and that it doesn't have an impl for FnMut<(char,)> -> bool
, it's sad that the error message doesn't mention that those other possibilities exist.
(Also, the error message doesn't mention the closure return type)
compiler-errors and edmorley
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-trait-systemArea: Trait systemArea: Trait systemD-confusingDiagnostics: Confusing error or lint that should be reworked.Diagnostics: Confusing error or lint that should be reworked.D-papercutDiagnostics: An error or lint that needs small tweaks.Diagnostics: An error or lint that needs small tweaks.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.