-
-
Notifications
You must be signed in to change notification settings - Fork 14.6k
Closed
Labels
A-frontendArea: Compiler frontend (errors, parsing and HIR)Area: Compiler frontend (errors, parsing and HIR)
Description
Updated bug report
Compiling this (erroneous) program:
struct mutex;
fn main() {
let x = mutex { }; // this should be `let x = mutex;`
println(fmt!("%?", x));
}
yields:
/tmp/foo.rs:3:18: 3:19 error: expected `;` but found `{`
/tmp/foo.rs:3 let x = mutex { };
We currently emit a nice error message if you incorrectly write the struct mutex definition as:
struct mutex { }
that tells you that you need to write the Unit-like struct as struct mutex;; we should do the same for the struct initialization expression.
Original bug report
struct mutex { }
fn main() {
let x = mutex { };
}
gives:
struct.rs:3:18: 3:19 error: expected `;` but found `{`
struct.rs:3 let x = mutex { };
but if you comment out the let x line, it gives:
struct.rs:1:0: 1:16 error: a class must have at least one field
struct.rs:1 struct mutex { }
Personally, I think we should be allowed to have empty structs, but either way, the latter error message should have higher priority(?) than the former.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
A-frontendArea: Compiler frontend (errors, parsing and HIR)Area: Compiler frontend (errors, parsing and HIR)