aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust
diff options
context:
space:
mode:
authorMuhammad Mahad <mahadtxt@gmail.com>2023-07-27 16:36:09 +0500
committerPhilip Herron <philip.herron@embecosm.com>2023-07-28 13:19:28 +0000
commitf201ef93a5d1f7bfa579b851bb91ffcbfc0823bb (patch)
treed10aa7f20114ce69746d388741c1b3532c0e27a2 /gcc/rust
parentfe6ad2e676ee5734856d86cf1dbbc12aef7e5561 (diff)
downloadgcc-f201ef93a5d1f7bfa579b851bb91ffcbfc0823bb.zip
gcc-f201ef93a5d1f7bfa579b851bb91ffcbfc0823bb.tar.gz
gcc-f201ef93a5d1f7bfa579b851bb91ffcbfc0823bb.tar.bz2
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 <mahadtxt@gmail.com>
Diffstat (limited to 'gcc/rust')
-rw-r--r--gcc/rust/typecheck/rust-hir-type-check-expr.cc5
1 files changed, 3 insertions, 2 deletions
diff --git a/gcc/rust/typecheck/rust-hir-type-check-expr.cc b/gcc/rust/typecheck/rust-hir-type-check-expr.cc
index 37ab69d..d6496fe 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 %<loop%>");
+ rust_error_at (
+ expr.get_locus (), ErrorCode::E0571,
+ "can only %<break%> with a value inside a %<loop%> block");
return;
}