-
Notifications
You must be signed in to change notification settings - Fork 187
Closed
Labels
Description
Refactoring Field Error Function
Both the lines you modified have the exact same error message and pattern. I think it would be worth opening an issue to factor them into one function (
emit_invalid_field_error
or w/ever) in this file, and it's something you can work on if you like. This will make it easier for you to rework the Error emitting code once we get to that point in your GSoC project @MahadMuhammad
Originally posted by @CohenArthur in #2326 (comment)
gccrs/gcc/rust/typecheck/rust-hir-type-check-pattern.cc
Lines 204 to 212 in 5711a2a
if (!variant->lookup_field (ident.get_identifier (), &field, | |
nullptr)) | |
{ | |
rust_error_at (ident.get_locus (), ErrorCode ("E0026"), | |
"variant %s does not have a field named %s", | |
variant->get_identifier ().c_str (), | |
ident.get_identifier ().c_str ()); | |
break; | |
} |
gccrs/gcc/rust/typecheck/rust-hir-type-check-pattern.cc
Lines 225 to 233 in 5711a2a
if (!variant->lookup_field (ident.get_identifier (), &field, | |
nullptr)) | |
{ | |
rust_error_at (ident.get_locus (), ErrorCode ("E0026"), | |
"variant %s does not have a field named %s", | |
variant->get_identifier ().c_str (), | |
ident.get_identifier ().c_str ()); | |
break; | |
} |
- Both of these functions has the same error message and pattern. Merging them into function, makes easier for working in error emittion part.
- [E0026] Non-Existent Field Extraction in Struct Pattern #2326 (review)