]> 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 d1832ebf962a486a255e950338a0fd809129fd74..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,9 +31,7 @@ pub enum AddCallGuards {
  */
 
 impl<'tcx> MirPass<'tcx> for AddCallGuards {
-    fn run_pass(
-        &self, _tcx: TyCtxt<'tcx>, _src: MirSource<'tcx>, body: &mut BodyAndCache<'tcx>
-    ) {
+    fn run_pass(&self, _tcx: TyCtxt<'tcx>, _src: MirSource<'tcx>, body: &mut BodyAndCache<'tcx>) {
         self.add_call_guards(body);
     }
 }
@@ -50,13 +48,15 @@ pub fn add_call_guards(&self, body: &mut BodyAndCache<'_>) {
         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 BodyAndCache<'_>) {
                         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