diff options
author | Muhammad Mahad <mahadtxt@gmail.com> | 2023-07-06 18:26:26 +0500 |
---|---|---|
committer | Philip Herron <philip.herron@embecosm.com> | 2023-07-06 16:12:24 +0000 |
commit | 0aa7ed791bfb7123190ca21bfc4006599faa6ae1 (patch) | |
tree | 59643e1b7391aedbc43e760511ce041bd449f445 | |
parent | 46a61f02f12d697c6f25eb03371bbb22a5b8504a (diff) | |
download | gcc-0aa7ed791bfb7123190ca21bfc4006599faa6ae1.zip gcc-0aa7ed791bfb7123190ca21bfc4006599faa6ae1.tar.gz gcc-0aa7ed791bfb7123190ca21bfc4006599faa6ae1.tar.bz2 |
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 <mahadtxt@gmail.com>
-rw-r--r-- | gcc/rust/typecheck/rust-hir-type-check-struct.cc | 2 | ||||
-rw-r--r-- | gcc/testsuite/rust/compile/missing_constructor_fields.rs | 10 |
2 files changed, 11 insertions, 1 deletions
diff --git a/gcc/rust/typecheck/rust-hir-type-check-struct.cc b/gcc/rust/typecheck/rust-hir-type-check-struct.cc index ce11e72..d911cf7 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 0000000..9d49210 --- /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 |