Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Introduced a new set to stop duplicate errors from MIR passes on one …
…place/span.
  • Loading branch information
davidtwco committed Jan 27, 2018
commit 3daa4d255f1ecc9d0a28deb9ca3d6da79f1df438
16 changes: 16 additions & 0 deletions src/librustc_mir/borrow_check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ fn do_mir_borrowck<'a, 'gcx, 'tcx>(
},
storage_dead_or_drop_error_reported_l: FxHashSet(),
storage_dead_or_drop_error_reported_s: FxHashSet(),
read_or_write_error_reported: FxHashSet(),
reservation_error_reported: FxHashSet(),
nonlexical_regioncx: opt_regioncx.clone(),
};
Expand Down Expand Up @@ -300,6 +301,9 @@ pub struct MirBorrowckCtxt<'cx, 'gcx: 'tcx, 'tcx: 'cx> {
storage_dead_or_drop_error_reported_l: FxHashSet<Local>,
/// Same as the above, but for statics (thread-locals)
storage_dead_or_drop_error_reported_s: FxHashSet<DefId>,
/// This field keeps track of when borrow errors are reported in read or write passes
/// so that an error is not reported in both.
read_or_write_error_reported: FxHashSet<(Place<'tcx>, Span)>,
/// This field keeps track of when borrow conflict errors are reported
/// for reservations, so that we don't report seemingly duplicate
/// errors for corresponding activations
Expand Down Expand Up @@ -739,11 +743,23 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
}
}

if self.read_or_write_error_reported.contains(&(place_span.0.clone(), place_span.1)) {
debug!("suppressing access_place write for {:?}", place_span);
return AccessErrorsReported {
mutability_error: false,
conflict_error: true,
};
}

let mutability_error =
self.check_access_permissions(place_span, rw, is_local_mutation_allowed);
let conflict_error =
self.check_access_for_conflict(context, place_span, sd, rw, flow_state);

if conflict_error {
self.read_or_write_error_reported.insert((place_span.0.clone(), place_span.1));
}

AccessErrorsReported {
mutability_error,
conflict_error,
Expand Down