aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/hir/rust-hir-dump.h
diff options
context:
space:
mode:
authorMahmoud Mohamed <mahadelr19@gmail.com>2023-03-16 02:54:11 +0300
committerArthur Cohen <arthur.cohen@embecosm.com>2024-01-16 18:21:12 +0100
commit3b61fe1d507bc8a2197b2ea0e87ccda943ed4aa2 (patch)
tree8c8ee3519f8aa3750842bd08ce020a3414c0c01a /gcc/rust/hir/rust-hir-dump.h
parent4622e12040e585cf48f4a2d04e820b8d3506c983 (diff)
downloadgcc-3b61fe1d507bc8a2197b2ea0e87ccda943ed4aa2.zip
gcc-3b61fe1d507bc8a2197b2ea0e87ccda943ed4aa2.tar.gz
gcc-3b61fe1d507bc8a2197b2ea0e87ccda943ed4aa2.tar.bz2
gccrs: resolve: Add name resolution for AltPattern
The main changes in this commit can be logically split into two parts: 1) Pushing new pattern binding contexts in alt patterns. At the start of each AltPattern we push an 'Or' context which represents the relation between the bindings of different alts. Before we resolve each alt arm we need to push a 'Product' context to represent the relation between the bindings of this specific alt arm and each other. This 'Product' context is removed after the alt arm visit and the its bindings are pushed into the 'Or' context. Eventually, the 'Or' context is removed as well after it fulfills its duty. Its bindings are then pushed into the previous context similarly and so on. 2) Checking for consistent bindings between the alt arms which is handled by check_bindings_consistency. The info necessary for this check is held by binding_info_map inside PatternDeclaration class. The binding_info_map only holds bindings for one alt arm at a time. After every alt arm visit, these bindings info are pushed into a vec (that contains all alt arms info and will eventually be passed to check_bindings_consistency) and emptied out for the next alt arm visit. At the end, all the info from all the alt arms are pushed again into binding_info in addition to the initial bindings that were there before the alt arms visits, this way the binding_info will contain all the binding_info present in the AltPattern (as it should). In addition to that, some refactors were made (e.g. add_new_binding function) and some errors emitted, no biggie. gcc/rust/ChangeLog: * resolve/rust-ast-resolve-pattern.cc (PatternDeclaration::go): Print out consistency errors. (PatternDeclaration::visit): Implement visit for AltPattern. (PatternDeclaration::add_new_binding): New helper function for adding a binding to identifier. * resolve/rust-ast-resolve-pattern.h (struct BindingInfo): New struct to facilitate checking for inconsistencies between bindings. gcc/testsuite/ChangeLog: * rust/compile/torture/alt_patterns1.rs: New test. Signed-off-by: Mahmoud Mohamed <mahadelr19@gmail.com>
Diffstat (limited to 'gcc/rust/hir/rust-hir-dump.h')
0 files changed, 0 insertions, 0 deletions