]> git.lizzy.rs Git - rust.git/commitdiff
Add communicate field to evaluator and fix formatting
authorChristian Poveda <christianpoveda@protonmail.com>
Tue, 6 Aug 2019 20:32:57 +0000 (15:32 -0500)
committerChristian Poveda <christianpoveda@protonmail.com>
Tue, 6 Aug 2019 20:44:44 +0000 (15:44 -0500)
benches/helpers/miri_helper.rs
src/bin/miri-rustc-tests.rs
src/eval.rs
src/machine.rs

index 003c93f7464d7257a69a78269c650bc82aed14fe..5cb938659a6cd8184618d40c80f107a219a077ef 100644 (file)
@@ -25,7 +25,12 @@ fn after_analysis(&mut self, compiler: &interface::Compiler) -> Compilation {
             );
 
             self.bencher.iter(|| {
-                let config = miri::MiriConfig { validate: true, communicate: false, args: vec![], seed: None };
+                let config = miri::MiriConfig {
+                    validate: true,
+                    communicate: false,
+                    args: vec![],
+                    seed: None,
+                };
                 eval_main(tcx, entry_def_id, config);
             });
         });
index a1bc53f69b80050809022a1a30f368f1d3789ee6..0cf171f52e7e60de1439a519d2e39d81768eaa8e 100644 (file)
@@ -48,7 +48,12 @@ impl<'tcx, 'hir> itemlikevisit::ItemLikeVisitor<'hir> for Visitor<'tcx> {
                     fn visit_item(&mut self, i: &'hir hir::Item) {
                         if let hir::ItemKind::Fn(.., body_id) = i.node {
                             if i.attrs.iter().any(|attr| attr.check_name(syntax::symbol::sym::test)) {
-                                let config = MiriConfig { validate: true, communicate: false, args: vec![], seed: None };
+                                let config = MiriConfig {
+                                    validate: true,
+                                    communicate: false,
+                                    args: vec![],
+                                    seed: None,
+                                };
                                 let did = self.0.hir().body_owner_def_id(body_id);
                                 println!("running test: {}", self.0.def_path_debug_str(did));
                                 miri::eval_main(self.0, did, config);
@@ -62,7 +67,12 @@ fn visit_impl_item(&mut self, _impl_item: &'hir hir::ImplItem) {}
                 tcx.hir().krate().visit_all_item_likes(&mut Visitor(tcx));
             } else if let Some((entry_def_id, _)) = tcx.entry_fn(LOCAL_CRATE) {
 
-                let config = MiriConfig { validate: true, communicate: false, args: vec![], seed: None };
+                let config = MiriConfig {
+                    validate: true,
+                    communicate: false,
+                    args: vec![],
+                    seed: None
+                };
                 miri::eval_main(tcx, entry_def_id, config);
 
                 compiler.session().abort_if_errors();
index 681bad01d23cc23d53b4cb625c6433ad12bad992..e80162ec1796dc40a20f9b4aa12398df2c2be85a 100644 (file)
 #[derive(Clone)]
 pub struct MiriConfig {
     pub validate: bool,
+    /// Determines if communication with the host environment is enabled.
     pub communicate: bool,
     pub args: Vec<String>,
 
-    // The seed to use when non-determinism is required (e.g. getrandom())
+    /// The seed to use when non-determinism is required (e.g. getrandom())
     pub seed: Option<u64>,
 }
 
@@ -34,7 +35,7 @@ pub fn create_ecx<'mir, 'tcx: 'mir>(
     let mut ecx = InterpCx::new(
         tcx.at(syntax::source_map::DUMMY_SP),
         ty::ParamEnv::reveal_all(),
-        Evaluator::new(),
+        Evaluator::new(config.communicate),
         MemoryExtra::new(StdRng::seed_from_u64(config.seed.unwrap_or(0)), config.validate),
     );
 
index f2c81c92d3d0043dfbe23d5dffe8748bd527e822..ed9a8a1c46346f320149b1a9e473cbc56e3e124a 100644 (file)
@@ -93,10 +93,13 @@ pub struct Evaluator<'tcx> {
 
     /// TLS state.
     pub(crate) tls: TlsData<'tcx>,
+
+    /// If enabled, the `env_vars` field is populated with the host env vars during initialization.
+    pub(crate) communicate: bool,
 }
 
 impl<'tcx> Evaluator<'tcx> {
-    pub(crate) fn new() -> Self {
+    pub(crate) fn new(communicate: bool) -> Self {
         Evaluator {
             env_vars: HashMap::default(),
             argc: None,
@@ -104,6 +107,7 @@ pub(crate) fn new() -> Self {
             cmd_line: None,
             last_error: 0,
             tls: TlsData::default(),
+            communicate,
         }
     }
 }