Skip to content

Commit cfd9320

Browse files
Update to use new Place
1 parent bdaa90a commit cfd9320

File tree

2 files changed

+26
-20
lines changed

2 files changed

+26
-20
lines changed

src/librustc/mir/mod.rs

+10-3
Original file line numberDiff line numberDiff line change
@@ -1927,11 +1927,11 @@ impl<'tcx> Place<'tcx> {
19271927
place_projection: &Option<Box<Projection<'tcx>>>,
19281928
op: impl FnOnce(&'a PlaceBase<'tcx>, ProjectionsIter<'_, 'tcx>) -> R,
19291929
) -> R {
1930-
fn iterate_over2<'tcx, R>(
1931-
place_base: &PlaceBase<'tcx>,
1930+
fn iterate_over2<'a, 'tcx, R: 'a>(
1931+
place_base: &'a PlaceBase<'tcx>,
19321932
place_projection: &Option<Box<Projection<'tcx>>>,
19331933
next: &Projections<'_, 'tcx>,
1934-
op: impl FnOnce(&PlaceBase<'tcx>, ProjectionsIter<'_, 'tcx>) -> R,
1934+
op: impl FnOnce(&'a PlaceBase<'tcx>, ProjectionsIter<'_, 'tcx>) -> R,
19351935
) -> R {
19361936
match place_projection {
19371937
None => {
@@ -2242,6 +2242,13 @@ impl<'tcx> Operand<'tcx> {
22422242
Operand::Move(ref place) => Operand::Copy(place.clone()),
22432243
}
22442244
}
2245+
2246+
pub fn place(&self) -> Option<&Place<'tcx>> {
2247+
match self {
2248+
Operand::Copy(place) | Operand::Move(place) => Some(place),
2249+
Operand::Constant(_) => None,
2250+
}
2251+
}
22452252
}
22462253

22472254
///////////////////////////////////////////////////////////////////////////

src/librustc_mir/transform/rustc_peek.rs

+16-17
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ fn value_assigned_to_local<'a, 'tcx>(
155155
local: Local,
156156
) -> Option<&'a mir::Rvalue<'tcx>> {
157157
if let mir::StatementKind::Assign(place, rvalue) = &stmt.kind {
158-
if let mir::Place::Base(mir::PlaceBase::Local(l)) = place {
158+
if let mir::Place { base: mir::PlaceBase::Local(l), projection: None } = place {
159159
if local == *l {
160160
return Some(&*rvalue);
161161
}
@@ -206,23 +206,22 @@ impl PeekCall {
206206

207207
assert_eq!(args.len(), 1);
208208
let kind = PeekCallKind::from_arg_ty(substs.type_at(0));
209-
let arg = match args[0] {
210-
| mir::Operand::Copy(mir::Place::Base(mir::PlaceBase::Local(local)))
211-
| mir::Operand::Move(mir::Place::Base(mir::PlaceBase::Local(local)))
212-
=> local,
213-
214-
_ => {
215-
tcx.sess.diagnostic().span_err(
216-
span, "dataflow::sanity_check cannot feed a non-temp to rustc_peek.");
217-
return None;
209+
if let mir::Operand::Copy(place) | mir::Operand::Move(place) = &args[0] {
210+
if let mir::Place {
211+
base: mir::PlaceBase::Local(local),
212+
projection: None
213+
} = *place {
214+
return Some(PeekCall {
215+
arg: local,
216+
kind,
217+
span,
218+
});
218219
}
219-
};
220+
}
220221

221-
return Some(PeekCall {
222-
arg,
223-
kind,
224-
span,
225-
});
222+
tcx.sess.diagnostic().span_err(
223+
span, "dataflow::sanity_check cannot feed a non-temp to rustc_peek.");
224+
return None;
226225
}
227226
}
228227

@@ -255,7 +254,7 @@ impl<'tcx, O> RustcPeekAt<'tcx> for DataflowResults<'tcx, O>
255254
let operator = self.operator();
256255
let flow_state = dataflow::state_for_location(location, operator, self, body);
257256

258-
match operator.move_data().rev_lookup.find(place) {
257+
match operator.move_data().rev_lookup.find(place.as_ref()) {
259258
LookupResult::Exact(peek_mpi) => {
260259
let bit_state = flow_state.contains(peek_mpi);
261260
debug!("rustc_peek({:?} = &{:?}) bit_state: {}",

0 commit comments

Comments
 (0)