Closed
Description
fn foo<F>(f: F) where F: FnMut(usize) {}
fn main() {
foo(|s| s.is_empty())
}
$ rustc foo.rs
foo.rs:4:15: 4:25 error: type `usize` does not implement any method in scope named `is_empty`
foo.rs:4 foo(|s| s.is_empty())
^~~~~~~~~~
foo.rs:4:25: 4:25 help: methods from traits can only be called if the trait is implemented and in scope; no such traits are but the following traits define a method `is_empty`:
foo.rs:4:25: 4:25 help: candidate #1: `core::slice::SliceExt`
foo.rs:4:25: 4:25 help: candidate #2: `core::slice::SliceExt`
foo.rs:4:25: 4:25 help: candidate #3: `core::str::StrExt`
foo.rs:4:25: 4:25 help: candidate #4: `core::str::StrExt`
foo.rs:4:25: 4:25 help: candidate #5: `collections::slice::SliceExt`
foo.rs:4:25: 4:25 help: candidate #6: `collections::slice::SliceExt`
foo.rs:4:25: 4:25 help: candidate #7: `collections::slice::SliceExt`
foo.rs:4:25: 4:25 help: candidate #8: `collections::str::StrExt`
foo.rs:4:25: 4:25 help: candidate #9: `collections::str::StrExt`
foo.rs:4:25: 4:25 help: candidate #10: `collections::str::StrExt`
error: aborting due to previous error
cc @huonw
Perhaps each trait could be suggested at most once? We may also want to work out the core/collections/std split as the only traits listed should probably be std::str::StrExt
and std::slice::SliceExt
, but that's also a separate bug.