]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc_mir/transform/add_call_guards.rs
Rollup merge of #69949 - rust-lang:triagebot-ping-alias, r=Mark-Simulacrum
[rust.git] / src / librustc_mir / transform / add_call_guards.rs
index 35238e2d08a2e4a2547d4a2026bc4409738d05d3..c979b569ec5c7024c63504e275b9c9a4126f1edb 100644 (file)
@@ -1,7 +1,7 @@
-use rustc::ty::TyCtxt;
+use crate::transform::{MirPass, MirSource};
 use rustc::mir::*;
+use rustc::ty::TyCtxt;
 use rustc_index::vec::{Idx, IndexVec};
-use crate::transform::{MirPass, MirSource};
 
 #[derive(PartialEq)]
 pub enum AddCallGuards {
@@ -31,15 +31,13 @@ pub enum AddCallGuards {
  */
 
 impl<'tcx> MirPass<'tcx> for AddCallGuards {
-    fn run_pass(
-        &self, _tcx: TyCtxt<'tcx>, _src: MirSource<'tcx>, body: &mut BodyCache<'tcx>
-    ) {
+    fn run_pass(&self, _tcx: TyCtxt<'tcx>, _src: MirSource<'tcx>, body: &mut BodyAndCache<'tcx>) {
         self.add_call_guards(body);
     }
 }
 
 impl AddCallGuards {
-    pub fn add_call_guards(&self, body: &mut BodyCache<'_>) {
+    pub fn add_call_guards(&self, body: &mut BodyAndCache<'_>) {
         let pred_count: IndexVec<_, _> = body.predecessors().iter().map(|ps| ps.len()).collect();
 
         // We need a place to store the new blocks generated
@@ -50,13 +48,15 @@ pub fn add_call_guards(&self, body: &mut BodyCache<'_>) {
         for block in body.basic_blocks_mut() {
             match block.terminator {
                 Some(Terminator {
-                    kind: TerminatorKind::Call {
-                        destination: Some((_, ref mut destination)),
-                        cleanup,
-                        ..
-                    }, source_info
-                }) if pred_count[*destination] > 1 &&
-                      (cleanup.is_some() || self == &AllCallEdges) =>
+                    kind:
+                        TerminatorKind::Call {
+                            destination: Some((_, ref mut destination)),
+                            cleanup,
+                            ..
+                        },
+                    source_info,
+                }) if pred_count[*destination] > 1
+                    && (cleanup.is_some() || self == &AllCallEdges) =>
                 {
                     // It's a critical edge, break it
                     let call_guard = BasicBlockData {
@@ -64,8 +64,8 @@ pub fn add_call_guards(&self, body: &mut BodyCache<'_>) {
                         is_cleanup: block.is_cleanup,
                         terminator: Some(Terminator {
                             source_info,
-                            kind: TerminatorKind::Goto { target: *destination }
-                        })
+                            kind: TerminatorKind::Goto { target: *destination },
+                        }),
                     };
 
                     // Get the index it will be when inserted into the MIR