From: Faisal Abbas <90.abbasfaisal@gmail.com> Date: Sun, 4 Sep 2022 15:07:43 +0000 (+0100) Subject: gccrs: bugfix: initialize slice from array in const context X-Git-Tag: upstream/13.1.0~1690 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=689a5c6711b8217158988763ba25959f8112dcfc;p=platform%2Fupstream%2Fgcc.git gccrs: bugfix: initialize slice from array in const context gcc/rust/ChangeLog: * typecheck/rust-hir-type-check-stmt.cc (TypeCheckStmt::visit): Turn constant item typechecking into a coercion site instead of a unify site. gcc/testsuite/ChangeLog: * rust/compile/const6.rs: New test. Signed-off-by: Faisal Abbas <90.abbasfaisal@gmail.com> --- diff --git a/gcc/rust/typecheck/rust-hir-type-check-stmt.cc b/gcc/rust/typecheck/rust-hir-type-check-stmt.cc index e82dd8e..a55cf22 100644 --- a/gcc/rust/typecheck/rust-hir-type-check-stmt.cc +++ b/gcc/rust/typecheck/rust-hir-type-check-stmt.cc @@ -68,7 +68,7 @@ TypeCheckStmt::visit (HIR::ConstantItem &constant) TyTy::BaseType *type = TypeCheckType::Resolve (constant.get_type ()); TyTy::BaseType *expr_type = TypeCheckExpr::Resolve (constant.get_expr ()); - infered = unify_site ( + infered = coercion_site ( constant.get_mappings ().get_hirid (), TyTy::TyWithLocation (type, constant.get_type ()->get_locus ()), TyTy::TyWithLocation (expr_type, constant.get_expr ()->get_locus ()), diff --git a/gcc/testsuite/rust/compile/const6.rs b/gcc/testsuite/rust/compile/const6.rs new file mode 100644 index 0000000..8f0dc32 --- /dev/null +++ b/gcc/testsuite/rust/compile/const6.rs @@ -0,0 +1,4 @@ +fn main() { + const array:[i32; 1] = [1]; + const slice:&[i32] = &array; +}