Skip to content

Regression: cannot convert to a trait object because trait core::ops::FnOnce is not object-safe #19878

@tomaka

Description

@tomaka

The following code used to work:

#![feature(unboxed_closures)]

fn convert<F: FnOnce() + Send>(f: F) -> Box<FnOnce() + Send> {
    box f
}

But now it fails to compile with 126db549b 2014-12-15 00:07:35 +0000:

D:\Projets\test\src\lib.rs:4:5: 4:10 error: cannot convert to a trait object because trait `core::ops::FnOnce` is not object-safe [E0038]
D:\Projets\test\src\lib.rs:4     box f
                                 ^~~~~
note: cannot call a method (`call_once`) with a by-value receiver through a trait object

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions