From: Muhammad Mahad Date: Thu, 6 Jul 2023 13:26:26 +0000 (+0500) Subject: gccrs: [E0063] constructor is missing fields X-Git-Tag: basepoints/gcc-15~2401 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=efa319175a0d5a2aa2d859d8305be3bf881ad006;p=thirdparty%2Fgcc.git gccrs: [E0063] constructor is missing fields Added error code for Missing Field in struct or struct-like enum variant. gcc/rust/ChangeLog: * typecheck/rust-hir-type-check-struct.cc (TypeCheckStructExpr::resolve): called error function. gcc/testsuite/ChangeLog: * rust/compile/missing_constructor_fields.rs: New test. Signed-off-by: Muhammad Mahad --- diff --git a/gcc/rust/typecheck/rust-hir-type-check-struct.cc b/gcc/rust/typecheck/rust-hir-type-check-struct.cc index 08d4c2efdee2..08488093fdd2 100644 --- a/gcc/rust/typecheck/rust-hir-type-check-struct.cc +++ b/gcc/rust/typecheck/rust-hir-type-check-struct.cc @@ -149,7 +149,7 @@ TypeCheckStructExpr::resolve (HIR::StructExprStructFields &struct_expr) } else if (!struct_expr.has_struct_base ()) { - rust_error_at (struct_expr.get_locus (), + rust_error_at (struct_expr.get_locus (), ErrorCode ("E0063"), "constructor is missing fields"); return; } diff --git a/gcc/testsuite/rust/compile/missing_constructor_fields.rs b/gcc/testsuite/rust/compile/missing_constructor_fields.rs new file mode 100644 index 000000000000..9d492101fbd5 --- /dev/null +++ b/gcc/testsuite/rust/compile/missing_constructor_fields.rs @@ -0,0 +1,10 @@ +// https://doc.rust-lang.org/error_codes/E0063.html +struct Foo { + x: i32, + y: i32, + z: i32, +} + +fn main() { + let x = Foo { x: 0 , y:1 }; // { dg-error "constructor is missing fields" } +} \ No newline at end of file