You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Point at problematic argument on mismatched Fn argument count #48099
(After #48047's ICE fix) When a function or closure from another crate is passed as an argument and it doesn't match the expected argument count, the error points only at the method that expected the closure:
error[E0593]: function is expected to take 1 argument, but it takes 2 arguments
--> $DIR/closure-arg-count.rs:40:41
|
40 | let _it = vec![1, 2, 3].into_iter().map(usize::checked_add);
| ^^^ expected function that takes 1 argument
In the case where the function or closure is local, the span for it is highlighted:
error[E0593]: function is expected to take a single 2-tuple as argument, but it takes 0 arguments
--> $DIR/closure-arg-count.rs:32:53
|
32 | let _it = vec![1, 2, 3].into_iter().enumerate().map(foo);
| ^^^ expected function that takes a single 2-tuple as argument
...
44 | fn foo() {}
| -------- takes 0 arguments
It would be good for consistency to point at the external's function/closure span use location, as well as printing out the signature of the method:
error[E0593]: function is expected to take 1 argument, but it takes 2 arguments
--> $DIR/closure-arg-count.rs:40:41
|
40 | let _it = vec![1, 2, 3].into_iter().map(usize::checked_add);
| ^^^ ------------------ takes 2 arguments: `fn(self, _: u32) -> Option<u32>`
| |
| expected function that takes 1 argument
Activity
Rollup merge of rust-lang#64498 - estebank:point-at-arg, r=Centril
Auto merge of #64498 - estebank:point-at-arg, r=Centril