aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2022-09-05 11:45:24 +0000
committerGitHub <noreply@github.com>2022-09-05 11:45:24 +0000
commit8c6b017310ec3b4f77500d5fa8311e995d655c1a (patch)
treef28c4471e451f3cea477b29fabf27d35ed8a030b /gcc
parent4f0a2729d78d77f14140531ca809d1c45311f0c9 (diff)
parenta876e9e8f0c48b476116b0f5808ab32dfb520f56 (diff)
downloadgcc-8c6b017310ec3b4f77500d5fa8311e995d655c1a.zip
gcc-8c6b017310ec3b4f77500d5fa8311e995d655c1a.tar.gz
gcc-8c6b017310ec3b4f77500d5fa8311e995d655c1a.tar.bz2
Merge #1522
1522: Add testcases to test folding r=philberty a=abbasfaisal The fix is a bit of guess so do have a careful look :) Co-authored-by: Faisal Abbas <90.abbasfaisal@gmail.com>
Diffstat (limited to 'gcc')
-rw-r--r--gcc/rust/typecheck/rust-hir-type-check-stmt.cc2
-rw-r--r--gcc/testsuite/rust/compile/const6.rs4
-rw-r--r--gcc/testsuite/rust/compile/const7.rs12
3 files changed, 17 insertions, 1 deletions
diff --git a/gcc/rust/typecheck/rust-hir-type-check-stmt.cc b/gcc/rust/typecheck/rust-hir-type-check-stmt.cc
index 48db1fd..ce8d97b 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;
+}
diff --git a/gcc/testsuite/rust/compile/const7.rs b/gcc/testsuite/rust/compile/const7.rs
new file mode 100644
index 0000000..a7431c0
--- /dev/null
+++ b/gcc/testsuite/rust/compile/const7.rs
@@ -0,0 +1,12 @@
+// { dg-options "-w -O0 -fdump-tree-gimple" }
+struct Foo(usize, usize);
+
+const A:Foo = Foo(123, 4546);
+
+const B:usize = A.0;
+
+fn main() {
+ // { dg-final { scan-tree-dump-times {b = 123} 1 gimple } }
+ let b = B;
+}
+