Skip to content

Cannot generically implement Function traits #17779

@Ericson2314

Description

@Ericson2314
Contributor

My code:

pub struct LockedClosure<F>  {
    closure: Mutex<F>
}

impl<F, Args, Result> Fn<Args, Result> for LockedClosure<F>
    where F: FnMut<Args, Result>, F:Send
{
    #[rust_call_abi_hack]
    fn call(&self, args: Args) -> Result {
        self.closure.lock().deref_mut().call_mut(args)
    }
}

I get an ICE 'argument to function with "rust-call" ABI is neither a tuple nor unit', which is perfectly reasonable. This seems like a useful thing to do however, and due to the where clause, args will in fact be a tuple or unit.

Activity

Ericson2314

Ericson2314 commented on Oct 4, 2014

@Ericson2314
ContributorAuthor

Hmm, so another unboxed-closure thing might of triggered the ICE, closing until I can reconfirm issue.

added a commit that references this issue on Sep 25, 2024
28142e4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-type-systemArea: Type systemI-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @kmcallister@Ericson2314

        Issue actions

          Cannot generically implement Function traits · Issue #17779 · rust-lang/rust