Skip to content

Commit da2364d

Browse files
committed
Move Visitor impl out to the mod level
1 parent f216bac commit da2364d

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs

+22-22
Original file line numberDiff line numberDiff line change
@@ -859,28 +859,6 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
859859
})
860860
.sum();
861861

862-
/// Look for `break` expressions within any arbitrary expressions. We'll do this to infer
863-
/// whether this is a case where the moved value would affect the exit of a loop, making it
864-
/// unsuitable for a `.clone()` suggestion.
865-
struct BreakFinder {
866-
found_breaks: Vec<(hir::Destination, Span)>,
867-
found_continues: Vec<(hir::Destination, Span)>,
868-
}
869-
impl<'hir> Visitor<'hir> for BreakFinder {
870-
fn visit_expr(&mut self, ex: &'hir hir::Expr<'hir>) {
871-
match ex.kind {
872-
hir::ExprKind::Break(destination, _) => {
873-
self.found_breaks.push((destination, ex.span));
874-
}
875-
hir::ExprKind::Continue(destination) => {
876-
self.found_continues.push((destination, ex.span));
877-
}
878-
_ => {}
879-
}
880-
hir::intravisit::walk_expr(self, ex);
881-
}
882-
}
883-
884862
let sm = tcx.sess.source_map();
885863
if let Some(in_loop) = outer_most_loop {
886864
let mut finder = BreakFinder { found_breaks: vec![], found_continues: vec![] };
@@ -3943,6 +3921,28 @@ impl<'a, 'v> Visitor<'v> for ReferencedStatementsVisitor<'a> {
39433921
}
39443922
}
39453923

3924+
/// Look for `break` expressions within any arbitrary expressions. We'll do this to infer
3925+
/// whether this is a case where the moved value would affect the exit of a loop, making it
3926+
/// unsuitable for a `.clone()` suggestion.
3927+
struct BreakFinder {
3928+
found_breaks: Vec<(hir::Destination, Span)>,
3929+
found_continues: Vec<(hir::Destination, Span)>,
3930+
}
3931+
impl<'hir> Visitor<'hir> for BreakFinder {
3932+
fn visit_expr(&mut self, ex: &'hir hir::Expr<'hir>) {
3933+
match ex.kind {
3934+
hir::ExprKind::Break(destination, _) => {
3935+
self.found_breaks.push((destination, ex.span));
3936+
}
3937+
hir::ExprKind::Continue(destination) => {
3938+
self.found_continues.push((destination, ex.span));
3939+
}
3940+
_ => {}
3941+
}
3942+
hir::intravisit::walk_expr(self, ex);
3943+
}
3944+
}
3945+
39463946
/// Given a set of spans representing statements initializing the relevant binding, visit all the
39473947
/// function expressions looking for branching code paths that *do not* initialize the binding.
39483948
struct ConditionVisitor<'b> {

0 commit comments

Comments
 (0)