Skip to content

Commit 9975752

Browse files
committed
fix docs for ConstContinuableScope
1 parent 67220bb commit 9975752

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

compiler/rustc_mir_build/src/builder/scope.rs

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -181,17 +181,16 @@ struct BreakableScope<'tcx> {
181181

182182
#[derive(Debug)]
183183
struct ConstContinuableScope<'tcx> {
184-
/// The if-then scope or arm scope.
184+
/// The scope for the `#[loop_match]` which its `#[const_continue]`s will jump to.
185185
region_scope: region::Scope,
186-
/// The destination of the loop/block expression itself (i.e., where to put
187-
/// the result of a `break` or `return` expression).
186+
/// The place of the state of a `#[loop_match]`, which a `#[const_continue]` must update.
188187
state_place: Place<'tcx>,
189188

190189
arms: Box<[ArmId]>,
191190
built_match_tree: BuiltMatchTree<'tcx>,
192191

193-
/// Drops that happen on the `return` path and would have happened on the `break` path.
194-
break_drops: DropTree,
192+
/// Drops that happen on a `#[const_continue]`
193+
const_continue_drops: DropTree,
195194
}
196195

197196
#[derive(Debug)]
@@ -591,17 +590,21 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
591590
let scope = ConstContinuableScope {
592591
region_scope,
593592
state_place,
594-
break_drops: DropTree::new(),
593+
const_continue_drops: DropTree::new(),
595594
arms,
596595
built_match_tree,
597596
};
598597
self.scopes.const_continuable_scopes.push(scope);
599598
let normal_exit_block = f(self);
600-
let breakable_scope = self.scopes.const_continuable_scopes.pop().unwrap();
601-
assert!(breakable_scope.region_scope == region_scope);
599+
let const_continue_scope = self.scopes.const_continuable_scopes.pop().unwrap();
600+
assert!(const_continue_scope.region_scope == region_scope);
602601

603-
let break_block =
604-
self.build_exit_tree(breakable_scope.break_drops, region_scope, span, None);
602+
let break_block = self.build_exit_tree(
603+
const_continue_scope.const_continue_drops,
604+
region_scope,
605+
span,
606+
None,
607+
);
605608

606609
match (normal_exit_block, break_block) {
607610
(block, None) => block,
@@ -892,7 +895,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
892895
TerminatorKind::FalseEdge { real_target: drop_and_continue_block, imaginary_target },
893896
);
894897

895-
let drops = &mut scope.break_drops;
898+
let drops = &mut scope.const_continue_drops;
896899

897900
let drop_idx = self.scopes.scopes[scope_index + 1..]
898901
.iter()

compiler/rustc_passes/src/loops.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ impl<'hir> CheckLoopVisitor<'hir> {
428428
}
429429
}
430430

431-
/// Is this a loop annotated with #[loop_match] that looks syntactically sound?
431+
/// Is this a loop annotated with `#[loop_match]` that looks syntactically sound?
432432
fn is_loop_match(
433433
&self,
434434
e: &'hir hir::Expr<'hir>,

0 commit comments

Comments
 (0)