diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-12-16 13:08:09 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-16 13:08:09 +0000 |
commit | de1ed2e805cc7de7ab29b5e183354bae86173669 (patch) | |
tree | df2bc819e07affe08e13d8f09f8448c00ae4722a /gcc/rust/hir/rust-ast-lower-pattern.h | |
parent | 8507a68883438060b3b8e828069ffe20a084b85a (diff) | |
parent | 4d70990b838e3fbeedaf0918c2c87f46cdf0d689 (diff) | |
download | gcc-de1ed2e805cc7de7ab29b5e183354bae86173669.zip gcc-de1ed2e805cc7de7ab29b5e183354bae86173669.tar.gz gcc-de1ed2e805cc7de7ab29b5e183354bae86173669.tar.bz2 |
Merge #838
838: Add mssing mappings to HIR::Pattern r=philberty a=philberty
These mappings are missing within the HIR but are required
to complete typechecking of all patterns in match arms. As the
fields of structures must bind their associated field's types to new
names declared as part of the pattern, these mappings give access
to the associated name-resolved NodeId's to figure this out.
Co-authored-by: Philip Herron <philip.herron@embecosm.com>
Diffstat (limited to 'gcc/rust/hir/rust-ast-lower-pattern.h')
-rw-r--r-- | gcc/rust/hir/rust-ast-lower-pattern.h | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/gcc/rust/hir/rust-ast-lower-pattern.h b/gcc/rust/hir/rust-ast-lower-pattern.h index d8c03ce..bd25b83 100644 --- a/gcc/rust/hir/rust-ast-lower-pattern.h +++ b/gcc/rust/hir/rust-ast-lower-pattern.h @@ -33,16 +33,32 @@ public: { ASTLoweringPattern resolver; pattern->accept_vis (resolver); + rust_assert (resolver.translated != nullptr); + + resolver.mappings->insert_hir_pattern ( + resolver.translated->get_pattern_mappings ().get_crate_num (), + resolver.translated->get_pattern_mappings ().get_hirid (), + resolver.translated); + resolver.mappings->insert_location ( + resolver.translated->get_pattern_mappings ().get_crate_num (), + resolver.translated->get_pattern_mappings ().get_hirid (), + pattern->get_locus ()); + return resolver.translated; } void visit (AST::IdentifierPattern &pattern) override { + auto crate_num = mappings->get_current_crate (); + Analysis::NodeMapping mapping (crate_num, pattern.get_node_id (), + mappings->get_next_hir_id (crate_num), + UNKNOWN_LOCAL_DEFID); + std::unique_ptr<Pattern> to_bind; translated - = new HIR::IdentifierPattern (pattern.get_ident (), pattern.get_locus (), - pattern.get_is_ref (), + = new HIR::IdentifierPattern (mapping, pattern.get_ident (), + pattern.get_locus (), pattern.get_is_ref (), pattern.get_is_mut () ? Mutability::Mut : Mutability::Imm, std::move (to_bind)); |