From af98bd9a53f575bf755d172b2e64e552c59a5180 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sun, 1 Mar 2020 11:53:34 +0100 Subject: [PATCH 1/2] fix trailing indent in xargo files --- src/bin/cargo-miri.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/bin/cargo-miri.rs b/src/bin/cargo-miri.rs index 17063b6ff67f..88609d4dea63 100644 --- a/src/bin/cargo-miri.rs +++ b/src/bin/cargo-miri.rs @@ -353,7 +353,7 @@ default_features = false features = ["panic_unwind"] [dependencies.test] - "#, +"#, ) .unwrap(); // The boring bits: a dummy project for xargo. @@ -369,7 +369,7 @@ version = "0.0.0" [lib] path = "lib.rs" - "#, +"#, ) .unwrap(); File::create(dir.join("lib.rs")).unwrap(); From 48a4e3f4d89a365dde0e0b257d7af6631d4d69aa Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sun, 1 Mar 2020 11:54:19 +0100 Subject: [PATCH 2/2] format a few things --- src/bin/cargo-miri.rs | 31 ++++++++++++++++--------------- src/bin/miri-rustc-tests.rs | 8 +++++--- src/bin/miri.rs | 2 +- 3 files changed, 22 insertions(+), 19 deletions(-) diff --git a/src/bin/cargo-miri.rs b/src/bin/cargo-miri.rs index 88609d4dea63..f8a408561b0b 100644 --- a/src/bin/cargo-miri.rs +++ b/src/bin/cargo-miri.rs @@ -563,7 +563,8 @@ fn inside_cargo_rustc() { // other args for target crates - that is, crates which are ultimately // going to get interpreted by Miri. if target_crate { - let sysroot = std::env::var("MIRI_SYSROOT").expect("The wrapper should have set MIRI_SYSROOT"); + let sysroot = + std::env::var("MIRI_SYSROOT").expect("The wrapper should have set MIRI_SYSROOT"); args.push("--sysroot".to_owned()); args.push(sysroot); args.splice(0..0, miri::miri_default_args().iter().map(ToString::to_string)); @@ -571,20 +572,20 @@ fn inside_cargo_rustc() { // Figure out the binary we need to call. If this is a runnable target crate, we want to call // Miri to start interpretation; otherwise we want to call rustc to build the crate as usual. - let mut command = - if target_crate && is_runnable_crate() { - // This is the 'target crate' - the binary or test crate that - // we want to interpret under Miri. We deserialize the user-provided arguments - // from the special environment variable "MIRI_ARGS", and feed them - // to the 'miri' binary. - let magic = std::env::var("MIRI_ARGS").expect("missing MIRI_ARGS"); - let mut user_args: Vec = serde_json::from_str(&magic).expect("failed to deserialize MIRI_ARGS"); - args.append(&mut user_args); - // Run this in Miri. - Command::new(find_miri()) - } else { - Command::new("rustc") - }; + let mut command = if target_crate && is_runnable_crate() { + // This is the 'target crate' - the binary or test crate that + // we want to interpret under Miri. We deserialize the user-provided arguments + // from the special environment variable "MIRI_ARGS", and feed them + // to the 'miri' binary. + let magic = std::env::var("MIRI_ARGS").expect("missing MIRI_ARGS"); + let mut user_args: Vec = + serde_json::from_str(&magic).expect("failed to deserialize MIRI_ARGS"); + args.append(&mut user_args); + // Run this in Miri. + Command::new(find_miri()) + } else { + Command::new("rustc") + }; // Run it. command.args(&args); diff --git a/src/bin/miri-rustc-tests.rs b/src/bin/miri-rustc-tests.rs index abda47f75b1c..9cc9901a9134 100644 --- a/src/bin/miri-rustc-tests.rs +++ b/src/bin/miri-rustc-tests.rs @@ -15,11 +15,11 @@ use std::io::Write; use std::path::Path; use std::sync::{Arc, Mutex}; +use rustc::ty::TyCtxt; +use rustc_driver::Compilation; use rustc_hir as hir; use rustc_hir::def_id::LOCAL_CRATE; use rustc_hir::itemlikevisit; -use rustc::ty::TyCtxt; -use rustc_driver::Compilation; use rustc_interface::{interface, Queries}; use miri::MiriConfig; @@ -42,7 +42,9 @@ impl rustc_driver::Callbacks for MiriCompilerCalls { 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.kind { - if i.attrs.iter().any(|attr| attr.check_name(rustc_span::symbol::sym::test)) + if i.attrs + .iter() + .any(|attr| attr.check_name(rustc_span::symbol::sym::test)) { let config = MiriConfig { validate: true, diff --git a/src/bin/miri.rs b/src/bin/miri.rs index 9523609889cd..e69e7f7b6f50 100644 --- a/src/bin/miri.rs +++ b/src/bin/miri.rs @@ -21,8 +21,8 @@ use std::str::FromStr; use hex::FromHexError; -use rustc_hir::def_id::LOCAL_CRATE; use rustc_driver::Compilation; +use rustc_hir::def_id::LOCAL_CRATE; use rustc_interface::{interface, Queries}; struct MiriCompilerCalls {