@@ -14,6 +14,7 @@ use rustc::mir::{Local, Location, Place};
14
14
use rustc_data_structures:: fx:: FxHashSet ;
15
15
16
16
use borrow_check:: MirBorrowckCtxt ;
17
+ use util:: collect_writes:: is_place_assignment;
17
18
18
19
impl < ' cx , ' gcx , ' tcx > MirBorrowckCtxt < ' cx , ' gcx , ' tcx > {
19
20
/// Walks the MIR looking for assignments to a set of locals, as part of the unused mutable
@@ -45,31 +46,19 @@ impl<'visit, 'cx, 'gcx, 'tcx> Visitor<'tcx> for GatherUsedMutsVisitor<'visit, 'c
45
46
return ;
46
47
}
47
48
48
- match place_context {
49
- PlaceContext :: Store | PlaceContext :: Call => {
50
- // Propagate the Local assigned at this Location as a used mutable local variable
51
- for moi in & self . mbcx . move_data . loc_map [ location] {
52
- let mpi = & self . mbcx . move_data . moves [ * moi] . path ;
53
- let path = & self . mbcx . move_data . move_paths [ * mpi] ;
54
- debug ! (
55
- "assignment of {:?} to {:?}, adding {:?} to used mutable set" ,
56
- path. place, local, path. place
57
- ) ;
58
- if let Place :: Local ( user_local) = path. place {
59
- self . mbcx . used_mut . insert ( user_local) ;
60
- }
49
+ if is_place_assignment ( & place_context) {
50
+ // Propagate the Local assigned at this Location as a used mutable local variable
51
+ for moi in & self . mbcx . move_data . loc_map [ location] {
52
+ let mpi = & self . mbcx . move_data . moves [ * moi] . path ;
53
+ let path = & self . mbcx . move_data . move_paths [ * mpi] ;
54
+ debug ! (
55
+ "assignment of {:?} to {:?}, adding {:?} to used mutable set" ,
56
+ path. place, local, path. place
57
+ ) ;
58
+ if let Place :: Local ( user_local) = path. place {
59
+ self . mbcx . used_mut . insert ( user_local) ;
61
60
}
62
61
}
63
- PlaceContext :: AsmOutput
64
- | PlaceContext :: Drop
65
- | PlaceContext :: Inspect
66
- | PlaceContext :: Borrow { .. }
67
- | PlaceContext :: Projection ( ..)
68
- | PlaceContext :: Copy
69
- | PlaceContext :: Move
70
- | PlaceContext :: StorageLive
71
- | PlaceContext :: StorageDead
72
- | PlaceContext :: Validate => { }
73
62
}
74
63
}
75
64
}
0 commit comments