diff options
| author | Paul Daniel Faria <Nashenas88@users.noreply.github.com> | 2019-10-28 18:16:25 -0400 |
|---|---|---|
| committer | Paul Daniel Faria <Nashenas88@users.noreply.github.com> | 2019-12-02 08:38:16 -0500 |
| commit | 67b7a78231c84f9e864d7074f2fc8f092290873b (patch) | |
| tree | 4d680bf8d0ffedb107f2518fa71e50e2029e5cf6 | |
| parent | 35590b5cc8135b21e8cbb50d059febba5136d41b (diff) | |
Fix tidy errors
26 files changed, 182 insertions, 62 deletions
diff --git a/src/librustc/mir/cache.rs b/src/librustc/mir/cache.rs index 7a52dea787a..204b3d9f7e3 100644 --- a/src/librustc/mir/cache.rs +++ b/src/librustc/mir/cache.rs @@ -43,7 +43,11 @@ macro_rules! get_predecessors { macro_rules! impl_predecessor_locations { ( ( $($pub:ident)? ) $name:ident $($mutability:ident)?) => { - $($pub)? fn $name<'a>(&'a $($mutability)? self, loc: Location, body: &'a Body<'a>) -> impl Iterator<Item = Location> + 'a { + $($pub)? fn $name<'a>( + &'a $($mutability)? self, + loc: Location, + body: &'a Body<'a> + ) -> impl Iterator<Item = Location> + 'a { let if_zero_locations = if loc.statement_index == 0 { let predecessor_blocks = get_predecessors!($($mutability)? self, loc.block, body); let num_predecessor_blocks = predecessor_blocks.len(); @@ -119,7 +123,10 @@ impl Cache { impl_predecessor_locations!(() unwrap_predecessor_locations); #[inline] - pub fn basic_blocks_mut<'a, 'tcx>(&mut self, body: &'a mut Body<'tcx>) -> &'a mut IndexVec<BasicBlock, BasicBlockData<'tcx>> { + pub fn basic_blocks_mut<'a, 'tcx>( + &mut self, + body: &'a mut Body<'tcx> + ) -> &'a mut IndexVec<BasicBlock, BasicBlockData<'tcx>> { debug!("bbm: Clearing predecessors cache for body at: {:?}", body.span.data()); self.invalidate_predecessors(); &mut body.basic_blocks diff --git a/src/librustc/mir/mod.rs b/src/librustc/mir/mod.rs index fdc3adabf0c..1b1c7573484 100644 --- a/src/librustc/mir/mod.rs +++ b/src/librustc/mir/mod.rs @@ -38,7 +38,7 @@ use syntax::symbol::Symbol; use syntax_pos::{Span, DUMMY_SP}; pub use crate::mir::interpret::AssertMessage; -// TODO(nashenas88) Cache only exported for use in librustc_mir/transform/check_unsafety.rs +// FIXME(nashenas88) Cache only exported for use in librustc_mir/transform/check_unsafety.rs pub use crate::mir::cache::{BodyCache, Cache, ReadOnlyBodyCache}; pub use crate::read_only; diff --git a/src/librustc_codegen_ssa/mir/place.rs b/src/librustc_codegen_ssa/mir/place.rs index 281539277cb..0790526e9f9 100644 --- a/src/librustc_codegen_ssa/mir/place.rs +++ b/src/librustc_codegen_ssa/mir/place.rs @@ -591,7 +591,11 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { pub fn monomorphized_place_ty(&self, place_ref: &mir::PlaceRef<'_, 'tcx>) -> Ty<'tcx> { let tcx = self.cx.tcx(); - let place_ty = mir::Place::ty_from(place_ref.base, place_ref.projection, self.mir.body(), tcx); + let place_ty = mir::Place::ty_from( + place_ref.base, + place_ref.projection, + self.mir.body(), + tcx); self.monomorphize(&place_ty.ty) } } diff --git a/src/librustc_mir/borrow_check/borrow_set.rs b/src/librustc_mir/borrow_check/borrow_set.rs index d1af7461f47..1553131c5d6 100644 --- a/src/librustc_mir/borrow_check/borrow_set.rs +++ b/src/librustc_mir/borrow_check/borrow_set.rs @@ -106,7 +106,8 @@ impl LocalsStateAtExit { if locals_are_invalidated_at_exit { LocalsStateAtExit::AllAreInvalidated } else { - let mut has_storage_dead = HasStorageDead(BitSet::new_empty(body_cache.local_decls.len())); + let mut has_storage_dead + = HasStorageDead(BitSet::new_empty(body_cache.local_decls.len())); has_storage_dead.visit_body(body_cache); let mut has_storage_dead_or_moved = has_storage_dead.0; for move_out in &move_data.moves { diff --git a/src/librustc_mir/borrow_check/conflict_errors.rs b/src/librustc_mir/borrow_check/conflict_errors.rs index d9686ac2192..7f2d6a68d02 100644 --- a/src/librustc_mir/borrow_check/conflict_errors.rs +++ b/src/librustc_mir/borrow_check/conflict_errors.rs @@ -205,9 +205,12 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { ); } - let ty = - Place::ty_from(used_place.base, used_place.projection, self.body_cache.body(), self.infcx.tcx) - .ty; + let ty = Place::ty_from( + used_place.base, + used_place.projection, + self.body_cache.body(), + self.infcx.tcx + ).ty; let needs_note = match ty.kind { ty::Closure(id, _) => { let tables = self.infcx.tcx.typeck_tables_of(id); @@ -619,7 +622,12 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { // Define a small closure that we can use to check if the type of a place // is a union. let union_ty = |place_base, place_projection| { - let ty = Place::ty_from(place_base, place_projection, self.body_cache.body(), self.infcx.tcx).ty; + let ty = Place::ty_from( + place_base, + place_projection, + self.body_cache.body(), + self.infcx.tcx + ).ty; ty.ty_adt_def().filter(|adt| adt.is_union()).map(|_| ty) }; let describe_place = |place| self.describe_place(place).unwrap_or_else(|| "_".to_owned()); @@ -1174,11 +1182,12 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { }; // FIXME use a better heuristic than Spans - let reference_desc = if return_span == self.body_cache.source_info(borrow.reserve_location).span { - "reference to" - } else { - "value referencing" - }; + let reference_desc + = if return_span == self.body_cache.source_info(borrow.reserve_location).span { + "reference to" + } else { + "value referencing" + }; let (place_desc, note) = if let Some(place_desc) = opt_place_desc { let local_kind = if let Some(local) = borrow.borrowed_place.as_local() { @@ -1623,7 +1632,12 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { StorageDeadOrDrop::LocalStorageDead | StorageDeadOrDrop::BoxedStorageDead => { assert!( - Place::ty_from(&place.base, proj_base, self.body_cache.body(), tcx).ty.is_box(), + Place::ty_from( + &place.base, + proj_base, + self.body_cache.body(), + tcx + ).ty.is_box(), "Drop of value behind a reference or raw pointer" ); StorageDeadOrDrop::BoxedStorageDead @@ -1631,7 +1645,12 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { StorageDeadOrDrop::Destructor(_) => base_access, }, ProjectionElem::Field(..) | ProjectionElem::Downcast(..) => { - let base_ty = Place::ty_from(&place.base, proj_base, self.body_cache.body(), tcx).ty; + let base_ty = Place::ty_from( + &place.base, + proj_base, + self.body_cache.body(), + tcx + ).ty; match base_ty.kind { ty::Adt(def, _) if def.has_dtor(tcx) => { // Report the outermost adt with a destructor @@ -1734,7 +1753,8 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { // Next, look through the rest of the block, checking if we are assigning the // `target` (that is, the place that contains our borrow) to anything. let mut annotated_closure = None; - for stmt in &self.body_cache[location.block].statements[location.statement_index + 1..] { + for stmt in &self.body_cache[location.block].statements[location.statement_index + 1..] + { debug!( "annotate_argument_and_return_for_borrow: target={:?} stmt={:?}", target, stmt diff --git a/src/librustc_mir/borrow_check/error_reporting.rs b/src/librustc_mir/borrow_check/error_reporting.rs index 8267e5c1c4b..3b394f853a7 100644 --- a/src/librustc_mir/borrow_check/error_reporting.rs +++ b/src/librustc_mir/borrow_check/error_reporting.rs @@ -369,8 +369,11 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { }, field) } ProjectionElem::Downcast(_, variant_index) => { - let base_ty = - Place::ty_from(place.base, place.projection, self.body_cache.body(), self.infcx.tcx).ty; + let base_ty = Place::ty_from( + place.base, + place.projection, + self.body_cache.body(), + self.infcx.tcx).ty; self.describe_field_from_ty(&base_ty, field, Some(*variant_index)) } ProjectionElem::Field(_, field_type) => { @@ -498,9 +501,10 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { }, .. }) = bbd.terminator { - if let Some(source) - = BorrowedContentSource::from_call(func.ty(self.body_cache.body(), tcx), tcx) - { + if let Some(source) = BorrowedContentSource::from_call( + func.ty(self.body_cache.body(), tcx), + tcx + ) { return source; } } @@ -512,7 +516,12 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { // If we didn't find an overloaded deref or index, then assume it's a // built in deref and check the type of the base. - let base_ty = Place::ty_from(deref_base.base, deref_base.projection, self.body_cache.body(), tcx).ty; + let base_ty = Place::ty_from( + deref_base.base, + deref_base.projection, + self.body_cache.body(), + tcx + ).ty; if base_ty.is_unsafe_ptr() { BorrowedContentSource::DerefRawPointer } else if base_ty.is_mutable_ptr() { diff --git a/src/librustc_mir/borrow_check/mod.rs b/src/librustc_mir/borrow_check/mod.rs index 426c0190596..1ff26acd361 100644 --- a/src/librustc_mir/borrow_check/mod.rs +++ b/src/librustc_mir/borrow_check/mod.rs @@ -168,7 +168,10 @@ fn do_mir_borrowck<'a, 'tcx>( let free_regions = nll::replace_regions_in_mir(infcx, def_id, param_env, &mut body_cache, &mut promoted); let body_cache = read_only!(body_cache); // no further changes - let promoted: IndexVec<_, _> = promoted.iter_mut().map(|body_cache| read_only!(body_cache)).collect(); + let promoted: IndexVec<_, _> = promoted + .iter_mut() + .map(|body_cache| read_only!(body_cache)) + .collect(); let location_table = &LocationTable::new(&body_cache); @@ -303,7 +306,7 @@ fn do_mir_borrowck<'a, 'tcx>( let mut initial_diag = mbcx.report_conflicting_borrow(location, (&place, span), bk, &borrow); - let scope = mbcx.body.source_info(location).scope; + let scope = mbcx.body_cache.source_info(location).scope; let lint_root = match &mbcx.body_cache.source_scopes[scope].local_data { ClearCrossCrate::Set(data) => data.lint_root, _ => id, @@ -339,7 +342,8 @@ fn do_mir_borrowck<'a, 'tcx>( debug!("mbcx.used_mut: {:?}", mbcx.used_mut); let used_mut = mbcx.used_mut; - for local in mbcx.body_cache.mut_vars_and_args_iter().filter(|local| !used_mut.contains(local)) { + for local in mbcx.body_cache.mut_vars_and_args_iter().filter(|local| !used_mut.contains(local)) + { let local_decl = &mbcx.body_cache.local_decls[local]; let lint_root = match &mbcx.body.source_scopes[local_decl.source_info.scope].local_data { ClearCrossCrate::Set(data) => data.lint_root, diff --git a/src/librustc_mir/borrow_check/mutability_errors.rs b/src/librustc_mir/borrow_check/mutability_errors.rs index feaa5fd3a55..0ec72150d97 100644 --- a/src/librustc_mir/borrow_check/mutability_errors.rs +++ b/src/librustc_mir/borrow_check/mutability_errors.rs @@ -61,8 +61,12 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { projection: [proj_base @ .., ProjectionElem::Field(upvar_index, _)], } => { debug_assert!(is_closure_or_generator( - Place::ty_from(&the_place_err.base, proj_base, self.body_cache.body(), self.infcx.tcx).ty - )); + Place::ty_from( + &the_place_err.base, + proj_base, + self.body_cache.body(), + self.infcx.tcx + ).ty)); item_msg = format!("`{}`", access_place_desc.unwrap()); if self.is_upvar_field_projection(access_place.as_ref()).is_some() { diff --git a/src/librustc_mir/borrow_check/nll/mod.rs b/src/librustc_mir/borrow_check/nll/mod.rs index bf11d348409..519b59304b7 100644 --- a/src/librustc_mir/borrow_check/nll/mod.rs +++ b/src/librustc_mir/borrow_check/nll/mod.rs @@ -298,7 +298,13 @@ pub(in crate::borrow_check) fn compute_regions<'cx, 'tcx>( // We also have a `#[rustc_nll]` annotation that causes us to dump // information - dump_annotation(infcx, body_cache.body(), def_id, ®ioncx, &closure_region_requirements, errors_buffer); + dump_annotation( + infcx, + body_cache.body(), + def_id, + ®ioncx, + &closure_region_requirements, + errors_buffer); (regioncx, polonius_output, closure_region_requirements) } diff --git a/src/librustc_mir/borrow_check/nll/type_check/mod.rs b/src/librustc_mir/borrow_check/nll/type_check/mod.rs index e1750af6693..7200f8d8ae5 100644 --- a/src/librustc_mir/borrow_check/nll/type_check/mod.rs +++ b/src/librustc_mir/borrow_check/nll/type_check/mod.rs @@ -168,8 +168,17 @@ pub(crate) fn type_check<'tcx>( &mut borrowck_context, &universal_region_relations, |mut cx| { - cx.equate_inputs_and_outputs(body_cache.body(), universal_regions, &normalized_inputs_and_output); - liveness::generate(&mut cx, body_cache, elements, flow_inits, move_data, location_table); + cx.equate_inputs_and_outputs( + body_cache.body(), + universal_regions, + &normalized_inputs_and_output); + liveness::generate( + &mut cx, + body_cache, + elements, + flow_inits, + move_data, + location_table); translate_outlives_facts(cx.borrowck_context); }, @@ -535,7 +544,11 @@ impl<'a, 'b, 'tcx> TypeVerifier<'a, 'b, 'tcx> { place_ty } - fn sanitize_promoted(&mut self, promoted_body_cache: ReadOnlyBodyCache<'b, 'tcx>, location: Location) { + fn sanitize_promoted( + &mut self, + promoted_body_cache: ReadOnlyBodyCache<'b, 'tcx>, + location: Location + ) { // Determine the constraints from the promoted MIR by running the type // checker on the promoted MIR, then transfer the constraints back to // the main MIR, changing the locations to the provided location. diff --git a/src/librustc_mir/dataflow/impls/storage_liveness.rs b/src/librustc_mir/dataflow/impls/storage_liveness.rs index fc344f9b252..3f76d0e3a3c 100644 --- a/src/librustc_mir/dataflow/impls/storage_liveness.rs +++ b/src/librustc_mir/dataflow/impls/storage_liveness.rs @@ -87,7 +87,9 @@ impl<'mir, 'tcx: 'mir> RequiresStorage<'mir, 'tcx> { ) -> Self { RequiresStorage { body_cache, - borrowed_locals: RefCell::new(DataflowResultsCursor::new(borrowed_locals, body_cache.body())), + borrowed_locals: RefCell::new( + DataflowResultsCursor::new(borrowed_locals, body_cache.body()) + ), } } diff --git a/src/librustc_mir/shim.rs b/src/librustc_mir/shim.rs index 0f91b8b28bc..9b54c66e1e5 100644 --- a/src/librustc_mir/shim.rs +++ b/src/librustc_mir/shim.rs @@ -165,7 +165,9 @@ fn local_decls_for_sig<'tcx>(sig: &ty::FnSig<'tcx>, span: Span) .collect() } -fn build_drop_shim<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId, ty: Option<Ty<'tcx>>) -> BodyCache<'tcx> { +fn build_drop_shim<'tcx>( + tcx: TyCtxt<'tcx>, def_id: DefId, ty: Option<Ty<'tcx>> +) -> BodyCache<'tcx> { debug!("build_drop_shim(def_id={:?}, ty={:?})", def_id, ty); // Check if this is a generator, if so, return the drop glue for it diff --git a/src/librustc_mir/transform/add_call_guards.rs b/src/librustc_mir/transform/add_call_guards.rs index 071ad002c16..48aa53a58c9 100644 --- a/src/librustc_mir/transform/add_call_guards.rs +++ b/src/librustc_mir/transform/add_call_guards.rs @@ -31,7 +31,9 @@ pub use self::AddCallGuards::*; */ impl<'tcx> MirPass<'tcx> for AddCallGuards { - fn run_pass(&self, _tcx: TyCtxt<'tcx>, _src: MirSource<'tcx>, body_cache: &mut BodyCache<'tcx>) { + fn run_pass( + &self, _tcx: TyCtxt<'tcx>, _src: MirSource<'tcx>, body_cache: &mut BodyCache<'tcx> + ) { self.add_call_guards(body_cache); } } diff --git a/src/librustc_mir/transform/add_moves_for_packed_drops.rs b/src/librustc_mir/transform/add_moves_for_packed_drops.rs index aebd632978a..21bc679b9a0 100644 --- a/src/librustc_mir/transform/add_moves_for_packed_drops.rs +++ b/src/librustc_mir/transform/add_moves_for_packed_drops.rs @@ -46,7 +46,9 @@ impl<'tcx> MirPass<'tcx> for AddMovesForPackedDrops { } } -pub fn add_moves_for_packed_drops<'tcx>(tcx: TyCtxt<'tcx>, body_cache: &mut BodyCache<'tcx>, def_id: DefId) { +pub fn add_moves_for_packed_drops<'tcx>( + tcx: TyCtxt<'tcx>, body_cache: &mut BodyCache<'tcx>, def_id: DefId +) { let patch = add_moves_for_packed_drops_patch(tcx, body_cache, def_id); patch.apply(body_cache); } diff --git a/src/librustc_mir/transform/cleanup_post_borrowck.rs b/src/librustc_mir/transform/cleanup_post_borrowck.rs index 3ea41816ebe..23ab2c28063 100644 --- a/src/librustc_mir/transform/cleanup_post_borrowck.rs +++ b/src/librustc_mir/transform/cleanup_post_borrowck.rs @@ -29,7 +29,9 @@ pub struct DeleteNonCodegenStatements<'tcx> { } impl<'tcx> MirPass<'tcx> for CleanupNonCodegenStatements { - fn run_pass(&self, tcx: TyCtxt<'tcx>, _source: MirSource<'tcx>, body_cache: &mut BodyCache<'tcx>) { + fn run_pass( + &self, tcx: TyCtxt<'tcx>, _source: MirSource<'tcx>, body_cache: &mut BodyCache<'tcx> + ) { let mut delete = DeleteNonCodegenStatements { tcx }; delete.visit_body(body_cache); } diff --git a/src/librustc_mir/transform/const_prop.rs b/src/librustc_mir/transform/const_prop.rs index ddd9ccbe64a..3ea97ff68fd 100644 --- a/src/librustc_mir/transform/const_prop.rs +++ b/src/librustc_mir/transform/const_prop.rs @@ -42,7 +42,9 @@ const MAX_ALLOC_LIMIT: u64 = 1024; pub struct ConstProp; impl<'tcx> MirPass<'tcx> for ConstProp { - fn run_pass(&self, tcx: TyCtxt<'tcx>, source: MirSource<'tcx>, body_cache: &mut BodyCache<'tcx>) { + fn run_pass( + &self, tcx: TyCtxt<'tcx>, source: MirSource<'tcx>, body_cache: &mut BodyCache<'tcx> + ) { // will be evaluated by miri and produce its errors there if source.promoted.is_some() { return; diff --git a/src/librustc_mir/transform/copy_prop.rs b/src/librustc_mir/transform/copy_prop.rs index decd3f65c81..d2f83eeadeb 100644 --- a/src/librustc_mir/transform/copy_prop.rs +++ b/src/librustc_mir/transform/copy_prop.rs @@ -31,7 +31,9 @@ use crate::util::def_use::DefUseAnalysis; pub struct CopyPropagation; impl<'tcx> MirPass<'tcx> for CopyPropagation { - fn run_pass(&self, tcx: TyCtxt<'tcx>, _source: MirSource<'tcx>, body_cache: &mut BodyCache<'tcx>) { + fn run_pass( + &self, tcx: TyCtxt<'tcx>, _source: MirSource<'tcx>, body_cache: &mut BodyCache<'tcx> + ) { // We only run when the MIR optimization level is > 1. // This avoids a slow pass, and messing up debug info. if tcx.sess.opts.debugging_opts.mir_opt_level <= 1 { @@ -100,7 +102,10 @@ impl<'tcx> MirPass<'tcx> for CopyPropagation { let maybe_action = match operand { Operand::Copy(ref src_place) | Operand::Move(ref src_place) => { - Action::local_copy(&body_cache, &def_use_analysis, src_place) + Action::local_copy( + &body_cache, + &def_use_analysis, + src_place) } Operand::Constant(ref src_constant) => { Action::constant(src_constant) @@ -129,8 +134,8 @@ impl<'tcx> MirPass<'tcx> for CopyPropagation { } } - changed = - action.perform(body_cache, &def_use_analysis, dest_local, location, tcx) || changed; + changed = action.perform(body_cache, &def_use_analysis, dest_local, location, tcx) + || changed; // FIXME(pcwalton): Update the use-def chains to delete the instructions instead of // regenerating the chains. break @@ -273,7 +278,8 @@ impl<'tcx> Action<'tcx> { } // Replace all uses of the destination local with the source local. - def_use_analysis.replace_all_defs_and_uses_with(dest_local, body_cache, src_local, tcx); + def_use_analysis + .replace_all_defs_and_uses_with(dest_local, body_cache, src_local, tcx); // Finally, zap the now-useless assignment instruction. debug!(" Deleting assignment"); diff --git a/src/librustc_mir/transform/deaggregator.rs b/src/librustc_mir/transform/deaggregator.rs index 3d0bf6192dc..5ad034539e0 100644 --- a/src/librustc_mir/transform/deaggregator.rs +++ b/src/librustc_mir/transform/deaggregator.rs @@ -6,7 +6,9 @@ use crate::util::expand_aggregate; pub struct Deaggregator; impl<'tcx> MirPass<'tcx> for Deaggregator { - fn run_pass(&self, tcx: TyCtxt<'tcx>, _source: MirSource<'tcx>, body_cache: &mut BodyCache<'tcx>) { + fn run_pass( + &self, tcx: TyCtxt<'tcx>, _source: MirSource<'tcx>, body_cache: &mut BodyCache<'tcx> + ) { let (basic_blocks, local_decls) = body_cache.basic_blocks_and_local_decls_mut(); let local_decls = &*local_decls; for bb in basic_blocks { diff --git a/src/librustc_mir/transform/dump_mir.rs b/src/librustc_mir/transform/dump_mir.rs index 987f0fde2e3..3dbebf885f7 100644 --- a/src/librustc_mir/transform/dump_mir.rs +++ b/src/librustc_mir/transform/dump_mir.rs @@ -18,8 +18,9 @@ impl<'tcx> MirPass<'tcx> for Marker { Cow::Borrowed(self.0) } - fn run_pass(&self, _tcx: TyCtxt<'tcx>, _source: MirSource<'tcx>, _body_cache: &mut BodyCache<'tcx>) { - } + fn run_pass( + &self, _tcx: TyCtxt<'tcx>, _source: MirSource<'tcx>, _body_cache: &mut BodyCache<'tcx> + ) {} } pub struct Disambiguator { diff --git a/src/librustc_mir/transform/generator.rs b/src/librustc_mir/transform/generator.rs index 343cd8e47b2..c79178dcac7 100644 --- a/src/librustc_mir/transform/generator.rs +++ b/src/librustc_mir/transform/generator.rs @@ -860,7 +860,9 @@ fn insert_switch<'tcx>( } } -fn elaborate_generator_drops<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId, body_cache: &mut BodyCache<'tcx>) { +fn elaborate_generator_drops<'tcx>( + tcx: TyCtxt<'tcx>, def_id: DefId, body_cache: &mut BodyCache<'tcx> +) { use crate::util::elaborate_drops::{elaborate_drop, Unwind}; use crate::util::patch::MirPatch; use crate::shim::DropShimElaborator; @@ -993,7 +995,9 @@ fn create_generator_drop_shim<'tcx>( body_cache } -fn insert_term_block<'tcx>(body_cache: &mut BodyCache<'tcx>, kind: TerminatorKind<'tcx>) -> BasicBlock { +fn insert_term_block<'tcx>( + body_cache: &mut BodyCache<'tcx>, kind: TerminatorKind<'tcx> +) -> BasicBlock { let term_block = BasicBlock::new(body_cache.basic_blocks().len()); let source_info = source_info(body_cache); body_cache.basic_blocks_mut().push(BasicBlockData { @@ -1164,7 +1168,9 @@ where } impl<'tcx> MirPass<'tcx> for StateTransform { - fn run_pass(&self, tcx: TyCtxt<'tcx>, source: MirSource<'tcx>, body_cache: &mut BodyCache<'tcx>) { + fn run_pass( + &self, tcx: TyCtxt<'tcx>, source: MirSource<'tcx>, body_cache: &mut BodyCache<'tcx> + ) { let yield_ty = if let Some(yield_ty) = body_cache.yield_ty { yield_ty } else { diff --git a/src/librustc_mir/transform/inline.rs b/src/librustc_mir/transform/inline.rs index f4f7584bfab..6721982e846 100644 --- a/src/librustc_mir/transform/inline.rs +++ b/src/librustc_mir/transform/inline.rs @@ -38,7 +38,9 @@ struct CallSite<'tcx> { } impl<'tcx> MirPass<'tcx> for Inline { - fn run_pass(&self, tcx: TyCtxt<'tcx>, source: MirSource<'tcx>, body_cache: &mut BodyCache<'tcx>) { + fn run_pass( + &self, tcx: TyCtxt<'tcx>, source: MirSource<'tcx>, body_cache: &mut BodyCache<'tcx> + ) { if tcx.sess.opts.debugging_opts.mir_opt_level >= 2 { Inliner { tcx, source }.run_pass(body_cache); } @@ -136,7 +138,8 @@ impl Inliner<'tcx> { debug!("attempting to inline callsite {:?} - success", callsite); // Add callsites from inlined function - for (bb, bb_data) in caller_body_cache.basic_blocks().iter_enumerated().skip(start) { + for (bb, bb_data) in caller_body_cache.basic_blocks().iter_enumerated().skip(start) + { if let Some(new_callsite) = self.get_valid_function_call(bb, bb_data, caller_body_cache, @@ -543,8 +546,10 @@ impl Inliner<'tcx> { // and the vector is `[closure_ref, tmp0, tmp1, tmp2]`. if tcx.is_closure(callsite.callee) { let mut args = args.into_iter(); - let self_ = self.create_temp_if_necessary(args.next().unwrap(), callsite, caller_body_cache); - let tuple = self.create_temp_if_necessary(args.next().unwrap(), callsite, caller_body_cache); + let self_ + = self.create_temp_if_necessary(args.next().unwrap(), callsite, caller_body_cache); + let tuple + = self.create_temp_if_necessary(args.next().unwrap(), callsite, caller_body_cache); assert!(args.next().is_none()); let tuple = Place::from(tuple); diff --git a/src/librustc_mir/transform/mod.rs b/src/librustc_mir/transform/mod.rs index 6c0badff89e..3b2cea53d1c 100644 --- a/src/librustc_mir/transform/mod.rs +++ b/src/librustc_mir/transform/mod.rs @@ -338,7 +338,7 @@ fn optimized_mir(tcx: TyCtxt<'_>, def_id: DefId) -> &BodyCache<'_> { tcx.arena.alloc(body_cache) } -fn promoted_mir<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> &'tcx IndexVec<Promoted, BodyCache<'tcx>> { +fn promoted_mir(tcx: TyCtxt, def_id: DefId) -> &IndexVec<Promoted, BodyCache> { if tcx.is_constructor(def_id) { return tcx.intern_promoted(IndexVec::new()); } diff --git a/src/librustc_mir/transform/rustc_peek.rs b/src/librustc_mir/transform/rustc_peek.rs index 87fcef69238..6e877d2fb74 100644 --- a/src/librustc_mir/transform/rustc_peek.rs +++ b/src/librustc_mir/transform/rustc_peek.rs @@ -64,10 +64,20 @@ impl<'tcx> MirPass<'tcx> for SanityCheck { sanity_check_via_rustc_peek(tcx, body_cache.body(), def_id, &attributes, &flow_uninits); } if has_rustc_mir_with(&attributes, sym::rustc_peek_definite_init).is_some() { - sanity_check_via_rustc_peek(tcx, body_cache.body(), def_id, &attributes, &flow_def_inits); + sanity_check_via_rustc_peek( + tcx, + body_cache.body(), + def_id, + &attributes, + &flow_def_inits); } if has_rustc_mir_with(&attributes, sym::rustc_peek_indirectly_mutable).is_some() { - sanity_check_via_rustc_peek(tcx, body_cache.body(), def_id, &attributes, &flow_indirectly_mut); + sanity_check_via_rustc_peek( + tcx, + body_cache.body(), + def_id, + &attributes, + &flow_indirectly_mut); } if has_rustc_mir_with(&attributes, sym::stop_after_dataflow).is_some() { tcx.sess.fatal("stop_after_dataflow ended compilation"); diff --git a/src/librustc_mir/transform/simplify.rs b/src/librustc_mir/transform/simplify.rs index e2cf9538f1f..949059f19ae 100644 --- a/src/librustc_mir/transform/simplify.rs +++ b/src/librustc_mir/transform/simplify.rs @@ -56,7 +56,9 @@ impl<'tcx> MirPass<'tcx> for SimplifyCfg { Cow::Borrowed(&self.label) } - fn run_pass(&self, _tcx: TyCtxt<'tcx>, _src: MirSource<'tcx>, body_cache: &mut BodyCache<'tcx>) { + fn run_pass( + &self, _tcx: TyCtxt<'tcx>, _src: MirSource<'tcx>, body_cache: &mut BodyCache<'tcx> + ) { debug!("SimplifyCfg({:?}) - simplifying {:?}", self.label, body_cache.body()); simplify_cfg(body_cache); } @@ -293,7 +295,9 @@ pub fn remove_dead_blocks(body_cache: &mut BodyCache<'_>) { pub struct SimplifyLocals; impl<'tcx> MirPass<'tcx> for SimplifyLocals { - fn run_pass(&self, tcx: TyCtxt<'tcx>, source: MirSource<'tcx>, body_cache: &mut BodyCache<'tcx>) { + fn run_pass( + &self, tcx: TyCtxt<'tcx>, source: MirSource<'tcx>, body_cache: &mut BodyCache<'tcx> + ) { trace!("running SimplifyLocals on {:?}", source); let locals = { let read_only_cache = read_only!(body_cache); diff --git a/src/librustc_mir/transform/uniform_array_move_out.rs b/src/librustc_mir/transform/uniform_array_move_out.rs index 784ccf5a6b6..62a2f269fac 100644 --- a/src/librustc_mir/transform/uniform_array_move_out.rs +++ b/src/librustc_mir/transform/uniform_array_move_out.rs @@ -42,7 +42,8 @@ impl<'tcx> MirPass<'tcx> for UniformArrayMoveOut { let param_env = tcx.param_env(src.def_id()); { let read_only_cache = read_only!(body_cache); - let mut visitor = UniformArrayMoveOutVisitor{ body: body_cache, patch: &mut patch, tcx, param_env}; + let mut visitor + = UniformArrayMoveOutVisitor{ body: body_cache, patch: &mut patch, tcx, param_env}; visitor.visit_body(read_only_cache); } patch.apply(body_cache); @@ -219,8 +220,12 @@ impl<'tcx> MirPass<'tcx> for RestoreSubsliceArrayMoveOut<'tcx> { let opt_src_place = items.first().and_then(|x| *x).map(|x| x.2); let opt_size = opt_src_place.and_then(|src_place| { - let src_ty = - Place::ty_from(src_place.base, src_place.projection, body_cache.body(), tcx).ty; + let src_ty = Place::ty_from( + src_place.base, + src_place.projection, + body_cache.body(), + tcx + ).ty; if let ty::Array(_, ref size_o) = src_ty.kind { size_o.try_eval_usize(tcx, param_env) } else { diff --git a/src/librustc_mir/util/liveness.rs b/src/librustc_mir/util/liveness.rs index 37611561d58..1773dbd2e34 100644 --- a/src/librustc_mir/util/liveness.rs +++ b/src/librustc_mir/util/liveness.rs @@ -83,7 +83,8 @@ pub fn liveness_of_locals( // FIXME(ecstaticmorse): Reverse post-order on the reverse CFG may generate a better iteration // order when cycles are present, but the overhead of computing the reverse CFG may outweigh // any benefits. Benchmark this and find out. - let mut dirty_queue: WorkQueue<BasicBlock> = WorkQueue::with_none(body_cache.basic_blocks().len()); + let mut dirty_queue: WorkQueue<BasicBlock> + = WorkQueue::with_none(body_cache.basic_blocks().len()); for (bb, _) in traversal::postorder(body_cache.body()) { dirty_queue.insert(bb); } |
