Skip to content

Commit a830732

Browse files
committed
Rename places_conflict to borrow_conflicts_with_place
This name better reflects the asymmetry of this function.
1 parent 531e98a commit a830732

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

src/librustc_mir/borrow_check/path_utils.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ pub(super) fn each_borrow_involving_path<'a, 'tcx, 'gcx: 'tcx, F, I, S> (
6161
for i in candidates {
6262
let borrowed = &borrow_set[i];
6363

64-
if places_conflict::places_conflict(
64+
if places_conflict::borrow_conflicts_with_place(
6565
tcx,
6666
mir,
6767
&borrowed.borrowed_place,

src/librustc_mir/borrow_check/places_conflict.rs

+12-12
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use rustc::mir::{Projection, ProjectionElem};
1717
use rustc::ty::{self, TyCtxt};
1818
use std::cmp::max;
1919

20-
pub(super) fn places_conflict<'gcx, 'tcx>(
20+
pub(super) fn borrow_conflicts_with_place<'gcx, 'tcx>(
2121
tcx: TyCtxt<'_, 'gcx, 'tcx>,
2222
mir: &Mir<'tcx>,
2323
borrow_place: &Place<'tcx>,
@@ -26,7 +26,7 @@ pub(super) fn places_conflict<'gcx, 'tcx>(
2626
access: AccessDepth,
2727
) -> bool {
2828
debug!(
29-
"places_conflict({:?},{:?},{:?})",
29+
"borrow_conflicts_with_place({:?},{:?},{:?})",
3030
borrow_place, access_place, access
3131
);
3232

@@ -104,10 +104,10 @@ fn place_components_conflict<'gcx, 'tcx>(
104104
loop {
105105
// loop invariant: borrow_c is always either equal to access_c or disjoint from it.
106106
if let Some(borrow_c) = borrow_components.next() {
107-
debug!("places_conflict: borrow_c = {:?}", borrow_c);
107+
debug!("borrow_conflicts_with_place: borrow_c = {:?}", borrow_c);
108108

109109
if let Some(access_c) = access_components.next() {
110-
debug!("places_conflict: access_c = {:?}", access_c);
110+
debug!("borrow_conflicts_with_place: access_c = {:?}", access_c);
111111

112112
// Borrow and access path both have more components.
113113
//
@@ -136,7 +136,7 @@ fn place_components_conflict<'gcx, 'tcx>(
136136
// idea, at least for now, so just give up and
137137
// report a conflict. This is unsafe code anyway so
138138
// the user could always use raw pointers.
139-
debug!("places_conflict: arbitrary -> conflict");
139+
debug!("borrow_conflicts_with_place: arbitrary -> conflict");
140140
return true;
141141
}
142142
Overlap::EqualOrDisjoint => {
@@ -145,7 +145,7 @@ fn place_components_conflict<'gcx, 'tcx>(
145145
Overlap::Disjoint => {
146146
// We have proven the borrow disjoint - further
147147
// projections will remain disjoint.
148-
debug!("places_conflict: disjoint");
148+
debug!("borrow_conflicts_with_place: disjoint");
149149
return false;
150150
}
151151
}
@@ -177,15 +177,15 @@ fn place_components_conflict<'gcx, 'tcx>(
177177
//
178178
// e.g. a (mutable) borrow of `a[5]` while we read the
179179
// array length of `a`.
180-
debug!("places_conflict: implicit field");
180+
debug!("borrow_conflicts_with_place: implicit field");
181181
return false;
182182
}
183183

184184
(ProjectionElem::Deref, _, Shallow(None)) => {
185185
// e.g. a borrow of `*x.y` while we shallowly access `x.y` or some
186186
// prefix thereof - the shallow access can't touch anything behind
187187
// the pointer.
188-
debug!("places_conflict: shallow access behind ptr");
188+
debug!("borrow_conflicts_with_place: shallow access behind ptr");
189189
return false;
190190
}
191191
(ProjectionElem::Deref, ty::Ref(_, _, hir::MutImmutable), _) => {
@@ -195,7 +195,7 @@ fn place_components_conflict<'gcx, 'tcx>(
195195
(ProjectionElem::Deref, ty::Ref(_, _, hir::MutMutable), AccessDepth::Drop) => {
196196
// Values behind a mutatble reference are not access either by Dropping a
197197
// value, or by StorageDead
198-
debug!("places_conflict: drop access behind ptr");
198+
debug!("borrow_conflicts_with_place: drop access behind ptr");
199199
return false;
200200
}
201201

@@ -236,10 +236,10 @@ fn place_components_conflict<'gcx, 'tcx>(
236236
// that the borrow can access a *part* of our place that
237237
// our access cares about, so we still have a conflict.
238238
if borrow_kind == BorrowKind::Shallow && access_components.next().is_some() {
239-
debug!("places_conflict: shallow borrow");
239+
debug!("borrow_conflicts_with_place: shallow borrow");
240240
return false;
241241
} else {
242-
debug!("places_conflict: full borrow, CONFLICT");
242+
debug!("borrow_conflicts_with_place: full borrow, CONFLICT");
243243
return true;
244244
}
245245
}
@@ -253,7 +253,7 @@ fn place_components_conflict<'gcx, 'tcx>(
253253
///
254254
/// NB: This particular impl strategy is not the most obvious. It was
255255
/// chosen because it makes a measurable difference to NLL
256-
/// performance, as this code (`places_conflict`) is somewhat hot.
256+
/// performance, as this code (`borrow_conflicts_with_place`) is somewhat hot.
257257
struct PlaceComponents<'p, 'tcx: 'p> {
258258
component: &'p Place<'tcx>,
259259
next: Option<&'p PlaceComponents<'p, 'tcx>>,

0 commit comments

Comments
 (0)