Skip to content

Commit 3c7d9ff

Browse files
committed
Address review comment: use .get instead of indexing to cope w/ terminators.
(Same net effect as code from before; just cleaner way to get there.)
1 parent 5cae7a0 commit 3c7d9ff

File tree

1 file changed

+4
-13
lines changed

1 file changed

+4
-13
lines changed

src/librustc_mir/borrow_check/error_reporting.rs

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
use syntax_pos::Span;
1212
use rustc::middle::region::ScopeTree;
1313
use rustc::mir::{BorrowKind, Field, Local, Location, Operand};
14-
use rustc::mir::{Place, ProjectionElem, Rvalue, StatementKind};
14+
use rustc::mir::{Place, ProjectionElem, Rvalue, Statement, StatementKind};
1515
use rustc::ty::{self, RegionKind};
1616
use rustc_data_structures::indexed_vec::Idx;
1717

@@ -143,18 +143,9 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
143143
use rustc::hir::ExprClosure;
144144
use rustc::mir::AggregateKind;
145145

146-
if location.statement_index == self.mir[location.block].statements.len() {
147-
// Code below hasn't been written in a manner to deal with
148-
// a terminator location.
149-
return None;
150-
}
151-
152-
let local = if let StatementKind::Assign(Place::Local(local), _) =
153-
self.mir[location.block].statements[location.statement_index].kind
154-
{
155-
local
156-
} else {
157-
return None;
146+
let local = match self.mir[location.block].statements.get(location.statement_index) {
147+
Some(&Statement { kind: StatementKind::Assign(Place::Local(local), _), .. }) => local,
148+
_ => return None,
158149
};
159150

160151
for stmt in &self.mir[location.block].statements[location.statement_index + 1..] {

0 commit comments

Comments
 (0)