Skip to content

"the trait Clone is not implemented for the type fn(&mut Foo, …) #24000

Closed
@SimonSapin

Description

@SimonSapin

Upgrading rust-encoding to Rust beta, I hit this error message:

/// A type of the bare function in `DecoderTrap` values.
#[unstable]
pub type DecoderTrapFunc =
    extern "Rust" fn(decoder: &mut RawDecoder, input: &[u8], output: &mut StringWriter) -> bool;

/// Trap, which handles decoder errors.
#[stable]
#[derive(Copy, Clone)]
pub enum DecoderTrap {
    /// Immediately fails on errors.
    /// Corresponds to WHATWG "fatal" error algorithm.
    Strict,
    /// Replaces an error with a U+FFFD (decoder).
    /// Corresponds to WHATWG "replacement" error algorithm.
    Replace,
    /// Silently ignores an error, effectively replacing it with an empty sequence.
    Ignore,
    /// Calls given function to handle decoder errors.
    /// The function is given the current decoder, input and output writer,
    /// and should return true only when it is fine to keep going.
    #[unstable] Call(DecoderTrapFunc),
}
src/types.rs:380:22: 380:37 error: the trait `core::clone::Clone` is not implemented for the type `fn(&'a mut types::RawDecoder, &'b [u8], &'c mut types::StringWriter + 'c) -> bool` [E0277]
src/types.rs:380     #[unstable] Call(DecoderTrapFunc),
                                      ^~~~~~~~~~~~~~~
src/types.rs:367:16: 367:21 note: in expansion of #[derive_Clone]
src/types.rs:367:16: 367:21 note: expansion site

Shouldn’t this fn type implement Clone? It seems to implement Copy.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-type-systemArea: Type systemC-bugCategory: This is a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions