Move Visitor
impl out to the mod
level
This commit is contained in:
parent
f216bac861
commit
da2364d746
1 changed files with 22 additions and 22 deletions
|
@ -859,28 +859,6 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
|||
})
|
||||
.sum();
|
||||
|
||||
/// Look for `break` expressions within any arbitrary expressions. We'll do this to infer
|
||||
/// whether this is a case where the moved value would affect the exit of a loop, making it
|
||||
/// unsuitable for a `.clone()` suggestion.
|
||||
struct BreakFinder {
|
||||
found_breaks: Vec<(hir::Destination, Span)>,
|
||||
found_continues: Vec<(hir::Destination, Span)>,
|
||||
}
|
||||
impl<'hir> Visitor<'hir> for BreakFinder {
|
||||
fn visit_expr(&mut self, ex: &'hir hir::Expr<'hir>) {
|
||||
match ex.kind {
|
||||
hir::ExprKind::Break(destination, _) => {
|
||||
self.found_breaks.push((destination, ex.span));
|
||||
}
|
||||
hir::ExprKind::Continue(destination) => {
|
||||
self.found_continues.push((destination, ex.span));
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
hir::intravisit::walk_expr(self, ex);
|
||||
}
|
||||
}
|
||||
|
||||
let sm = tcx.sess.source_map();
|
||||
if let Some(in_loop) = outer_most_loop {
|
||||
let mut finder = BreakFinder { found_breaks: vec![], found_continues: vec![] };
|
||||
|
@ -3943,6 +3921,28 @@ impl<'a, 'v> Visitor<'v> for ReferencedStatementsVisitor<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
/// Look for `break` expressions within any arbitrary expressions. We'll do this to infer
|
||||
/// whether this is a case where the moved value would affect the exit of a loop, making it
|
||||
/// unsuitable for a `.clone()` suggestion.
|
||||
struct BreakFinder {
|
||||
found_breaks: Vec<(hir::Destination, Span)>,
|
||||
found_continues: Vec<(hir::Destination, Span)>,
|
||||
}
|
||||
impl<'hir> Visitor<'hir> for BreakFinder {
|
||||
fn visit_expr(&mut self, ex: &'hir hir::Expr<'hir>) {
|
||||
match ex.kind {
|
||||
hir::ExprKind::Break(destination, _) => {
|
||||
self.found_breaks.push((destination, ex.span));
|
||||
}
|
||||
hir::ExprKind::Continue(destination) => {
|
||||
self.found_continues.push((destination, ex.span));
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
hir::intravisit::walk_expr(self, ex);
|
||||
}
|
||||
}
|
||||
|
||||
/// Given a set of spans representing statements initializing the relevant binding, visit all the
|
||||
/// function expressions looking for branching code paths that *do not* initialize the binding.
|
||||
struct ConditionVisitor<'b> {
|
||||
|
|
Loading…
Add table
Reference in a new issue