Open
Description
Given the following code: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=d6dfe3d605639255444883813f8376db
enum CargoMessage {
CompilerArtifact {
filenames: Vec<String>,
target: CargoTarget,
extra: bool,
}
}
struct CargoTarget {
crate_types: Vec<String>,
}
pub fn run_cargo() {
let is_debug_info = |_| true;
let is_dylib = |_| true;
let is_check = true;
let ok = stream_cargo(vec![], &mut |msg| {
let (filenames, crate_types) = match msg {
CargoMessage::CompilerArtifact {
filenames,
target: CargoTarget { crate_types },
..
} => (filenames, crate_types),
_ => return,
};
for filename in filenames {
// Skip files like executables
if !(filename.ends_with(".rlib")
|| filename.ends_with(".lib")
|| filename.ends_with(".a")
|| is_debug_info(&filename)
|| is_dylib(&filename)
|| (is_check && filename.ends_with(".rmeta")))
{
continue;
}
}
});
}
pub fn stream_cargo(
cb: &mut dyn FnMut(CargoMessage),
) -> bool {
true
}
The current output is:
error[[E0061]](https://doc.rust-lang.org/stable/error-index.html#E0061): this function takes 1 argument but 2 arguments were supplied
--> src/lib.rs:17:14
|
17 | let ok = stream_cargo(vec![], &mut |msg| {
| ^^^^^^^^^^^^ ------ argument of type `Vec<_>` unexpected
|
note: function defined here
--> src/lib.rs:41:8
|
41 | pub fn stream_cargo(
| ^^^^^^^^^^^^
42 | cb: &mut dyn FnMut(CargoMessage),
| --------------------------------
help: remove the extra argument
|
17 ~ let ok = stream_cargo(&mut |msg| {
18 + let (filenames, crate_types) = match msg {
19 + CargoMessage::CompilerArtifact {
20 + filenames,
21 + target: CargoTarget { crate_types },
22 + ..
23 + } => (filenames, crate_types),
24 + _ => return,
25 + };
26 + for filename in filenames {
27 + // Skip files like executables
28 + if !(filename.ends_with(".rlib")
29 + || filename.ends_with(".lib")
30 + || filename.ends_with(".a")
31 + || is_debug_info(&filename)
32 + || is_dylib(&filename)
33 + || (is_check && filename.ends_with(".rmeta")))
34 + {
35 + continue;
36 + }
37 + }
38 ~ });
|
For more information about this error, try `rustc --explain E0061`.
Ideally the output should look like:
error[E0061]: this function takes 1 argument but 2 arguments were supplied
--> src/lib.rs:17:14
|
17 | let ok = stream_cargo(vec![], &mut |msg| {
| ^^^^^^^^^^^^ ------ argument of type `Vec<_>` unexpected
|
note: function defined here
--> src/lib.rs:41:8
|
41 | pub fn stream_cargo(
| ^^^^^^^^^^^^
42 | cb: &mut dyn FnMut(CargoMessage),
| --------------------------------
help: remove the extra argument
|
17 ~ let ok = stream_cargo(&mut |msg| {
Printing the entire body of the closure is ... a bit much 😆