Skip to content

deriving error should point to field which caused the error #7724

Closed
@metajack

Description

@metajack

Compiling the following:

struct Foo {
    foo: bool,
}

#[deriving(Clone)]
struct Bar {
    foo: Foo,
}

fn main() {
    let a = Bar { foo: Foo { foo: true }};
    a.clone();
}

produces

clonespan.rs:5:11: 5:16 error: mismatched types: expected `Foo` but found `&Foo` (expected struct Foo but found &-ptr)
clonespan.rs:5 #[deriving(Clone)]
                          ^~~~~

The real error is that Foo doesn't implement Clone. The span should also probably point to Foo in the definition for Bar instead of to the deriving line.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-syntaxextArea: Syntax extensions

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions