forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Suggest dereferncing when possible in E0277, fix rust-lang#87437
- Loading branch information
Showing
7 changed files
with
121 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
src/test/ui/traits/suggest-deferences/root-obligation.fixed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// run-rustfix | ||
|
||
fn get_vowel_count(string: &str) -> usize { | ||
string | ||
.chars() | ||
.filter(|c| "aeiou".contains(*c)) | ||
//~^ ERROR expected a `Fn<(char,)>` closure, found `char` | ||
.count() | ||
} | ||
|
||
fn main() { | ||
let _ = get_vowel_count("asdf"); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// run-rustfix | ||
|
||
fn get_vowel_count(string: &str) -> usize { | ||
string | ||
.chars() | ||
.filter(|c| "aeiou".contains(c)) | ||
//~^ ERROR expected a `Fn<(char,)>` closure, found `char` | ||
.count() | ||
} | ||
|
||
fn main() { | ||
let _ = get_vowel_count("asdf"); | ||
} | ||
|
24 changes: 24 additions & 0 deletions
24
src/test/ui/traits/suggest-deferences/root-obligation.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
error[E0277]: expected a `Fn<(char,)>` closure, found `char` | ||
--> $DIR/root-obligation.rs:6:38 | ||
| | ||
LL | .filter(|c| "aeiou".contains(c)) | ||
| -------- ^ expected an `Fn<(char,)>` closure, found `char` | ||
| | | ||
| required by a bound introduced by this call | ||
| | ||
= help: the trait `Fn<(char,)>` is not implemented for `char` | ||
= note: required because of the requirements on the impl of `FnOnce<(char,)>` for `&char` | ||
= note: required because of the requirements on the impl of `Pattern<'_>` for `&char` | ||
note: required by a bound in `core::str::<impl str>::contains` | ||
--> $SRC_DIR/core/src/str/mod.rs:LL:COL | ||
| | ||
LL | pub fn contains<'a, P: Pattern<'a>>(&'a self, pat: P) -> bool { | ||
| ^^^^^^^^^^^ required by this bound in `core::str::<impl str>::contains` | ||
help: consider dereferencing here | ||
| | ||
LL | .filter(|c| "aeiou".contains(*c)) | ||
| + | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0277`. |