Skip to content

Better error message when struct construction field name is left "implicit"  #4909

Closed
@jdm

Description

@jdm

(Updated with concrete example:)

struct Foo {
    A: int,
    B: int
}

fn main() {
    let B = 3i;
    let x = Foo{A:1,B};
}

yields (live playpen: http://is.gd/GDjwLK)

<anon>:8:22: 8:23 error: expected `:` but found `}`
<anon>:8     let x = Foo{A:1,B};
                              ^

This feels like something we should be able to better report (possibly as a note suggestion).

Original bug report follows:

/run/media/jdm/ssd/servo/src/servo/dom/bindings/ClientRectBinding.rs:254:61: 254:62 error: expected `;` but found `{`
/run/media/jdm/ssd/servo/src/servo/dom/bindings/ClientRectBinding.rs:254 const NativeHooks: NativePropertyHooks = 
                 NativePropertyHooks { 0 as *u8, ResolveProperty, 0 as *u8, EnumerateProperties, 0 as *NativePropertyHooks };

This feels like something we should be able to better report (possibly as a note suggestion).

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-frontendArea: Compiler frontend (errors, parsing and HIR)P-lowLow priority

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions