-
Notifications
You must be signed in to change notification settings - Fork 162
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add improved error when no fields in initializer
If a struct type with a variant that has fields is initialized with some fields the expression HIR StructExprStructFields is checked that all the fields are assigned. However, if no fields are initialized the HIR StructExprStruct is generated. This doesn't check if the struct is a unit during typechekc and only fails at the compile stage with a ICE. Add a check at the typecheck stage that makes sure the struct does not have a variant with fields and give an error message based on the rustc one. We have also updated the message given in the case where one field was present to list the missing fields and match more closely the new message. gcc/rust/ChangeLog: * typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit) Add additional check * typecheck/rust-hir-type-check-struct-field.h: A helper method to make error added * typecheck/rust-hir-type-check-struct.cc (TypeCheckStructExpr::resolve) Update message gcc/testsuite/ChangeLog: * rust/compile/missing_constructor_fields.rs: Added case with no initializers Signed-off-by: Robert Goss <[email protected]>
- Loading branch information
1 parent
1586de8
commit 7b203f6
Showing
4 changed files
with
76 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters