Skip to content

Commit 3dd77f4

Browse files
committed
MERGEME Add fn mark_borrowed method to rustc_mir::build::Builder.
Of course this should only be kept if I actually find `mark_borrowed` called elsewhere.
1 parent 31a2296 commit 3dd77f4

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/librustc_mir/build/scope.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -668,6 +668,23 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
668668

669669
success_block
670670
}
671+
672+
pub(crate) fn mark_borrowed(&mut self, extent: CodeExtent, span: Span) {
673+
let opt_scope = self.scopes
674+
.iter_mut()
675+
.find(|s| s.extent == extent);
676+
match opt_scope {
677+
None => {
678+
self.hir.tcx().sess.span_note_without_error(
679+
span,
680+
&format!("extent {:?} not found for borrow", extent));
681+
}
682+
Some(scope) => {
683+
// borrowed scopes will need to emit an EndRegion.
684+
scope.needs_cleanup = true;
685+
}
686+
}
687+
}
671688
}
672689

673690
/// Builds drops for pop_scope and exit_scope.

0 commit comments

Comments
 (0)