Skip to content

Commit 09ec24b

Browse files
Removed redundant check for label being block for continue
1 parent 078c572 commit 09ec24b

File tree

3 files changed

+5
-24
lines changed

3 files changed

+5
-24
lines changed

compiler/rustc_passes/messages.ftl

-5
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,6 @@ passes_collapse_debuginfo =
9898
passes_confusables = attribute should be applied to an inherent method
9999
.label = not an inherent method
100100
101-
passes_continue_labeled_block =
102-
`continue` pointing to a labeled block
103-
.label = labeled blocks cannot be `continue`'d
104-
.block_label = labeled block the `continue` points to
105-
106101
passes_coverage_not_fn_or_closure =
107102
attribute should be applied to a function definition or closure
108103
.label = not a function or closure

compiler/rustc_passes/src/errors.rs

-10
Original file line numberDiff line numberDiff line change
@@ -1052,16 +1052,6 @@ impl<'a, G: EmissionGuarantee> Diagnostic<'_, G> for BreakNonLoop<'a> {
10521052
}
10531053
}
10541054

1055-
#[derive(Diagnostic)]
1056-
#[diag(passes_continue_labeled_block, code = E0696)]
1057-
pub struct ContinueLabeledBlock {
1058-
#[primary_span]
1059-
#[label]
1060-
pub span: Span,
1061-
#[label(passes_block_label)]
1062-
pub block_span: Span,
1063-
}
1064-
10651055
#[derive(Diagnostic)]
10661056
#[diag(passes_break_inside_closure, code = E0267)]
10671057
pub struct BreakInsideClosure<'a> {

compiler/rustc_passes/src/loops.rs

+5-9
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ use rustc_span::hygiene::DesugaringKind;
1515
use rustc_span::{BytePos, Span};
1616

1717
use crate::errors::{
18-
BreakInsideClosure, BreakInsideCoroutine, BreakNonLoop, ContinueLabeledBlock, OutsideLoop,
19-
OutsideLoopSuggestion, UnlabeledCfInWhileCondition, UnlabeledInLabeledBlock,
18+
BreakInsideClosure, BreakInsideCoroutine, BreakNonLoop, OutsideLoop, OutsideLoopSuggestion,
19+
UnlabeledCfInWhileCondition, UnlabeledInLabeledBlock,
2020
};
2121

2222
#[derive(Clone, Copy, Debug, PartialEq)]
@@ -266,13 +266,9 @@ impl<'a, 'hir> Visitor<'hir> for CheckLoopVisitor<'a, 'hir> {
266266
self.require_label_in_labeled_block(e.span, &destination, "continue");
267267

268268
match destination.target_id {
269-
Ok(loop_id) => {
270-
if let Node::Block(block) = self.tcx.hir_node(loop_id) {
271-
self.sess.dcx().emit_err(ContinueLabeledBlock {
272-
span: e.span,
273-
block_span: block.span,
274-
});
275-
}
269+
Ok(_loop_id) => {
270+
// We have already insured that the loop exists while lowering the ast.
271+
// See `compiler/rustc_ast_lowering/src/expr.rs::LoweringContext::lower_expr_mut`
276272
}
277273
Err(hir::LoopIdError::UnlabeledCfInWhileCondition) => {
278274
self.sess.dcx().emit_err(UnlabeledCfInWhileCondition {

0 commit comments

Comments
 (0)