]> git.ipfire.org Git - people/ms/gcc.git/commitdiff
hir: Fix ReferencePattern typechecking
authorMahmoud Mohamed <mahadelr19@gmail.com>
Sun, 12 Mar 2023 23:26:13 +0000 (02:26 +0300)
committerPhilip Herron <philip.herron@embecosm.com>
Mon, 13 Mar 2023 18:09:26 +0000 (18:09 +0000)
The visit for TypeCheckPattern::visit (HIR::ReferencePattern) was missing
an assignment to infered

gcc/rust/ChangeLog:

* typecheck/rust-hir-type-check-pattern.cc (TypeCheckPattern::visit):
Add the missing infered type assignment

Signed-off-by: Mahmoud Mohamed <mahadelr19@gmail.com>
gcc/rust/typecheck/rust-hir-type-check-pattern.cc

index cd0dbef40fe2c786817a0fa45dbbd645254f23c1..228d2dd2443a9210da7c4c362652eb7816c433be 100644 (file)
@@ -355,8 +355,14 @@ TypeCheckPattern::visit (HIR::ReferencePattern &pattern)
                   parent->as_string ().c_str ());
 
   TyTy::ReferenceType *ref_ty_ty = static_cast<TyTy::ReferenceType *> (parent);
-  TypeCheckPattern::Resolve (pattern.get_referenced_pattern ().get (),
-                            ref_ty_ty->get_base ());
+  TyTy::BaseType *infered_base
+    = TypeCheckPattern::Resolve (pattern.get_referenced_pattern ().get (),
+                                ref_ty_ty->get_base ());
+  infered
+    = new TyTy::ReferenceType (pattern.get_pattern_mappings ().get_hirid (),
+                              TyTy::TyVar (infered_base->get_ref ()),
+                              pattern.is_mut () ? Mutability::Mut
+                                                : Mutability::Imm);
 }
 
 void