Skip to content

Commit 64db428

Browse files
Don't use * for deref-coercion
1 parent 884ba4f commit 64db428

File tree

17 files changed

+77
-78
lines changed

17 files changed

+77
-78
lines changed

src/librustc_codegen_ssa/mir/analyze.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ impl<Bx: BuilderMethods<'a, 'tcx>> LocalAnalyzer<'mir, 'a, 'tcx, Bx> {
120120
};
121121
if is_consume {
122122
let base_ty =
123-
mir::Place::ty_from(place_ref.local, proj_base, *self.fx.mir, cx.tcx());
123+
mir::Place::ty_from(place_ref.local, proj_base, self.fx.mir, cx.tcx());
124124
let base_ty = self.fx.monomorphize(&base_ty);
125125

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

src/librustc_codegen_ssa/mir/block.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
306306
target: mir::BasicBlock,
307307
unwind: Option<mir::BasicBlock>,
308308
) {
309-
let ty = location.ty(*self.mir, bx.tcx()).ty;
309+
let ty = location.ty(self.mir, bx.tcx()).ty;
310310
let ty = self.monomorphize(&ty);
311311
let drop_fn = Instance::resolve_drop_in_place(bx.tcx(), ty);
312312

@@ -572,7 +572,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
572572
let extra_args = extra_args
573573
.iter()
574574
.map(|op_arg| {
575-
let op_ty = op_arg.ty(*self.mir, bx.tcx());
575+
let op_ty = op_arg.ty(self.mir, bx.tcx());
576576
self.monomorphize(&op_ty)
577577
})
578578
.collect::<Vec<_>>();

src/librustc_codegen_ssa/mir/place.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
497497

498498
pub fn monomorphized_place_ty(&self, place_ref: mir::PlaceRef<'tcx>) -> Ty<'tcx> {
499499
let tcx = self.cx.tcx();
500-
let place_ty = mir::Place::ty_from(place_ref.local, place_ref.projection, *self.mir, tcx);
500+
let place_ty = mir::Place::ty_from(place_ref.local, place_ref.projection, self.mir, tcx);
501501
self.monomorphize(&place_ty.ty)
502502
}
503503
}

src/librustc_codegen_ssa/mir/rvalue.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
473473
}
474474

475475
mir::Rvalue::Discriminant(ref place) => {
476-
let discr_ty = rvalue.ty(*self.mir, bx.tcx());
476+
let discr_ty = rvalue.ty(self.mir, bx.tcx());
477477
let discr = self
478478
.codegen_place(&mut bx, place.as_ref())
479479
.codegen_get_discr(&mut bx, discr_ty);
@@ -529,7 +529,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
529529
mir::Rvalue::Repeat(..) | mir::Rvalue::Aggregate(..) => {
530530
// According to `rvalue_creates_operand`, only ZST
531531
// aggregate rvalues are allowed to be operands.
532-
let ty = rvalue.ty(*self.mir, self.cx.tcx());
532+
let ty = rvalue.ty(self.mir, self.cx.tcx());
533533
let operand =
534534
OperandRef::new_zst(&mut bx, self.cx.layout_of(self.monomorphize(&ty)));
535535
(bx, operand)
@@ -749,7 +749,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
749749
true,
750750
mir::Rvalue::Repeat(..) |
751751
mir::Rvalue::Aggregate(..) => {
752-
let ty = rvalue.ty(*self.mir, self.cx.tcx());
752+
let ty = rvalue.ty(self.mir, self.cx.tcx());
753753
let ty = self.monomorphize(&ty);
754754
self.cx.spanned_layout_of(ty, span).is_zst()
755755
}

src/librustc_mir/borrow_check/diagnostics/conflict_errors.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
186186
}
187187

188188
let ty =
189-
Place::ty_from(used_place.local, used_place.projection, *self.body, self.infcx.tcx)
189+
Place::ty_from(used_place.local, used_place.projection, self.body, self.infcx.tcx)
190190
.ty;
191191
let needs_note = match ty.kind {
192192
ty::Closure(id, _) => {
@@ -202,7 +202,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
202202
let mpi = self.move_data.moves[move_out_indices[0]].path;
203203
let place = &self.move_data.move_paths[mpi].place;
204204

205-
let ty = place.ty(*self.body, self.infcx.tcx).ty;
205+
let ty = place.ty(self.body, self.infcx.tcx).ty;
206206
let opt_name =
207207
self.describe_place_with_options(place.as_ref(), IncludingDowncast(true));
208208
let note_msg = match opt_name {
@@ -591,7 +591,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
591591
// Define a small closure that we can use to check if the type of a place
592592
// is a union.
593593
let union_ty = |place_base, place_projection| {
594-
let ty = Place::ty_from(place_base, place_projection, *self.body, self.infcx.tcx).ty;
594+
let ty = Place::ty_from(place_base, place_projection, self.body, self.infcx.tcx).ty;
595595
ty.ty_adt_def().filter(|adt| adt.is_union()).map(|_| ty)
596596
};
597597

@@ -1486,15 +1486,15 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
14861486
StorageDeadOrDrop::LocalStorageDead
14871487
| StorageDeadOrDrop::BoxedStorageDead => {
14881488
assert!(
1489-
Place::ty_from(place.local, proj_base, *self.body, tcx).ty.is_box(),
1489+
Place::ty_from(place.local, proj_base, self.body, tcx).ty.is_box(),
14901490
"Drop of value behind a reference or raw pointer"
14911491
);
14921492
StorageDeadOrDrop::BoxedStorageDead
14931493
}
14941494
StorageDeadOrDrop::Destructor(_) => base_access,
14951495
},
14961496
ProjectionElem::Field(..) | ProjectionElem::Downcast(..) => {
1497-
let base_ty = Place::ty_from(place.local, proj_base, *self.body, tcx).ty;
1497+
let base_ty = Place::ty_from(place.local, proj_base, self.body, tcx).ty;
14981498
match base_ty.kind {
14991499
ty::Adt(def, _) if def.has_dtor(tcx) => {
15001500
// Report the outermost adt with a destructor

src/librustc_mir/borrow_check/diagnostics/mod.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -331,8 +331,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
331331
}
332332
ProjectionElem::Downcast(_, variant_index) => {
333333
let base_ty =
334-
Place::ty_from(place.local, place.projection, *self.body, self.infcx.tcx)
335-
.ty;
334+
Place::ty_from(place.local, place.projection, self.body, self.infcx.tcx).ty;
336335
self.describe_field_from_ty(&base_ty, field, Some(*variant_index))
337336
}
338337
ProjectionElem::Field(_, field_type) => {
@@ -449,7 +448,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
449448
}) = bbd.terminator
450449
{
451450
if let Some(source) =
452-
BorrowedContentSource::from_call(func.ty(*self.body, tcx), tcx)
451+
BorrowedContentSource::from_call(func.ty(self.body, tcx), tcx)
453452
{
454453
return source;
455454
}
@@ -462,7 +461,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
462461

463462
// If we didn't find an overloaded deref or index, then assume it's a
464463
// built in deref and check the type of the base.
465-
let base_ty = Place::ty_from(deref_base.local, deref_base.projection, *self.body, tcx).ty;
464+
let base_ty = Place::ty_from(deref_base.local, deref_base.projection, self.body, tcx).ty;
466465
if base_ty.is_unsafe_ptr() {
467466
BorrowedContentSource::DerefRawPointer
468467
} else if base_ty.is_mutable_ptr() {

src/librustc_mir/borrow_check/diagnostics/move_errors.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
296296
// Inspect the type of the content behind the
297297
// borrow to provide feedback about why this
298298
// was a move rather than a copy.
299-
let ty = deref_target_place.ty(*self.body, self.infcx.tcx).ty;
299+
let ty = deref_target_place.ty(self.body, self.infcx.tcx).ty;
300300
let upvar_field = self
301301
.prefixes(move_place.as_ref(), PrefixSet::All)
302302
.find_map(|p| self.is_upvar_field_projection(p));
@@ -385,7 +385,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
385385
}
386386
};
387387
if let Ok(snippet) = self.infcx.tcx.sess.source_map().span_to_snippet(span) {
388-
let def_id = match move_place.ty(*self.body, self.infcx.tcx).ty.kind {
388+
let def_id = match move_place.ty(self.body, self.infcx.tcx).ty.kind {
389389
ty::Adt(self_def, _) => self_def.did,
390390
ty::Foreign(def_id)
391391
| ty::FnDef(def_id, _)
@@ -441,7 +441,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
441441
}
442442

443443
if binds_to.is_empty() {
444-
let place_ty = move_from.ty(*self.body, self.infcx.tcx).ty;
444+
let place_ty = move_from.ty(self.body, self.infcx.tcx).ty;
445445
let place_desc = match self.describe_place(move_from.as_ref()) {
446446
Some(desc) => format!("`{}`", desc),
447447
None => "value".to_string(),
@@ -464,7 +464,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
464464
// No binding. Nothing to suggest.
465465
GroupedMoveError::OtherIllegalMove { ref original_path, use_spans, .. } => {
466466
let span = use_spans.var_or_use();
467-
let place_ty = original_path.ty(*self.body, self.infcx.tcx).ty;
467+
let place_ty = original_path.ty(self.body, self.infcx.tcx).ty;
468468
let place_desc = match self.describe_place(original_path.as_ref()) {
469469
Some(desc) => format!("`{}`", desc),
470470
None => "value".to_string(),

src/librustc_mir/borrow_check/diagnostics/mutability_errors.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
5858
projection: [proj_base @ .., ProjectionElem::Field(upvar_index, _)],
5959
} => {
6060
debug_assert!(is_closure_or_generator(
61-
Place::ty_from(local, proj_base, *self.body, self.infcx.tcx).ty
61+
Place::ty_from(local, proj_base, self.body, self.infcx.tcx).ty
6262
));
6363

6464
item_msg = format!("`{}`", access_place_desc.unwrap());
@@ -104,7 +104,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
104104
Place::ty_from(
105105
the_place_err.local,
106106
the_place_err.projection,
107-
*self.body,
107+
self.body,
108108
self.infcx.tcx
109109
)
110110
.ty
@@ -197,7 +197,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
197197

198198
if let Some((span, message)) = annotate_struct_field(
199199
self.infcx.tcx,
200-
Place::ty_from(local, proj_base, *self.body, self.infcx.tcx).ty,
200+
Place::ty_from(local, proj_base, self.body, self.infcx.tcx).ty,
201201
field,
202202
) {
203203
err.span_suggestion(
@@ -273,7 +273,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
273273
projection: [proj_base @ .., ProjectionElem::Field(upvar_index, _)],
274274
} => {
275275
debug_assert!(is_closure_or_generator(
276-
Place::ty_from(local, proj_base, *self.body, self.infcx.tcx).ty
276+
Place::ty_from(local, proj_base, self.body, self.infcx.tcx).ty
277277
));
278278

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

src/librustc_mir/borrow_check/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,7 @@ impl<'cx, 'tcx> dataflow::ResultsVisitor<'cx, 'tcx> for MirBorrowckCtxt<'cx, 'tc
619619
let tcx = self.infcx.tcx;
620620

621621
// Compute the type with accurate region information.
622-
let drop_place_ty = drop_place.ty(*self.body, self.infcx.tcx);
622+
let drop_place_ty = drop_place.ty(self.body, self.infcx.tcx);
623623

624624
// Erase the regions.
625625
let drop_place_ty = self.infcx.tcx.erase_regions(&drop_place_ty).ty;
@@ -871,7 +871,7 @@ impl InitializationRequiringAction {
871871

872872
impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
873873
fn body(&self) -> &'cx Body<'tcx> {
874-
*self.body
874+
self.body
875875
}
876876

877877
/// Checks an access to the given place to see if it is allowed. Examines the set of borrows

src/librustc_mir/borrow_check/prefixes.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ impl<'cx, 'tcx> Iterator for Prefixes<'cx, 'tcx> {
120120
// derefs, except we stop at the deref of a shared
121121
// reference.
122122

123-
let ty = Place::ty_from(cursor.local, proj_base, *self.body, self.tcx).ty;
123+
let ty = Place::ty_from(cursor.local, proj_base, self.body, self.tcx).ty;
124124
match ty.kind {
125125
ty::RawPtr(_) | ty::Ref(_ /*rgn*/, _ /*ty*/, hir::Mutability::Not) => {
126126
// don't continue traversing over derefs of raw pointers or shared

0 commit comments

Comments
 (0)