]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc_middle/mir/mod.rs
Add MirPass to collect Unevaluated consts in MIR body
[rust.git] / src / librustc_middle / mir / mod.rs
index 489a47b5411f59f620a5ead7168a9f4ea443936c..5ab4689d2acb7540b7ab253416ea4afe42539717 100644 (file)
@@ -156,6 +156,9 @@ pub struct Body<'tcx> {
     /// A span representing this MIR, for error reporting.
     pub span: Span,
 
+    /// Unevaluated consts to evaluate them regardless of being optimized out
+    pub uneval_consts: Vec<Constant<'tcx>>,
+
     /// The user may be writing e.g. &[(SOME_CELL, 42)][i].1 and this would get promoted, because
     /// we'd statically know that no thing with interior mutability will ever be available to the
     /// user without some serious unsafe code.  Now this means that our promoted is actually
@@ -203,6 +206,7 @@ pub fn new(
             spread_arg: None,
             var_debug_info,
             span,
+            uneval_consts: Vec::new(),
             ignore_interior_mut_in_const_validation: false,
             control_flow_destroyed,
             predecessor_cache: PredecessorCache::new(),
@@ -227,6 +231,7 @@ pub fn new_cfg_only(basic_blocks: IndexVec<BasicBlock, BasicBlockData<'tcx>>) ->
             arg_count: 0,
             spread_arg: None,
             span: DUMMY_SP,
+            uneval_consts: Vec::new(),
             control_flow_destroyed: Vec::new(),
             generator_kind: None,
             var_debug_info: Vec::new(),