gccrs: Fix segv when handling invalid array capacities
We need to catch the error node for the array capacity and return early.
Otherwise we try to const evaluate something thats just silly. Also
when compiling array expressions we can simply reuse the array capacity
expression we already have cons folded.
Fixes Rust-GCC#3965
gcc/rust/ChangeLog:
* backend/rust-compile-context.h: add assertions for context peeks
* backend/rust-compile-expr.cc (CompileExpr::visit): check for valid loop context
(CompileExpr::array_copied_expr): just reuse array tyty capacity value
* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): catch error
gcc/testsuite/ChangeLog:
* rust/compile/issue-3965-1.rs: New test.
* rust/compile/issue-3965-2.rs: New test.
Signed-off-by: Philip Herron <herron.philip@googlemail.com>