From 55a3049525498a4c06e47c21c15f6b3d6eb1be29 Mon Sep 17 00:00:00 2001 From: Muhammad Mahad Date: Thu, 27 Jul 2023 16:36:09 +0500 Subject: gccrs: [E0571] break with argument in non-loop loop Refactored error message similiar to rustc & called error function. gcc/rust/ChangeLog: * typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): refactored error message & called error function. gcc/testsuite/ChangeLog: * rust/compile/break2.rs: Modified file to pass test case. * rust/compile/break_with_value_inside_loop.rs: New test. Signed-off-by: Muhammad Mahad --- gcc/rust/typecheck/rust-hir-type-check-expr.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'gcc/rust') diff --git a/gcc/rust/typecheck/rust-hir-type-check-expr.cc b/gcc/rust/typecheck/rust-hir-type-check-expr.cc index 95812d0..0b72fb6 100644 --- a/gcc/rust/typecheck/rust-hir-type-check-expr.cc +++ b/gcc/rust/typecheck/rust-hir-type-check-expr.cc @@ -1290,8 +1290,9 @@ TypeCheckExpr::visit (HIR::BreakExpr &expr) TyTy::BaseType *loop_context = context->peek_loop_context (); if (loop_context->get_kind () == TyTy::TypeKind::ERROR) { - rust_error_at (expr.get_locus (), - "can only break with a value inside %"); + rust_error_at ( + expr.get_locus (), ErrorCode::E0571, + "can only % with a value inside a % block"); return; } -- cgit v1.1