diff --git a/gcc/rust/backend/rust-compile-expr.cc b/gcc/rust/backend/rust-compile-expr.cc index 505303640cf..12c2fc883fc 100644 --- a/gcc/rust/backend/rust-compile-expr.cc +++ b/gcc/rust/backend/rust-compile-expr.cc @@ -753,8 +753,24 @@ CompileExpr::visit (HIR::BreakExpr &expr) if (expr.has_label ()) { NodeId resolved_node_id = UNKNOWN_NODEID; - if (!ctx->get_resolver ()->lookup_resolved_label ( - expr.get_label ().get_mappings ().get_nodeid (), &resolved_node_id)) + if (flag_name_resolution_2_0) + { + auto &nr_ctx + = Resolver2_0::ImmutableNameResolutionContext::get ().resolver (); + + if (auto id + = nr_ctx.lookup (expr.get_label ().get_mappings ().get_nodeid ())) + resolved_node_id = *id; + } + else + { + NodeId tmp = UNKNOWN_NODEID; + if (ctx->get_resolver ()->lookup_resolved_label ( + expr.get_label ().get_mappings ().get_nodeid (), &tmp)) + resolved_node_id = tmp; + } + + if (resolved_node_id == UNKNOWN_NODEID) { rust_error_at ( expr.get_label ().get_locus (), @@ -799,8 +815,25 @@ CompileExpr::visit (HIR::ContinueExpr &expr) if (expr.has_label ()) { NodeId resolved_node_id = UNKNOWN_NODEID; - if (!ctx->get_resolver ()->lookup_resolved_label ( - expr.get_label ().get_mappings ().get_nodeid (), &resolved_node_id)) + if (flag_name_resolution_2_0) + { + auto &nr_ctx + = Resolver2_0::ImmutableNameResolutionContext::get ().resolver (); + + if (auto id + = nr_ctx.lookup (expr.get_label ().get_mappings ().get_nodeid ())) + resolved_node_id = *id; + } + else + { + NodeId tmp = UNKNOWN_NODEID; + + if (ctx->get_resolver ()->lookup_resolved_label ( + expr.get_label ().get_mappings ().get_nodeid (), &tmp)) + resolved_node_id = tmp; + } + + if (resolved_node_id == UNKNOWN_NODEID) { rust_error_at ( expr.get_label ().get_locus (),