Skip to content

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

Closed
@nikomatsakis

Description

@nikomatsakis

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,))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions