Skip to content

Commit 8916946

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

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: ShallowOrDeep,
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), _) => {
@@ -194,7 +194,7 @@ fn place_components_conflict<'gcx, 'tcx>(
194194
// I'm not sure why we are tracking these borrows - shared
195195
// references can *always* be aliased, which means the
196196
// permission check already account for this borrow.
197-
debug!("places_conflict: behind a shared ref");
197+
debug!("borrow_conflicts_with_place: behind a shared ref");
198198
return false;
199199
}
200200

@@ -226,10 +226,10 @@ fn place_components_conflict<'gcx, 'tcx>(
226226
// that the borrow can access a *part* of our place that
227227
// our access cares about, so we still have a conflict.
228228
if borrow_kind == BorrowKind::Shallow && access_components.next().is_some() {
229-
debug!("places_conflict: shallow borrow");
229+
debug!("borrow_conflicts_with_place: shallow borrow");
230230
return false;
231231
} else {
232-
debug!("places_conflict: full borrow, CONFLICT");
232+
debug!("borrow_conflicts_with_place: full borrow, CONFLICT");
233233
return true;
234234
}
235235
}
@@ -243,7 +243,7 @@ fn place_components_conflict<'gcx, 'tcx>(
243243
///
244244
/// NB: This particular impl strategy is not the most obvious. It was
245245
/// chosen because it makes a measurable difference to NLL
246-
/// performance, as this code (`places_conflict`) is somewhat hot.
246+
/// performance, as this code (`borrow_conflicts_with_place`) is somewhat hot.
247247
struct PlaceComponents<'p, 'tcx: 'p> {
248248
component: &'p Place<'tcx>,
249249
next: Option<&'p PlaceComponents<'p, 'tcx>>,

0 commit comments

Comments
 (0)