diff options
| author | David Wood <david@davidtw.co> | 2018-01-19 22:11:59 +0000 |
|---|---|---|
| committer | David Wood <david@davidtw.co> | 2018-01-27 13:33:10 +0000 |
| commit | 3daa4d255f1ecc9d0a28deb9ca3d6da79f1df438 (patch) | |
| tree | 8f3568f79e4be46f215cdee974cacc65bd968540 /src | |
| parent | f1c1db61e454a6be93a2706ad15a09aad161613f (diff) | |
| download | rust-3daa4d255f1ecc9d0a28deb9ca3d6da79f1df438.tar.gz rust-3daa4d255f1ecc9d0a28deb9ca3d6da79f1df438.zip | |
Introduced a new set to stop duplicate errors from MIR passes on one place/span.
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc_mir/borrow_check/mod.rs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/librustc_mir/borrow_check/mod.rs b/src/librustc_mir/borrow_check/mod.rs index d6937c405f9..1d630b280a5 100644 --- a/src/librustc_mir/borrow_check/mod.rs +++ b/src/librustc_mir/borrow_check/mod.rs @@ -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(), }; @@ -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 @@ -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, |
