aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorPhilip Herron <philip.herron@embecosm.com>2021-03-08 15:05:35 +0000
committerPhilip Herron <herron.philip@googlemail.com>2021-03-09 18:18:35 +0000
commit537f59bdef827b8f265f7d155567ca2dc835301b (patch)
tree14ac5671af4c38d5305b4c3082d43c911799aeee /gcc
parent670da018324136992d817648a64ca73810d45d82 (diff)
downloadgcc-537f59bdef827b8f265f7d155567ca2dc835301b.zip
gcc-537f59bdef827b8f265f7d155567ca2dc835301b.tar.gz
gcc-537f59bdef827b8f265f7d155567ca2dc835301b.tar.bz2
Fix bug when using general inference variables
When we have a General inference G? variable as part of an array that is unified with integeral inference variables I? the context left the General inference variable but really this changed to tbe I? and can default to i32. Fixes #258
Diffstat (limited to 'gcc')
-rw-r--r--gcc/rust/typecheck/rust-tyty-rules.h10
-rw-r--r--gcc/testsuite/rust.test/compilable/infer_type1.rs3
2 files changed, 11 insertions, 2 deletions
diff --git a/gcc/rust/typecheck/rust-tyty-rules.h b/gcc/rust/typecheck/rust-tyty-rules.h
index 59c1890..758ec58 100644
--- a/gcc/rust/typecheck/rust-tyty-rules.h
+++ b/gcc/rust/typecheck/rust-tyty-rules.h
@@ -77,7 +77,13 @@ public:
resolved->append_reference (ref);
bool result_resolved = resolved->get_kind () != TyTy::TypeKind::INFER;
- if (result_resolved)
+ bool result_is_infer_var
+ = resolved->get_kind () == TyTy::TypeKind::INFER;
+ bool results_is_non_general_infer_var
+ = (result_is_infer_var
+ && ((InferType *) resolved)->get_infer_kind ()
+ != TyTy::InferType::GENERAL);
+ if (result_resolved || results_is_non_general_infer_var)
{
for (auto &ref : resolved->get_combined_refs ())
{
@@ -563,7 +569,7 @@ public:
auto base_resolved = base->get_type ()->unify (type.get_type ());
if (base_resolved == nullptr)
{
- // fixme add error message
+ BaseRules::visit (type);
return;
}
diff --git a/gcc/testsuite/rust.test/compilable/infer_type1.rs b/gcc/testsuite/rust.test/compilable/infer_type1.rs
new file mode 100644
index 0000000..38bd8ae
--- /dev/null
+++ b/gcc/testsuite/rust.test/compilable/infer_type1.rs
@@ -0,0 +1,3 @@
+fn main() {
+ let array: [_; 2] = [111, 222];
+}