Skip to content

Commit 67b7a78

Browse files
committed
Fix tidy errors
1 parent 35590b5 commit 67b7a78

26 files changed

+182
-62
lines changed

src/librustc/mir/cache.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,11 @@ macro_rules! get_predecessors {
4343

4444
macro_rules! impl_predecessor_locations {
4545
( ( $($pub:ident)? ) $name:ident $($mutability:ident)?) => {
46-
$($pub)? fn $name<'a>(&'a $($mutability)? self, loc: Location, body: &'a Body<'a>) -> impl Iterator<Item = Location> + 'a {
46+
$($pub)? fn $name<'a>(
47+
&'a $($mutability)? self,
48+
loc: Location,
49+
body: &'a Body<'a>
50+
) -> impl Iterator<Item = Location> + 'a {
4751
let if_zero_locations = if loc.statement_index == 0 {
4852
let predecessor_blocks = get_predecessors!($($mutability)? self, loc.block, body);
4953
let num_predecessor_blocks = predecessor_blocks.len();
@@ -119,7 +123,10 @@ impl Cache {
119123
impl_predecessor_locations!(() unwrap_predecessor_locations);
120124

121125
#[inline]
122-
pub fn basic_blocks_mut<'a, 'tcx>(&mut self, body: &'a mut Body<'tcx>) -> &'a mut IndexVec<BasicBlock, BasicBlockData<'tcx>> {
126+
pub fn basic_blocks_mut<'a, 'tcx>(
127+
&mut self,
128+
body: &'a mut Body<'tcx>
129+
) -> &'a mut IndexVec<BasicBlock, BasicBlockData<'tcx>> {
123130
debug!("bbm: Clearing predecessors cache for body at: {:?}", body.span.data());
124131
self.invalidate_predecessors();
125132
&mut body.basic_blocks

src/librustc/mir/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ use syntax::symbol::Symbol;
3838
use syntax_pos::{Span, DUMMY_SP};
3939

4040
pub use crate::mir::interpret::AssertMessage;
41-
// TODO(nashenas88) Cache only exported for use in librustc_mir/transform/check_unsafety.rs
41+
// FIXME(nashenas88) Cache only exported for use in librustc_mir/transform/check_unsafety.rs
4242
pub use crate::mir::cache::{BodyCache, Cache, ReadOnlyBodyCache};
4343
pub use crate::read_only;
4444

src/librustc_codegen_ssa/mir/place.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,11 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
591591

592592
pub fn monomorphized_place_ty(&self, place_ref: &mir::PlaceRef<'_, 'tcx>) -> Ty<'tcx> {
593593
let tcx = self.cx.tcx();
594-
let place_ty = mir::Place::ty_from(place_ref.base, place_ref.projection, self.mir.body(), tcx);
594+
let place_ty = mir::Place::ty_from(
595+
place_ref.base,
596+
place_ref.projection,
597+
self.mir.body(),
598+
tcx);
595599
self.monomorphize(&place_ty.ty)
596600
}
597601
}

src/librustc_mir/borrow_check/borrow_set.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,8 @@ impl LocalsStateAtExit {
106106
if locals_are_invalidated_at_exit {
107107
LocalsStateAtExit::AllAreInvalidated
108108
} else {
109-
let mut has_storage_dead = HasStorageDead(BitSet::new_empty(body_cache.local_decls.len()));
109+
let mut has_storage_dead
110+
= HasStorageDead(BitSet::new_empty(body_cache.local_decls.len()));
110111
has_storage_dead.visit_body(body_cache);
111112
let mut has_storage_dead_or_moved = has_storage_dead.0;
112113
for move_out in &move_data.moves {

src/librustc_mir/borrow_check/conflict_errors.rs

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -205,9 +205,12 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
205205
);
206206
}
207207

208-
let ty =
209-
Place::ty_from(used_place.base, used_place.projection, self.body_cache.body(), self.infcx.tcx)
210-
.ty;
208+
let ty = Place::ty_from(
209+
used_place.base,
210+
used_place.projection,
211+
self.body_cache.body(),
212+
self.infcx.tcx
213+
).ty;
211214
let needs_note = match ty.kind {
212215
ty::Closure(id, _) => {
213216
let tables = self.infcx.tcx.typeck_tables_of(id);
@@ -619,7 +622,12 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
619622
// Define a small closure that we can use to check if the type of a place
620623
// is a union.
621624
let union_ty = |place_base, place_projection| {
622-
let ty = Place::ty_from(place_base, place_projection, self.body_cache.body(), self.infcx.tcx).ty;
625+
let ty = Place::ty_from(
626+
place_base,
627+
place_projection,
628+
self.body_cache.body(),
629+
self.infcx.tcx
630+
).ty;
623631
ty.ty_adt_def().filter(|adt| adt.is_union()).map(|_| ty)
624632
};
625633
let describe_place = |place| self.describe_place(place).unwrap_or_else(|| "_".to_owned());
@@ -1174,11 +1182,12 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
11741182
};
11751183

11761184
// FIXME use a better heuristic than Spans
1177-
let reference_desc = if return_span == self.body_cache.source_info(borrow.reserve_location).span {
1178-
"reference to"
1179-
} else {
1180-
"value referencing"
1181-
};
1185+
let reference_desc
1186+
= if return_span == self.body_cache.source_info(borrow.reserve_location).span {
1187+
"reference to"
1188+
} else {
1189+
"value referencing"
1190+
};
11821191

11831192
let (place_desc, note) = if let Some(place_desc) = opt_place_desc {
11841193
let local_kind = if let Some(local) = borrow.borrowed_place.as_local() {
@@ -1623,15 +1632,25 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
16231632
StorageDeadOrDrop::LocalStorageDead
16241633
| StorageDeadOrDrop::BoxedStorageDead => {
16251634
assert!(
1626-
Place::ty_from(&place.base, proj_base, self.body_cache.body(), tcx).ty.is_box(),
1635+
Place::ty_from(
1636+
&place.base,
1637+
proj_base,
1638+
self.body_cache.body(),
1639+
tcx
1640+
).ty.is_box(),
16271641
"Drop of value behind a reference or raw pointer"
16281642
);
16291643
StorageDeadOrDrop::BoxedStorageDead
16301644
}
16311645
StorageDeadOrDrop::Destructor(_) => base_access,
16321646
},
16331647
ProjectionElem::Field(..) | ProjectionElem::Downcast(..) => {
1634-
let base_ty = Place::ty_from(&place.base, proj_base, self.body_cache.body(), tcx).ty;
1648+
let base_ty = Place::ty_from(
1649+
&place.base,
1650+
proj_base,
1651+
self.body_cache.body(),
1652+
tcx
1653+
).ty;
16351654
match base_ty.kind {
16361655
ty::Adt(def, _) if def.has_dtor(tcx) => {
16371656
// Report the outermost adt with a destructor
@@ -1734,7 +1753,8 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
17341753
// Next, look through the rest of the block, checking if we are assigning the
17351754
// `target` (that is, the place that contains our borrow) to anything.
17361755
let mut annotated_closure = None;
1737-
for stmt in &self.body_cache[location.block].statements[location.statement_index + 1..] {
1756+
for stmt in &self.body_cache[location.block].statements[location.statement_index + 1..]
1757+
{
17381758
debug!(
17391759
"annotate_argument_and_return_for_borrow: target={:?} stmt={:?}",
17401760
target, stmt

src/librustc_mir/borrow_check/error_reporting.rs

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -369,8 +369,11 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
369369
}, field)
370370
}
371371
ProjectionElem::Downcast(_, variant_index) => {
372-
let base_ty =
373-
Place::ty_from(place.base, place.projection, self.body_cache.body(), self.infcx.tcx).ty;
372+
let base_ty = Place::ty_from(
373+
place.base,
374+
place.projection,
375+
self.body_cache.body(),
376+
self.infcx.tcx).ty;
374377
self.describe_field_from_ty(&base_ty, field, Some(*variant_index))
375378
}
376379
ProjectionElem::Field(_, field_type) => {
@@ -498,9 +501,10 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
498501
},
499502
..
500503
}) = bbd.terminator {
501-
if let Some(source)
502-
= BorrowedContentSource::from_call(func.ty(self.body_cache.body(), tcx), tcx)
503-
{
504+
if let Some(source) = BorrowedContentSource::from_call(
505+
func.ty(self.body_cache.body(), tcx),
506+
tcx
507+
) {
504508
return source;
505509
}
506510
}
@@ -512,7 +516,12 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
512516

513517
// If we didn't find an overloaded deref or index, then assume it's a
514518
// built in deref and check the type of the base.
515-
let base_ty = Place::ty_from(deref_base.base, deref_base.projection, self.body_cache.body(), tcx).ty;
519+
let base_ty = Place::ty_from(
520+
deref_base.base,
521+
deref_base.projection,
522+
self.body_cache.body(),
523+
tcx
524+
).ty;
516525
if base_ty.is_unsafe_ptr() {
517526
BorrowedContentSource::DerefRawPointer
518527
} else if base_ty.is_mutable_ptr() {

src/librustc_mir/borrow_check/mod.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,10 @@ fn do_mir_borrowck<'a, 'tcx>(
168168
let free_regions =
169169
nll::replace_regions_in_mir(infcx, def_id, param_env, &mut body_cache, &mut promoted);
170170
let body_cache = read_only!(body_cache); // no further changes
171-
let promoted: IndexVec<_, _> = promoted.iter_mut().map(|body_cache| read_only!(body_cache)).collect();
171+
let promoted: IndexVec<_, _> = promoted
172+
.iter_mut()
173+
.map(|body_cache| read_only!(body_cache))
174+
.collect();
172175

173176
let location_table = &LocationTable::new(&body_cache);
174177

@@ -303,7 +306,7 @@ fn do_mir_borrowck<'a, 'tcx>(
303306
let mut initial_diag =
304307
mbcx.report_conflicting_borrow(location, (&place, span), bk, &borrow);
305308

306-
let scope = mbcx.body.source_info(location).scope;
309+
let scope = mbcx.body_cache.source_info(location).scope;
307310
let lint_root = match &mbcx.body_cache.source_scopes[scope].local_data {
308311
ClearCrossCrate::Set(data) => data.lint_root,
309312
_ => id,
@@ -339,7 +342,8 @@ fn do_mir_borrowck<'a, 'tcx>(
339342

340343
debug!("mbcx.used_mut: {:?}", mbcx.used_mut);
341344
let used_mut = mbcx.used_mut;
342-
for local in mbcx.body_cache.mut_vars_and_args_iter().filter(|local| !used_mut.contains(local)) {
345+
for local in mbcx.body_cache.mut_vars_and_args_iter().filter(|local| !used_mut.contains(local))
346+
{
343347
let local_decl = &mbcx.body_cache.local_decls[local];
344348
let lint_root = match &mbcx.body.source_scopes[local_decl.source_info.scope].local_data {
345349
ClearCrossCrate::Set(data) => data.lint_root,

src/librustc_mir/borrow_check/mutability_errors.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,12 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
6161
projection: [proj_base @ .., ProjectionElem::Field(upvar_index, _)],
6262
} => {
6363
debug_assert!(is_closure_or_generator(
64-
Place::ty_from(&the_place_err.base, proj_base, self.body_cache.body(), self.infcx.tcx).ty
65-
));
64+
Place::ty_from(
65+
&the_place_err.base,
66+
proj_base,
67+
self.body_cache.body(),
68+
self.infcx.tcx
69+
).ty));
6670

6771
item_msg = format!("`{}`", access_place_desc.unwrap());
6872
if self.is_upvar_field_projection(access_place.as_ref()).is_some() {

src/librustc_mir/borrow_check/nll/mod.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,13 @@ pub(in crate::borrow_check) fn compute_regions<'cx, 'tcx>(
298298

299299
// We also have a `#[rustc_nll]` annotation that causes us to dump
300300
// information
301-
dump_annotation(infcx, body_cache.body(), def_id, &regioncx, &closure_region_requirements, errors_buffer);
301+
dump_annotation(
302+
infcx,
303+
body_cache.body(),
304+
def_id,
305+
&regioncx,
306+
&closure_region_requirements,
307+
errors_buffer);
302308

303309
(regioncx, polonius_output, closure_region_requirements)
304310
}

src/librustc_mir/borrow_check/nll/type_check/mod.rs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,17 @@ pub(crate) fn type_check<'tcx>(
168168
&mut borrowck_context,
169169
&universal_region_relations,
170170
|mut cx| {
171-
cx.equate_inputs_and_outputs(body_cache.body(), universal_regions, &normalized_inputs_and_output);
172-
liveness::generate(&mut cx, body_cache, elements, flow_inits, move_data, location_table);
171+
cx.equate_inputs_and_outputs(
172+
body_cache.body(),
173+
universal_regions,
174+
&normalized_inputs_and_output);
175+
liveness::generate(
176+
&mut cx,
177+
body_cache,
178+
elements,
179+
flow_inits,
180+
move_data,
181+
location_table);
173182

174183
translate_outlives_facts(cx.borrowck_context);
175184
},
@@ -535,7 +544,11 @@ impl<'a, 'b, 'tcx> TypeVerifier<'a, 'b, 'tcx> {
535544
place_ty
536545
}
537546

538-
fn sanitize_promoted(&mut self, promoted_body_cache: ReadOnlyBodyCache<'b, 'tcx>, location: Location) {
547+
fn sanitize_promoted(
548+
&mut self,
549+
promoted_body_cache: ReadOnlyBodyCache<'b, 'tcx>,
550+
location: Location
551+
) {
539552
// Determine the constraints from the promoted MIR by running the type
540553
// checker on the promoted MIR, then transfer the constraints back to
541554
// the main MIR, changing the locations to the provided location.

0 commit comments

Comments
 (0)