From 34fe28bc67817db6743654f8eef8bbf8244f57bf Mon Sep 17 00:00:00 2001 From: Wesley Wiser Date: Wed, 14 Aug 2019 08:08:17 -0400 Subject: [PATCH] Fix tidy --- src/librustc/query/mod.rs | 6 +++++- src/librustc_codegen_ssa/mir/place.rs | 1 - src/librustc_metadata/decoder.rs | 3 ++- src/librustc_metadata/encoder.rs | 3 ++- src/librustc_mir/borrow_check/mod.rs | 3 ++- src/librustc_mir/borrow_check/nll/renumber.rs | 6 +++++- src/librustc_mir/borrow_check/nll/type_check/mod.rs | 6 +++++- src/librustc_mir/monomorphize/collector.rs | 9 +++++---- src/librustc_mir/transform/mod.rs | 10 +++++++--- src/librustc_mir/transform/promote_consts.rs | 7 ++++++- 10 files changed, 39 insertions(+), 15 deletions(-) diff --git a/src/librustc/query/mod.rs b/src/librustc/query/mod.rs index e1dbaeb5b173d..c4f7ca51f4a7a 100644 --- a/src/librustc/query/mod.rs +++ b/src/librustc/query/mod.rs @@ -110,7 +110,11 @@ rustc_queries! { no_hash } - query mir_validated(_: DefId) -> (&'tcx Steal>, &'tcx Steal>>) { + query mir_validated(_: DefId) -> + ( + &'tcx Steal>, + &'tcx Steal>> + ) { no_hash } diff --git a/src/librustc_codegen_ssa/mir/place.rs b/src/librustc_codegen_ssa/mir/place.rs index f7b94ea134cfc..b08093c3a71eb 100644 --- a/src/librustc_codegen_ssa/mir/place.rs +++ b/src/librustc_codegen_ssa/mir/place.rs @@ -460,7 +460,6 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { }), projection: None, } => { - debug!("promoted={:?}, def_id={:?}, substs={:?}, self_substs={:?}", promoted, def_id, substs, self.instance.substs); let param_env = ty::ParamEnv::reveal_all(); let instance = Instance::new(*def_id, substs.subst(bx.tcx(), self.instance.substs)); debug!("instance: {:?}", instance); diff --git a/src/librustc_metadata/decoder.rs b/src/librustc_metadata/decoder.rs index 128e30be79929..2add8bf918398 100644 --- a/src/librustc_metadata/decoder.rs +++ b/src/librustc_metadata/decoder.rs @@ -924,7 +924,8 @@ impl<'a, 'tcx> CrateMetadata { } } - pub fn maybe_get_promoted_mir(&self, tcx: TyCtxt<'tcx>, id: DefIndex) -> Option>> { + pub fn maybe_get_promoted_mir(&self, tcx: TyCtxt<'tcx>, id: DefIndex) -> + Option>> { match self.is_proc_macro(id) { true => None, false => self.entry(id).promoted_mir.map(|promoted| promoted.decode((self, tcx)),) diff --git a/src/librustc_metadata/encoder.rs b/src/librustc_metadata/encoder.rs index f3863fd788ae0..0b8d2438752fa 100644 --- a/src/librustc_metadata/encoder.rs +++ b/src/librustc_metadata/encoder.rs @@ -1060,7 +1060,8 @@ impl EncodeContext<'tcx> { } } - fn encode_promoted_mir(&mut self, def_id: DefId) -> Option>>> { + fn encode_promoted_mir(&mut self, def_id: DefId) -> + Option>>> { debug!("EncodeContext::encode_promoted_mir({:?})", def_id); if self.tcx.mir_keys(LOCAL_CRATE).contains(&def_id) { let promoted = self.tcx.promoted_mir(def_id); diff --git a/src/librustc_mir/borrow_check/mod.rs b/src/librustc_mir/borrow_check/mod.rs index 33cec78f3dfd5..8ded539e7205a 100644 --- a/src/librustc_mir/borrow_check/mod.rs +++ b/src/librustc_mir/borrow_check/mod.rs @@ -151,7 +151,8 @@ fn do_mir_borrowck<'a, 'tcx>( // will have a lifetime tied to the inference context. let mut body: Body<'tcx> = input_body.clone(); let mut promoted: IndexVec> = input_promoted.clone(); - let free_regions = nll::replace_regions_in_mir(infcx, def_id, param_env, &mut body, &mut promoted); + let free_regions = + nll::replace_regions_in_mir(infcx, def_id, param_env, &mut body, &mut promoted); let body = &body; // no further changes let location_table = &LocationTable::new(body); diff --git a/src/librustc_mir/borrow_check/nll/renumber.rs b/src/librustc_mir/borrow_check/nll/renumber.rs index 4e3ffb7af1601..c6a5c6fdfd0f2 100644 --- a/src/librustc_mir/borrow_check/nll/renumber.rs +++ b/src/librustc_mir/borrow_check/nll/renumber.rs @@ -7,7 +7,11 @@ use rustc_data_structures::indexed_vec::IndexVec; /// Replaces all free regions appearing in the MIR with fresh /// inference variables, returning the number of variables created. -pub fn renumber_mir<'tcx>(infcx: &InferCtxt<'_, 'tcx>, body: &mut Body<'tcx>, promoted: &mut IndexVec>) { +pub fn renumber_mir<'tcx>( + infcx: &InferCtxt<'_, 'tcx>, + body: &mut Body<'tcx>, + promoted: &mut IndexVec>, +) { debug!("renumber_mir()"); debug!("renumber_mir: body.arg_count={:?}", body.arg_count); 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 35dd5b5d7eb19..da1f64b05151b 100644 --- a/src/librustc_mir/borrow_check/nll/type_check/mod.rs +++ b/src/librustc_mir/borrow_check/nll/type_check/mod.rs @@ -384,7 +384,11 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for TypeVerifier<'a, 'b, 'tcx> { } impl<'a, 'b, 'tcx> TypeVerifier<'a, 'b, 'tcx> { - fn new(cx: &'a mut TypeChecker<'b, 'tcx>, body: &'b Body<'tcx>, promoted: &'b IndexVec>) -> Self { + fn new( + cx: &'a mut TypeChecker<'b, 'tcx>, + body: &'b Body<'tcx>, + promoted: &'b IndexVec>, + ) -> Self { TypeVerifier { body, promoted, diff --git a/src/librustc_mir/monomorphize/collector.rs b/src/librustc_mir/monomorphize/collector.rs index 512ace1a4728c..11f9df625285f 100644 --- a/src/librustc_mir/monomorphize/collector.rs +++ b/src/librustc_mir/monomorphize/collector.rs @@ -670,15 +670,16 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirNeighborCollector<'a, 'tcx> { self.output.push(MonoItem::Static(*def_id)); } } - PlaceBase::Static(box Static { kind: StaticKind::Promoted(promoted, substs), def_id, .. }) => { - debug!("collecting promoted(def_id: {:?}, promoted: {:?}, substs: {:?})", def_id, promoted, substs); - debug!("param_substs: {:?}", self.param_substs); + PlaceBase::Static(box Static { + kind: StaticKind::Promoted(promoted, substs), + def_id, + .. + }) => { let param_env = ty::ParamEnv::reveal_all(); let cid = GlobalId { instance: Instance::new(*def_id, substs.subst(self.tcx, self.param_substs)), promoted: Some(*promoted), }; - debug!("cid: {:?}", cid); match self.tcx.const_eval(param_env.and(cid)) { Ok(val) => collect_const(self.tcx, val, substs, self.output), Err(ErrorHandled::Reported) => {}, diff --git a/src/librustc_mir/transform/mod.rs b/src/librustc_mir/transform/mod.rs index a78e78331ee3f..f59ad6bae0298 100644 --- a/src/librustc_mir/transform/mod.rs +++ b/src/librustc_mir/transform/mod.rs @@ -200,7 +200,10 @@ fn mir_const(tcx: TyCtxt<'_>, def_id: DefId) -> &Steal> { tcx.alloc_steal_mir(body) } -fn mir_validated(tcx: TyCtxt<'tcx>, def_id: DefId) -> (&'tcx Steal>, &'tcx Steal>>) { +fn mir_validated( + tcx: TyCtxt<'tcx>, + def_id: DefId, +) -> (&'tcx Steal>, &'tcx Steal>>) { let hir_id = tcx.hir().as_local_hir_id(def_id).unwrap(); if let hir::BodyOwnerKind::Const = tcx.hir().body_owner_kind(hir_id) { // Ensure that we compute the `mir_const_qualif` for constants at @@ -215,8 +218,9 @@ fn mir_validated(tcx: TyCtxt<'tcx>, def_id: DefId) -> (&'tcx Steal>, &qualify_and_promote_pass, &simplify::SimplifyCfg::new("qualify-consts"), ]); - let promoted = qualify_and_promote_pass.promoted.into_inner(); - (tcx.alloc_steal_mir(body), tcx.alloc_steal_promoted(promoted.unwrap_or_else(|| IndexVec::new()))) + let promoted = + qualify_and_promote_pass.promoted.into_inner().unwrap_or_else(|| IndexVec::new()); + (tcx.alloc_steal_mir(body), tcx.alloc_steal_promoted(promoted)) } fn optimized_mir(tcx: TyCtxt<'_>, def_id: DefId) -> &Body<'_> { diff --git a/src/librustc_mir/transform/promote_consts.rs b/src/librustc_mir/transform/promote_consts.rs index cb0ce77d5c014..fd5b6c2a32825 100644 --- a/src/librustc_mir/transform/promote_consts.rs +++ b/src/librustc_mir/transform/promote_consts.rs @@ -295,7 +295,12 @@ impl<'a, 'tcx> Promoter<'a, 'tcx> { new_temp } - fn promote_candidate(mut self, def_id: DefId, candidate: Candidate, next_promoted_id: usize) -> Option> { + fn promote_candidate( + mut self, + def_id: DefId, + candidate: Candidate, + next_promoted_id: usize, + ) -> Option> { let mut operand = { let promoted = &mut self.promoted; let promoted_id = Promoted::new(next_promoted_id);