Skip to content

Commit 538cdef

Browse files
Use & to do deref coercion for ReadOnlyBodyAndCache
1 parent b641e9e commit 538cdef

File tree

19 files changed

+22
-22
lines changed

19 files changed

+22
-22
lines changed

src/librustc_codegen_ssa/mir/analyze.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ pub fn non_ssa_locals<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
2020
let mir = fx.mir;
2121
let mut analyzer = LocalAnalyzer::new(fx);
2222

23-
analyzer.visit_body(*mir);
23+
analyzer.visit_body(&mir);
2424

2525
for (local, decl) in mir.local_decls.iter_enumerated() {
2626
let ty = fx.monomorphize(&decl.ty);

src/librustc_mir/borrow_check/borrow_set.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ impl LocalsStateAtExit {
107107
LocalsStateAtExit::AllAreInvalidated
108108
} else {
109109
let mut has_storage_dead = HasStorageDead(BitSet::new_empty(body.local_decls.len()));
110-
has_storage_dead.visit_body(*body);
110+
has_storage_dead.visit_body(&body);
111111
let mut has_storage_dead_or_moved = has_storage_dead.0;
112112
for move_out in &move_data.moves {
113113
if let Some(index) = move_data.base_local(move_out.path) {

src/librustc_mir/borrow_check/diagnostics/conflict_errors.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1561,7 +1561,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
15611561
}
15621562
}
15631563
let mut visitor = FakeReadCauseFinder { place, cause: None };
1564-
visitor.visit_body(*self.body);
1564+
visitor.visit_body(&self.body);
15651565
match visitor.cause {
15661566
Some(FakeReadCause::ForMatchGuard) => Some("match guard"),
15671567
Some(FakeReadCause::ForIndex) => Some("indexing expression"),

src/librustc_mir/borrow_check/invalidation.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ pub(super) fn generate_invalidates<'tcx>(
3737
body: &body,
3838
dominators,
3939
};
40-
ig.visit_body(*body);
40+
ig.visit_body(&body);
4141
}
4242
}
4343

src/librustc_mir/borrow_check/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -299,8 +299,8 @@ fn do_mir_borrowck<'a, 'tcx>(
299299
}
300300

301301
dataflow::visit_results(
302-
&*body,
303-
traversal::reverse_postorder(&*body).map(|(bb, _)| bb),
302+
&body,
303+
traversal::reverse_postorder(&body).map(|(bb, _)| bb),
304304
&results,
305305
&mut mbcx,
306306
);

src/librustc_mir/borrow_check/type_check/liveness/local_use_map.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ impl LocalUseMap {
8181
live_locals.iter().for_each(|&local| locals_with_use_data[local] = true);
8282

8383
LocalUseMapBuild { local_use_map: &mut local_use_map, elements, locals_with_use_data }
84-
.visit_body(*body);
84+
.visit_body(&body);
8585

8686
local_use_map
8787
}

src/librustc_mir/borrow_check/type_check/liveness/polonius.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ pub(super) fn populate_access_facts(
101101
location_table,
102102
move_data,
103103
};
104-
extractor.visit_body(*body);
104+
extractor.visit_body(&body);
105105

106106
facts.var_dropped_at.extend(
107107
dropped_at.iter().map(|&(local, location)| (local, location_table.mid_index(location))),

src/librustc_mir/borrow_check/type_check/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ fn type_check_internal<'a, 'tcx, R>(
210210
);
211211
let errors_reported = {
212212
let mut verifier = TypeVerifier::new(&mut checker, *body, promoted);
213-
verifier.visit_body(*body);
213+
verifier.visit_body(&body);
214214
verifier.errors_reported
215215
};
216216

@@ -563,7 +563,7 @@ impl<'a, 'b, 'tcx> TypeVerifier<'a, 'b, 'tcx> {
563563

564564
swap_constraints(self);
565565

566-
self.visit_body(*promoted_body);
566+
self.visit_body(&promoted_body);
567567

568568
if !self.errors_reported {
569569
// if verifier failed, don't do further checks to avoid ICEs

src/librustc_mir/borrow_check/used_muts.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
3232
never_initialized_mut_locals: &mut never_initialized_mut_locals,
3333
mbcx: self,
3434
};
35-
visitor.visit_body(*visitor.mbcx.body);
35+
visitor.visit_body(&visitor.mbcx.body);
3636
}
3737

3838
// Take the union of the existed `used_mut` set with those variables we've found were

src/librustc_mir/const_eval/eval_queries.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ pub fn const_eval_raw_provider<'tcx>(
307307
);
308308

309309
let res = ecx.load_mir(cid.instance.def, cid.promoted);
310-
res.and_then(|body| eval_body_using_ecx(&mut ecx, cid, *body))
310+
res.and_then(|body| eval_body_using_ecx(&mut ecx, cid, &body))
311311
.and_then(|place| {
312312
Ok(RawConst { alloc_id: place.ptr.assert_ptr().alloc_id, ty: place.layout.ty })
313313
})

src/librustc_mir/dataflow/impls/storage_liveness.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ impl<'mir, 'tcx> MaybeRequiresStorage<'mir, 'tcx> {
8383
) -> Self {
8484
MaybeRequiresStorage {
8585
body,
86-
borrowed_locals: RefCell::new(ResultsRefCursor::new(*body, borrowed_locals)),
86+
borrowed_locals: RefCell::new(ResultsRefCursor::new(&body, borrowed_locals)),
8787
}
8888
}
8989
}
@@ -250,7 +250,7 @@ impl<'mir, 'tcx> MaybeRequiresStorage<'mir, 'tcx> {
250250
/// Kill locals that are fully moved and have not been borrowed.
251251
fn check_for_move(&self, trans: &mut impl GenKill<Local>, loc: Location) {
252252
let mut visitor = MoveVisitor { trans, borrowed_locals: &self.borrowed_locals };
253-
visitor.visit_location(*self.body, loc);
253+
visitor.visit_location(&self.body, loc);
254254
}
255255
}
256256

src/librustc_mir/monomorphize/collector.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1162,7 +1162,7 @@ fn collect_neighbours<'tcx>(
11621162
debug!("collect_neighbours: {:?}", instance.def_id());
11631163
let body = tcx.instance_mir(instance.def);
11641164

1165-
MirNeighborCollector { tcx, body: &body, output, instance }.visit_body(*body);
1165+
MirNeighborCollector { tcx, body: &body, output, instance }.visit_body(&body);
11661166
}
11671167

11681168
fn def_id_to_string(tcx: TyCtxt<'_>, def_id: DefId) -> String {

src/librustc_mir/transform/check_consts/validation.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ impl Validator<'a, 'mir, 'tcx> {
183183
self.check_op_spanned(ops::Loop, body.span);
184184
}
185185

186-
self.visit_body(*body);
186+
self.visit_body(&body);
187187

188188
// Ensure that the end result is `Sync` in a non-thread local `static`.
189189
let should_check_for_sync =

src/librustc_mir/transform/check_unsafety.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ fn unsafety_check_result(tcx: TyCtxt<'_>, def_id: DefId) -> UnsafetyCheckResult
507507
// mir_built ensures that body has a computed cache, so we don't (and can't) attempt to
508508
// recompute it here.
509509
let body = body.unwrap_read_only();
510-
checker.visit_body(*body);
510+
checker.visit_body(&body);
511511

512512
check_unused_unsafe(tcx, def_id, &checker.used_unsafe, &mut checker.inherited_blocks);
513513
UnsafetyCheckResult {

src/librustc_mir/transform/const_prop.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -778,7 +778,7 @@ impl CanConstProp {
778778
trace!("local {:?} can't be const propagated because it's not a temporary", local);
779779
}
780780
}
781-
cpv.visit_body(*body);
781+
cpv.visit_body(&body);
782782
cpv.can_const_prop
783783
}
784784
}

src/librustc_mir/transform/generator.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ fn locals_live_across_suspend_points(
469469
// Find the MIR locals which do not use StorageLive/StorageDead statements.
470470
// The storage of these locals are always live.
471471
let mut ignored = StorageIgnored(BitSet::new_filled(body.local_decls.len()));
472-
ignored.visit_body(*body);
472+
ignored.visit_body(&body);
473473

474474
// Calculate the MIR locals which have been previously
475475
// borrowed (even if they are still active).

src/librustc_mir/transform/instcombine.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ impl<'tcx> MirPass<'tcx> for InstCombine {
2626
let optimizations = {
2727
let read_only_cache = read_only!(body);
2828
let mut optimization_finder = OptimizationFinder::new(body, tcx);
29-
optimization_finder.visit_body(*read_only_cache);
29+
optimization_finder.visit_body(&read_only_cache);
3030
optimization_finder.optimizations
3131
};
3232

src/librustc_mir/transform/simplify.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ impl<'tcx> MirPass<'tcx> for SimplifyLocals {
309309
let locals = {
310310
let read_only_cache = read_only!(body);
311311
let mut marker = DeclMarker { locals: BitSet::new_empty(body.local_decls.len()), body };
312-
marker.visit_body(*read_only_cache);
312+
marker.visit_body(&read_only_cache);
313313
// Return pointer and arguments are always live
314314
marker.locals.insert(RETURN_PLACE);
315315
for arg in body.args_iter() {

src/librustc_mir/util/def_use.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ impl DefUseAnalysis {
3838
var_debug_info_index: 0,
3939
in_var_debug_info: false,
4040
};
41-
finder.visit_body(*body);
41+
finder.visit_body(&body);
4242
self.info = finder.info
4343
}
4444

0 commit comments

Comments
 (0)