Skip to content

Commit 06f33dc

Browse files
Removed redundant check for label being block for continue
1 parent f2e19d0 commit 06f33dc

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
@@ -95,11 +95,6 @@ passes_collapse_debuginfo =
9595
passes_confusables = attribute should be applied to an inherent method
9696
.label = not an inherent method
9797
98-
passes_continue_labeled_block =
99-
`continue` pointing to a labeled block
100-
.label = labeled blocks cannot be `continue`'d
101-
.block_label = labeled block the `continue` points to
102-
10398
passes_coverage_not_fn_or_closure =
10499
attribute should be applied to a function definition or closure
105100
.label = not a function or closure

compiler/rustc_passes/src/errors.rs

-10
Original file line numberDiff line numberDiff line change
@@ -1044,16 +1044,6 @@ impl<'a, G: EmissionGuarantee> Diagnostic<'_, G> for BreakNonLoop<'a> {
10441044
}
10451045
}
10461046

1047-
#[derive(Diagnostic)]
1048-
#[diag(passes_continue_labeled_block, code = E0696)]
1049-
pub struct ContinueLabeledBlock {
1050-
#[primary_span]
1051-
#[label]
1052-
pub span: Span,
1053-
#[label(passes_block_label)]
1054-
pub block_span: Span,
1055-
}
1056-
10571047
#[derive(Diagnostic)]
10581048
#[diag(passes_break_inside_closure, code = E0267)]
10591049
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::{BytePos, Span};
1515
use Context::*;
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)