Skip to content

Commit a57aea8

Browse files
committed
rustc: expose the mir::Body reference lifetime from mir::ReadOnlyBodyCache (rust-lang#64736 fallout).
1 parent 4810cf1 commit a57aea8

File tree

16 files changed

+62
-70
lines changed

16 files changed

+62
-70
lines changed

src/librustc/mir/cache.rs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -279,18 +279,10 @@ impl<'a, 'b, 'tcx> graph::GraphSuccessors<'b> for ReadOnlyBodyCache<'a, 'tcx> {
279279

280280

281281
impl Deref for ReadOnlyBodyCache<'a, 'tcx> {
282-
type Target = Body<'tcx>;
282+
type Target = &'a Body<'tcx>;
283283

284284
fn deref(&self) -> &Self::Target {
285-
self.body
286-
}
287-
}
288-
289-
impl Index<BasicBlock> for ReadOnlyBodyCache<'a, 'tcx> {
290-
type Output = BasicBlockData<'tcx>;
291-
292-
fn index(&self, index: BasicBlock) -> &BasicBlockData<'tcx> {
293-
&self.body[index]
285+
&self.body
294286
}
295287
}
296288

src/librustc_codegen_ssa/mir/analyze.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ impl<Bx: BuilderMethods<'a, 'tcx>> LocalAnalyzer<'mir, 'a, 'tcx, Bx> {
131131
};
132132
if is_consume {
133133
let base_ty =
134-
mir::Place::ty_from(place_ref.base, proj_base, &*self.fx.mir, cx.tcx());
134+
mir::Place::ty_from(place_ref.base, proj_base, *self.fx.mir, cx.tcx());
135135
let base_ty = self.fx.monomorphize(&base_ty);
136136

137137
// ZSTs don't require any actual memory access.

src/librustc_codegen_ssa/mir/block.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
324324
target: mir::BasicBlock,
325325
unwind: Option<mir::BasicBlock>,
326326
) {
327-
let ty = location.ty(&*self.mir, bx.tcx()).ty;
327+
let ty = location.ty(*self.mir, bx.tcx()).ty;
328328
let ty = self.monomorphize(&ty);
329329
let drop_fn = Instance::resolve_drop_in_place(bx.tcx(), ty);
330330

@@ -510,7 +510,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
510510

511511
let extra_args = &args[sig.inputs().len()..];
512512
let extra_args = extra_args.iter().map(|op_arg| {
513-
let op_ty = op_arg.ty(&*self.mir, bx.tcx());
513+
let op_ty = op_arg.ty(*self.mir, bx.tcx());
514514
self.monomorphize(&op_ty)
515515
}).collect::<Vec<_>>();
516516

src/librustc_codegen_ssa/mir/place.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
594594
let place_ty = mir::Place::ty_from(
595595
place_ref.base,
596596
place_ref.projection,
597-
&*self.mir,
597+
*self.mir,
598598
tcx,
599599
);
600600
self.monomorphize(&place_ty.ty)

src/librustc_codegen_ssa/mir/rvalue.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
460460
}
461461

462462
mir::Rvalue::Discriminant(ref place) => {
463-
let discr_ty = rvalue.ty(&*self.mir, bx.tcx());
463+
let discr_ty = rvalue.ty(*self.mir, bx.tcx());
464464
let discr = self.codegen_place(&mut bx, &place.as_ref())
465465
.codegen_get_discr(&mut bx, discr_ty);
466466
(bx, OperandRef {
@@ -513,7 +513,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
513513
mir::Rvalue::Aggregate(..) => {
514514
// According to `rvalue_creates_operand`, only ZST
515515
// aggregate rvalues are allowed to be operands.
516-
let ty = rvalue.ty(&*self.mir, self.cx.tcx());
516+
let ty = rvalue.ty(*self.mir, self.cx.tcx());
517517
let operand = OperandRef::new_zst(
518518
&mut bx,
519519
self.cx.layout_of(self.monomorphize(&ty)),
@@ -710,7 +710,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
710710
true,
711711
mir::Rvalue::Repeat(..) |
712712
mir::Rvalue::Aggregate(..) => {
713-
let ty = rvalue.ty(&*self.mir, self.cx.tcx());
713+
let ty = rvalue.ty(*self.mir, self.cx.tcx());
714714
let ty = self.monomorphize(&ty);
715715
self.cx.spanned_layout_of(ty, span).is_zst()
716716
}

src/librustc_mir/borrow_check/conflict_errors.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
208208
let ty = Place::ty_from(
209209
used_place.base,
210210
used_place.projection,
211-
&*self.body,
211+
*self.body,
212212
self.infcx.tcx
213213
).ty;
214214
let needs_note = match ty.kind {
@@ -225,7 +225,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
225225
let mpi = self.move_data.moves[move_out_indices[0]].path;
226226
let place = &self.move_data.move_paths[mpi].place;
227227

228-
let ty = place.ty(&*self.body, self.infcx.tcx).ty;
228+
let ty = place.ty(*self.body, self.infcx.tcx).ty;
229229
let opt_name =
230230
self.describe_place_with_options(place.as_ref(), IncludingDowncast(true));
231231
let note_msg = match opt_name {
@@ -625,7 +625,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
625625
let ty = Place::ty_from(
626626
place_base,
627627
place_projection,
628-
&*self.body,
628+
*self.body,
629629
self.infcx.tcx
630630
).ty;
631631
ty.ty_adt_def().filter(|adt| adt.is_union()).map(|_| ty)
@@ -1635,7 +1635,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
16351635
Place::ty_from(
16361636
&place.base,
16371637
proj_base,
1638-
&*self.body,
1638+
*self.body,
16391639
tcx
16401640
).ty.is_box(),
16411641
"Drop of value behind a reference or raw pointer"
@@ -1648,7 +1648,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
16481648
let base_ty = Place::ty_from(
16491649
&place.base,
16501650
proj_base,
1651-
&*self.body,
1651+
*self.body,
16521652
tcx
16531653
).ty;
16541654
match base_ty.kind {

src/librustc_mir/borrow_check/error_reporting.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
372372
let base_ty = Place::ty_from(
373373
place.base,
374374
place.projection,
375-
&*self.body,
375+
*self.body,
376376
self.infcx.tcx).ty;
377377
self.describe_field_from_ty(&base_ty, field, Some(*variant_index))
378378
}
@@ -502,7 +502,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
502502
..
503503
}) = bbd.terminator {
504504
if let Some(source) = BorrowedContentSource::from_call(
505-
func.ty(&*self.body, tcx),
505+
func.ty(*self.body, tcx),
506506
tcx
507507
) {
508508
return source;
@@ -519,7 +519,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
519519
let base_ty = Place::ty_from(
520520
deref_base.base,
521521
deref_base.projection,
522-
&*self.body,
522+
*self.body,
523523
tcx
524524
).ty;
525525
if base_ty.is_unsafe_ptr() {

src/librustc_mir/borrow_check/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,7 @@ impl<'cx, 'tcx> DataflowResultsConsumer<'cx, 'tcx> for MirBorrowckCtxt<'cx, 'tcx
646646
let tcx = self.infcx.tcx;
647647

648648
// Compute the type with accurate region information.
649-
let drop_place_ty = drop_place.ty(&*self.body, self.infcx.tcx);
649+
let drop_place_ty = drop_place.ty(*self.body, self.infcx.tcx);
650650

651651
// Erase the regions.
652652
let drop_place_ty = self.infcx.tcx.erase_regions(&drop_place_ty).ty;

src/librustc_mir/borrow_check/move_errors.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
300300
// Inspect the type of the content behind the
301301
// borrow to provide feedback about why this
302302
// was a move rather than a copy.
303-
let ty = deref_target_place.ty(&*self.body, self.infcx.tcx).ty;
303+
let ty = deref_target_place.ty(*self.body, self.infcx.tcx).ty;
304304
let upvar_field = self.prefixes(move_place.as_ref(), PrefixSet::All)
305305
.find_map(|p| self.is_upvar_field_projection(p));
306306

@@ -411,7 +411,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
411411
};
412412
let move_ty = format!(
413413
"{:?}",
414-
move_place.ty(&*self.body, self.infcx.tcx).ty,
414+
move_place.ty(*self.body, self.infcx.tcx).ty,
415415
);
416416
if let Ok(snippet) = self.infcx.tcx.sess.source_map().span_to_snippet(span) {
417417
let is_option = move_ty.starts_with("std::option::Option");
@@ -454,7 +454,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
454454
}
455455

456456
if binds_to.is_empty() {
457-
let place_ty = move_from.ty(&*self.body, self.infcx.tcx).ty;
457+
let place_ty = move_from.ty(*self.body, self.infcx.tcx).ty;
458458
let place_desc = match self.describe_place(move_from.as_ref()) {
459459
Some(desc) => format!("`{}`", desc),
460460
None => format!("value"),
@@ -482,7 +482,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
482482
// No binding. Nothing to suggest.
483483
GroupedMoveError::OtherIllegalMove { ref original_path, use_spans, .. } => {
484484
let span = use_spans.var_or_use();
485-
let place_ty = original_path.ty(&*self.body, self.infcx.tcx).ty;
485+
let place_ty = original_path.ty(*self.body, self.infcx.tcx).ty;
486486
let place_desc = match self.describe_place(original_path.as_ref()) {
487487
Some(desc) => format!("`{}`", desc),
488488
None => format!("value"),

src/librustc_mir/borrow_check/mutability_errors.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
6464
Place::ty_from(
6565
&the_place_err.base,
6666
proj_base,
67-
&*self.body,
67+
*self.body,
6868
self.infcx.tcx
6969
).ty));
7070

@@ -115,7 +115,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
115115
Place::ty_from(
116116
the_place_err.base,
117117
the_place_err.projection,
118-
&*self.body,
118+
*self.body,
119119
self.infcx.tcx
120120
)
121121
.ty
@@ -229,7 +229,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
229229

230230
if let Some((span, message)) = annotate_struct_field(
231231
self.infcx.tcx,
232-
Place::ty_from(base, proj_base, &*self.body, self.infcx.tcx).ty,
232+
Place::ty_from(base, proj_base, *self.body, self.infcx.tcx).ty,
233233
field,
234234
) {
235235
err.span_suggestion(
@@ -304,7 +304,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
304304
projection: [proj_base @ .., ProjectionElem::Field(upvar_index, _)],
305305
} => {
306306
debug_assert!(is_closure_or_generator(
307-
Place::ty_from(base, proj_base, &*self.body, self.infcx.tcx).ty
307+
Place::ty_from(base, proj_base, *self.body, self.infcx.tcx).ty
308308
));
309309

310310
err.span_label(span, format!("cannot {ACT}", ACT = act));

0 commit comments

Comments
 (0)