The TypeCheckExpr creates a new TyTy::BoolType for a
ComparisonExpr. This new BoolType is unknown to TyTyResolveCompile
which causes a crash when trying to compile the inferred new
BoolType. The new "bools_eq.rs" testcase uses several bools which show
this issue. Resolve this by looking up the builtin bool type.
---
gcc/rust/typecheck/rust-hir-type-check-expr.h | 2 +-
gcc/testsuite/rust/compile/torture/bools_eq.rs | 18 ++++++++++++++++++
2 files changed, 19 insertions(+), 1 deletion(-)
create mode 100644 gcc/testsuite/rust/compile/torture/bools_eq.rs
diff --git a/gcc/rust/typecheck/rust-hir-type-check-expr.h
b/gcc/rust/typecheck/rust-hir-type-check-expr.h
index d88cb0b7f1d..9cf64685e00 100644
--- a/gcc/rust/typecheck/rust-hir-type-check-expr.h
+++ b/gcc/rust/typecheck/rust-hir-type-check-expr.h
@@ -631,7 +631,7 @@ public:
return;
// we expect this to be
- infered = new TyTy::BoolType (expr.get_mappings ().get_hirid ());
+ context->lookup_builtin ("bool", &infered);
infered->append_reference (lhs->get_ref ());
infered->append_reference (rhs->get_ref ());
}
diff --git a/gcc/testsuite/rust/compile/torture/bools_eq.rs
b/gcc/testsuite/rust/compile/torture/bools_eq.rs
new file mode 100644
index 00000000000..965127b5d54
--- /dev/null
+++ b/gcc/testsuite/rust/compile/torture/bools_eq.rs
@@ -0,0 +1,18 @@
+extern "C"
+{
+ fn abort ();
+}
+
+fn beq (a: bool, b: bool) -> bool
+{
+ let bools_eq = a == b;
+ bools_eq
+}
+
+pub fn main ()
+{
+ let a = true;
+ let b = false;
+ let r = beq (a, b);
+ if r { unsafe { abort (); } }
+}
--
2.32.0
--
Gcc-rust mailing list
[email protected]
https://gcc.gnu.org/mailman/listinfo/gcc-rust