Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[E0063] constructor is missing fields #2387

Merged
merged 1 commit into from
Jul 6, 2023

Conversation

MahadMuhammad
Copy link
Contributor

Constructor is missing fields - E0063

Added error code for Missing Field in
struct or struct-like enum variant.


Tested Code From E0063

// 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" }
}

Output:

➜  gccrs-build gcc/crab1 /home/mahad/Desktop/mahad/gccrs/gcc/testsuite/rust/compile/missing_constructor_fields.rs
/home/mahad/Desktop/mahad/gccrs/gcc/testsuite/rust/compile/missing_constructor_fields.rs:9:13: error: constructor is missing fields [E0063]
    9 |     let x = Foo { x: 0 , y:1 }; // { dg-error "constructor is missing fields" }
      |             ^~~

Analyzing compilation unit

Time variable                                   usr           sys          wall           GGC
 TOTAL                              :   0.00          0.00          0.00          146k
Extra diagnostic checks enabled; compiler may run slowly.
Configure with --enable-checking=release to disable checks.

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.

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>
@@ -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");
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

@philberty philberty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@philberty philberty added this pull request to the merge queue Jul 6, 2023
Merged via the queue into Rust-GCC:master with commit 0aa7ed7 Jul 6, 2023
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants