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 calls must now be written as (*self)() instead of self() #18742

Closed
japaric opened this issue Nov 7, 2014 · 1 comment
Closed

Overloaded calls must now be written as (*self)() instead of self() #18742

japaric opened this issue Nov 7, 2014 · 1 comment

Comments

@japaric
Copy link
Member

japaric commented Nov 7, 2014

STR

#![feature(overloaded_calls)]

struct Foo;

impl Fn<(), ()> for Foo {
    extern "rust-call" fn call(&self, args: ()) {
        unimplemented!();
    }
}

impl Foo {
    fn foo(self) {
        self();
        self.call(());
    }

    fn bar(&self) {
        (*self)();  // OK
        self();  //~ error: expected function, found `&Foo`
        self.call(());  // OK
    }

    fn baz(&mut self) {
        (*self)();  // OK
        self();  //~ error: expected function, found `&mut Foo`
        self.call(());  // OK
    }
}

fn main() {}

Version

rustc 0.13.0-dev (97a57ec90 2014-11-07 11:31:25 +0000)

I think all these cases should work since self() should be sugar for self.call(()) and that method call works on the three cases.

Also, it seems the situation has regressed recently, because on the playpen bar is also working. The playpen is using this older version of the compiler:

rustc 0.13.0-dev (5c1fd5f8b 2014-11-05 18:01:53 +0000)

This is probably related to #18349

cc @nikomatsakis

japaric pushed a commit to japaric-archived/stats.rs that referenced this issue Nov 7, 2014
@nikomatsakis
Copy link
Contributor

Right. I guess we have to decide whether overloaded calls auto-deref. Presumably they should.

nikomatsakis added a commit to nikomatsakis/rust that referenced this issue Jan 3, 2015
nikomatsakis added a commit to nikomatsakis/rust that referenced this issue Jan 3, 2015
GauravBholaris pushed a commit to GauravBholaris/criterion.rs that referenced this issue Jul 20, 2022
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

2 participants