Closed
Description
Given the following code:
fn takes_callback(callback: impl Fn(i32)) {
callback(&0);
}
The current output is dependent on whether you have the rust-src
component installed. With it installed:
error[E0308]: mismatched types
--> src/main.rs:2:14
|
2 | callback(&0);
| -------- ^^ expected `i32`, found `&{integer}`
| |
| arguments to this function are incorrect
|
note: associated function defined here
--> /home/jnelson/.local/lib/rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:77:27
|
77 | extern "rust-call" fn call(&self, args: Args)...
| ^^^^
help: consider removing the borrow
|
2 - callback(&0);
2 + callback(0);
without it (e.g. on playground), the same except the note looks very strange because it doesn't actually point anywhere:
note: associated function defined here
help: consider removing the borrow
Ideally the output should look like:
error[E0308]: mismatched types
--> src/main.rs:2:14
|
2 | callback(&0);
| -------- ^^ expected `i32`, found `&{integer}`
| |
| arguments to this function are incorrect
|
note: function defined here:
--> src/main.rs:1:x
|
1 | fn takes_callback(callback: impl Fn(i32)) {
| ^^^^^^^^^^^^
help: consider removing the borrow
|
2 - callback(&0);
2 + callback(0);