- debug!("check_if_reassignment_to_immutable_state({:?})", place);
- // determine if this path has a non-mut owner (and thus needs checking).
- let err_place = match self.is_mutable(place, LocalMutationIsAllowed::No) {
- Ok(..) => return,
- Err(place) => place,
- };
- debug!(
- "check_if_reassignment_to_immutable_state({:?}) - is an imm local",
- place
- );
-
- for i in flow_state.ever_inits.iter_incoming() {
- let init = self.move_data.inits[i];
- let init_place = &self.move_data.move_paths[init.path].place;
- if places_conflict::places_conflict(self.tcx, self.mir, &init_place, place, Deep) {
- self.report_illegal_reassignment(context, (place, span), init.span, err_place);
- break;
- }
+ debug!("check_if_reassignment_to_immutable_state({:?})", local);
+
+ // Check if any of the initializiations of `local` have happened yet:
+ let mpi = self.move_data.rev_lookup.find_local(local);
+ let init_indices = &self.move_data.init_path_map[mpi];
+ let first_init_index = init_indices.iter().find(|ii| flow_state.ever_inits.contains(ii));
+ if let Some(&init_index) = first_init_index {
+ // And, if so, report an error.
+ let init = &self.move_data.inits[init_index];
+ self.report_illegal_reassignment(context, place_span, init.span, place_span.0);