Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overloaded call notation doesn't work with trait bounds #18385

Closed
nikomatsakis opened this issue Oct 28, 2014 · 2 comments
Closed

Overloaded call notation doesn't work with trait bounds #18385

nikomatsakis opened this issue Oct 28, 2014 · 2 comments

Comments

@nikomatsakis
Copy link
Contributor

I expect this example to compile:

lunch-box. emacs -nw
#![feature(overloaded_calls)]

use std::ops::FnMut;

fn call_it_mut<F:FnMut(int)->int>(f: &mut F, x: int) -> int {
    f(x)
}

fn main() { }

but in fact it yields:

/home/nmatsakis/tmp/foo.rs:6:5: 6:17 error: the trait `core::ops::Fn<<generic #9>,<generic #10>>` is
 not implemented for the type `&&mut F`
/home/nmatsakis/tmp/foo.rs:6     (&mut *f)(x)
                                 ^~~~~~~~~~~~
/home/nmatsakis/tmp/foo.rs:6:5: 6:17 error: the type of this value must be known in this context
/home/nmatsakis/tmp/foo.rs:6     (&mut *f)(x)
                                 ^~~~~~~~~~~~
/home/nmatsakis/tmp/foo.rs:6:5: 6:17 error: cannot use call notation; the first type parameter for t
he function trait is neither a tuple nor unit [E0059]
/home/nmatsakis/tmp/foo.rs:6     (&mut *f)(x)
                                 ^~~~~~~~~~~~
error: aborting due to 3 previous errors

I was not able to get it to compile without resorting to f.call_mut((x,))

@aturon aturon mentioned this issue Oct 28, 2014
47 tasks
@japaric
Copy link
Member

japaric commented Nov 19, 2014

This is compiling now, but f(x) must be changed to (*f)(x). But that's #18742 I think.

@alexcrichton
Copy link
Member

Closing in favor of #18742

lnicola pushed a commit to lnicola/rust that referenced this issue Nov 4, 2024
feat: Add assist to generate a type alias for a function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants