Skip to content

Commit

Permalink
gccrs: [E0063] constructor is missing fields
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
MahadMuhammad committed Jul 6, 2023
1 parent 5d33b88 commit 5437803
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion gcc/rust/typecheck/rust-hir-type-check-struct.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
10 changes: 10 additions & 0 deletions gcc/testsuite/rust/compile/missing_constructor_fields.rs
Original file line number Diff line number Diff line change
@@ -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" }
}

0 comments on commit 5437803

Please sign in to comment.