Skip to content

Commit

Permalink
Fix tidy
Browse files Browse the repository at this point in the history
  • Loading branch information
wesleywiser committed Aug 22, 2019
1 parent 4d62545 commit 34fe28b
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 15 deletions.
6 changes: 5 additions & 1 deletion src/librustc/query/mod.rs
Expand Up @@ -110,7 +110,11 @@ rustc_queries! {
no_hash
}

query mir_validated(_: DefId) -> (&'tcx Steal<mir::Body<'tcx>>, &'tcx Steal<IndexVec<mir::Promoted, mir::Body<'tcx>>>) {
query mir_validated(_: DefId) ->
(
&'tcx Steal<mir::Body<'tcx>>,
&'tcx Steal<IndexVec<mir::Promoted, mir::Body<'tcx>>>
) {
no_hash
}

Expand Down
1 change: 0 additions & 1 deletion src/librustc_codegen_ssa/mir/place.rs
Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion src/librustc_metadata/decoder.rs
Expand Up @@ -924,7 +924,8 @@ impl<'a, 'tcx> CrateMetadata {
}
}

pub fn maybe_get_promoted_mir(&self, tcx: TyCtxt<'tcx>, id: DefIndex) -> Option<IndexVec<Promoted, Body<'tcx>>> {
pub fn maybe_get_promoted_mir(&self, tcx: TyCtxt<'tcx>, id: DefIndex) ->
Option<IndexVec<Promoted, Body<'tcx>>> {
match self.is_proc_macro(id) {
true => None,
false => self.entry(id).promoted_mir.map(|promoted| promoted.decode((self, tcx)),)
Expand Down
3 changes: 2 additions & 1 deletion src/librustc_metadata/encoder.rs
Expand Up @@ -1060,7 +1060,8 @@ impl EncodeContext<'tcx> {
}
}

fn encode_promoted_mir(&mut self, def_id: DefId) -> Option<Lazy<IndexVec<mir::Promoted, mir::Body<'tcx>>>> {
fn encode_promoted_mir(&mut self, def_id: DefId) ->
Option<Lazy<IndexVec<mir::Promoted, mir::Body<'tcx>>>> {
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);
Expand Down
3 changes: 2 additions & 1 deletion src/librustc_mir/borrow_check/mod.rs
Expand Up @@ -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<Promoted, Body<'tcx>> = 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);

Expand Down
6 changes: 5 additions & 1 deletion src/librustc_mir/borrow_check/nll/renumber.rs
Expand Up @@ -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<Promoted, Body<'tcx>>) {
pub fn renumber_mir<'tcx>(
infcx: &InferCtxt<'_, 'tcx>,
body: &mut Body<'tcx>,
promoted: &mut IndexVec<Promoted, Body<'tcx>>,
) {
debug!("renumber_mir()");
debug!("renumber_mir: body.arg_count={:?}", body.arg_count);

Expand Down
6 changes: 5 additions & 1 deletion src/librustc_mir/borrow_check/nll/type_check/mod.rs
Expand Up @@ -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<Promoted, Body<'tcx>>) -> Self {
fn new(
cx: &'a mut TypeChecker<'b, 'tcx>,
body: &'b Body<'tcx>,
promoted: &'b IndexVec<Promoted, Body<'tcx>>,
) -> Self {
TypeVerifier {
body,
promoted,
Expand Down
9 changes: 5 additions & 4 deletions src/librustc_mir/monomorphize/collector.rs
Expand Up @@ -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) => {},
Expand Down
10 changes: 7 additions & 3 deletions src/librustc_mir/transform/mod.rs
Expand Up @@ -200,7 +200,10 @@ fn mir_const(tcx: TyCtxt<'_>, def_id: DefId) -> &Steal<Body<'_>> {
tcx.alloc_steal_mir(body)
}

fn mir_validated(tcx: TyCtxt<'tcx>, def_id: DefId) -> (&'tcx Steal<Body<'tcx>>, &'tcx Steal<IndexVec<Promoted, Body<'tcx>>>) {
fn mir_validated(
tcx: TyCtxt<'tcx>,
def_id: DefId,
) -> (&'tcx Steal<Body<'tcx>>, &'tcx Steal<IndexVec<Promoted, Body<'tcx>>>) {
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
Expand All @@ -215,8 +218,9 @@ fn mir_validated(tcx: TyCtxt<'tcx>, def_id: DefId) -> (&'tcx Steal<Body<'tcx>>,
&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<'_> {
Expand Down
7 changes: 6 additions & 1 deletion src/librustc_mir/transform/promote_consts.rs
Expand Up @@ -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<Body<'tcx>> {
fn promote_candidate(
mut self,
def_id: DefId,
candidate: Candidate,
next_promoted_id: usize,
) -> Option<Body<'tcx>> {
let mut operand = {
let promoted = &mut self.promoted;
let promoted_id = Promoted::new(next_promoted_id);
Expand Down

0 comments on commit 34fe28b

Please sign in to comment.