Skip to content

Commit 211c6d5

Browse files
committed
librustc: Extract loan_path from move data into an accessor
1 parent 2ba1b0b commit 211c6d5

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/librustc/middle/borrowck/move_data.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ comments in the section "Moves and initialization" and in `doc.rs`.
1515
1616
*/
1717

18-
1918
use std::hashmap::{HashMap, HashSet};
2019
use std::uint;
2120
use middle::borrowck::*;
@@ -174,6 +173,10 @@ impl MoveData {
174173
}
175174
}
176175

176+
fn path_loan_path(&self, index: MovePathIndex) -> @LoanPath {
177+
self.paths[*index].loan_path
178+
}
179+
177180
fn path<'a>(&'a self, index: MovePathIndex) -> &'a MovePath {
178181
//! Type safe indexing operator
179182
&self.paths[*index]
@@ -400,7 +403,7 @@ impl MoveData {
400403

401404
// Kill all assignments when the variable goes out of scope:
402405
for (assignment_index, assignment) in self.var_assignments.iter().enumerate() {
403-
match *self.path(assignment.path).loan_path {
406+
match *self.path_loan_path(assignment.path) {
404407
LpVar(id) => {
405408
let kill_id = tcx.region_maps.encl_scope(id);
406409
dfcx_assign.add_kill(kill_id, assignment_index);
@@ -514,7 +517,7 @@ impl FlowedMoveData {
514517
self.dfcx_moves.each_gen_bit_frozen(id, |index| {
515518
let move = &self.move_data.moves[index];
516519
let moved_path = move.path;
517-
f(move, self.move_data.path(moved_path).loan_path)
520+
f(move, self.move_data.path_loan_path(moved_path))
518521
})
519522
}
520523

@@ -555,7 +558,7 @@ impl FlowedMoveData {
555558
if base_indices.iter().any(|x| x == &moved_path) {
556559
// Scenario 1 or 2: `loan_path` or some base path of
557560
// `loan_path` was moved.
558-
if !f(move, self.move_data.path(moved_path).loan_path) {
561+
if !f(move, self.move_data.path_loan_path(moved_path)) {
559562
ret = false;
560563
}
561564
} else {
@@ -564,7 +567,7 @@ impl FlowedMoveData {
564567
if p == loan_path_index {
565568
// Scenario 3: some extension of `loan_path`
566569
// was moved
567-
f(move, self.move_data.path(moved_path).loan_path)
570+
f(move, self.move_data.path_loan_path(moved_path))
568571
} else {
569572
true
570573
}

0 commit comments

Comments
 (0)