Skip to content

overloaded_calls on boxed Fn<A, R> #18349

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

Closed
mystor opened this issue Oct 26, 2014 · 1 comment
Closed

overloaded_calls on boxed Fn<A, R> #18349

mystor opened this issue Oct 26, 2014 · 1 comment

Comments

@mystor
Copy link
Contributor

mystor commented Oct 26, 2014

It appears as though overloaded_calls doesn't work when the struct which implements Fn<A, R> is boxed.

#![feature(overloaded_calls)]

fn mk_adder(i: int) -> Box<Fn<(int,), int> + 'static> {
    struct Closure(int);
    impl Fn<(int,), int> for Closure {
        extern "rust-call" fn call(&self, args: (int,)) -> int {
            let (j,) = args;
            let &Closure(i) = self;
            i + j
        }
    }

    Closure(i)(3); // Works

    box Closure(i)
}

fn main() {
    let adder = mk_adder(5);
    (*adder)(3); // Fail
}

Example run:

$ rustc main.rs
main.rs:20:5: 20:16 error: expected function, found `core::ops::Fn<(int),int>`
main.rs:20     (*adder)(3); // Fail
               ^~~~~~~~~~~
error: aborting due to previous error

$ rustc --version=verbose
rustc 0.13.0-nightly (f168c12c5 2014-10-25 20:57:10 +0000)
binary: rustc
commit-hash: f168c12c5629afd45c9b3ed250350bf830b99642
commit-date: 2014-10-25 20:57:10 +0000
host: x86_64-apple-darwin
release: 0.13.0-nightly
@steveklabnik
Copy link
Member

This now compiles without error, once you update it to current rust.

lnicola pushed a commit to lnicola/rust that referenced this issue Oct 29, 2024
feat: render docs from aliased type when type has no docs

Trying to close rust-lang#18344

- [x] ~Find the docs by traversing upwards if the type itself has none but aliasing for another type that might have.~
- [x] Show docs from aliased type.
- [x] Showing description that we are displaying documentation for different definition in hover box.

![image](https://github.com/user-attachments/assets/820d6f97-aa2c-4dc4-8a25-75746e32d950)
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