Skip to content

Unboxed closures with all Clone members should implement Clone #23501

Closed
@seanmonstar

Description

@seanmonstar

Similar to #19128

#![feature(core, unboxed_closures)]
use std::ops::Fn;

#[derive(Clone)]
struct NotCopy;

#[derive(Clone)]
struct Derp {
    foo: NotCopy
}

impl Fn<()> for Derp {
    type Output = ();
    extern "rust-call" fn call(&self, _: ()) {
    }
}

fn with_clone<F>(_f: F) where F: Fn() + Clone {

}

fn main() {
    let foo = NotCopy;
    with_clone(Derp { foo: NotCopy }); // works
    with_clone(move || { // errors
        let _ = foo; // <- should be like Derp, accessing self.foo
    });
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-closuresArea: Closures (`|…| { … }`)C-feature-requestCategory: A feature request, i.e: not implemented / a PR.P-lowLow priorityT-langRelevant to the language team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions