diff --git a/examples/cargo_manifest_dir/external_crate/src/lib.rs b/examples/cargo_manifest_dir/external_crate/src/lib.rs index b462aebe04..d453fdd93a 100644 --- a/examples/cargo_manifest_dir/external_crate/src/lib.rs +++ b/examples/cargo_manifest_dir/external_crate/src/lib.rs @@ -1,4 +1,6 @@ - pub fn get_included_str() -> &'static str { - include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/include/included_file.rs.inc")) + include_str!(concat!( + env!("CARGO_MANIFEST_DIR"), + "/include/included_file.rs.inc" + )) } diff --git a/examples/crate_universe/uses_proc_macro/src/main.rs b/examples/crate_universe/uses_proc_macro/src/main.rs index 90ab63cd60..cb74314db4 100644 --- a/examples/crate_universe/uses_proc_macro/src/main.rs +++ b/examples/crate_universe/uses_proc_macro/src/main.rs @@ -3,7 +3,7 @@ use structopt::StructOpt; #[derive(StructOpt)] struct Opt { #[structopt(long)] - name: String + name: String, } fn main() { diff --git a/examples/fibonacci/benches/fibonacci_bench.rs b/examples/fibonacci/benches/fibonacci_bench.rs index 80aa1a84ce..4a8b721d1d 100644 --- a/examples/fibonacci/benches/fibonacci_bench.rs +++ b/examples/fibonacci/benches/fibonacci_bench.rs @@ -14,8 +14,8 @@ #![feature(test)] -extern crate test; extern crate fibonacci; +extern crate test; use test::Bencher; diff --git a/examples/per_platform_printer/print_windows.rs b/examples/per_platform_printer/print_windows.rs index 2dcd0c693e..b857dcb3e9 100644 --- a/examples/per_platform_printer/print_windows.rs +++ b/examples/per_platform_printer/print_windows.rs @@ -1,3 +1,3 @@ pub fn print() -> String { - "Hello Windows!".to_owned() + "Hello Windows!".to_owned() } diff --git a/test/build_env/src/build.rs b/test/build_env/src/build.rs index 642b1d6f6a..654572a2be 100644 --- a/test/build_env/src/build.rs +++ b/test/build_env/src/build.rs @@ -1,5 +1,11 @@ fn main() { - println!("cargo:rustc-env=CARGO_PKG_NAME_FROM_BUILD_SCRIPT={}", env!("CARGO_PKG_NAME")); - println!("cargo:rustc-env=CARGO_CRATE_NAME_FROM_BUILD_SCRIPT={}", env!("CARGO_CRATE_NAME")); + println!( + "cargo:rustc-env=CARGO_PKG_NAME_FROM_BUILD_SCRIPT={}", + env!("CARGO_PKG_NAME") + ); + println!( + "cargo:rustc-env=CARGO_CRATE_NAME_FROM_BUILD_SCRIPT={}", + env!("CARGO_CRATE_NAME") + ); println!("cargo:rustc-env=HAS_TRAILING_SLASH=foo\\"); } diff --git a/test/build_env/tests/cargo.rs b/test/build_env/tests/cargo.rs index 6caca65cce..2c9d244c2a 100644 --- a/test/build_env/tests/cargo.rs +++ b/test/build_env/tests/cargo.rs @@ -2,7 +2,13 @@ fn cargo_env_vars() { assert_eq!(env!("CARGO_PKG_NAME"), "cargo_env-vars_test"); assert_eq!(env!("CARGO_CRATE_NAME"), "cargo_env_vars_test"); - assert_eq!(env!("CARGO_PKG_NAME_FROM_BUILD_SCRIPT"), "cargo_build_script_env-vars"); - assert_eq!(env!("CARGO_CRATE_NAME_FROM_BUILD_SCRIPT"), "cargo_build_script_env_vars"); + assert_eq!( + env!("CARGO_PKG_NAME_FROM_BUILD_SCRIPT"), + "cargo_build_script_env-vars" + ); + assert_eq!( + env!("CARGO_CRATE_NAME_FROM_BUILD_SCRIPT"), + "cargo_build_script_env_vars" + ); assert_eq!(env!("HAS_TRAILING_SLASH"), "foo\\"); } diff --git a/test/build_env/tests/custom_crate_name.rs b/test/build_env/tests/custom_crate_name.rs index 2700af4730..e80bd89983 100644 --- a/test/build_env/tests/custom_crate_name.rs +++ b/test/build_env/tests/custom_crate_name.rs @@ -1,5 +1,8 @@ #[test] fn cargo_env_vars() { - assert_eq!(env!("CARGO_PKG_NAME"), "cargo-env-vars-custom-crate-name-test"); + assert_eq!( + env!("CARGO_PKG_NAME"), + "cargo-env-vars-custom-crate-name-test" + ); assert_eq!(env!("CARGO_CRATE_NAME"), "custom_crate_name"); } diff --git a/test/build_env/tests/manifest_dir.rs b/test/build_env/tests/manifest_dir.rs index bf80013bd6..422a16c4f5 100644 --- a/test/build_env/tests/manifest_dir.rs +++ b/test/build_env/tests/manifest_dir.rs @@ -1,6 +1,9 @@ #[test] pub fn test_manifest_dir() { - let actual = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/manifest_dir_file.txt")); + let actual = include_str!(concat!( + env!("CARGO_MANIFEST_DIR"), + "/src/manifest_dir_file.txt" + )); let expected = "This file tests that CARGO_MANIFEST_DIR is set for the build environment\n"; assert_eq!(actual, expected); } diff --git a/test/inline_test_with_deps/test_with_srcs/src/lib.rs b/test/inline_test_with_deps/test_with_srcs/src/lib.rs index 526613b39c..da59d95e48 100644 --- a/test/inline_test_with_deps/test_with_srcs/src/lib.rs +++ b/test/inline_test_with_deps/test_with_srcs/src/lib.rs @@ -8,7 +8,7 @@ mod extra; #[cfg(test)] mod tests { - use super::{multiply, extra}; + use super::{extra, multiply}; use dep::example_test_dep_fn; #[test] diff --git a/test/test_env/tests/run.rs b/test/test_env/tests/run.rs index 4353b728bd..1abaa7ab09 100644 --- a/test/test_env/tests/run.rs +++ b/test/test_env/tests/run.rs @@ -1,23 +1,30 @@ #[test] fn run() { let path = env!("CARGO_BIN_EXE_hello-world"); - let output = std::process::Command::new(path).output().expect("Failed to run process"); + let output = std::process::Command::new(path) + .output() + .expect("Failed to run process"); assert_eq!(&b"Hello world\n"[..], output.stdout.as_slice()); // Test the `env` attribute of `rust_test` at run time - assert_eq!(std::env::var("FERRIS_SAYS").unwrap(), "Hello fellow Rustaceans!"); + assert_eq!( + std::env::var("FERRIS_SAYS").unwrap(), + "Hello fellow Rustaceans!" + ); // Test the behavior of `rootpath` and that a binary can be found relative to current_dir - let hello_world_bin = std::path::PathBuf::from(std::env::var_os("HELLO_WORLD_BIN_ROOTPATH").unwrap()); + let hello_world_bin = + std::path::PathBuf::from(std::env::var_os("HELLO_WORLD_BIN_ROOTPATH").unwrap()); assert_eq!( - hello_world_bin.as_path(), + hello_world_bin.as_path(), std::path::Path::new("test/test_env/hello-world"), ); assert!(!hello_world_bin.is_absolute()); assert!(hello_world_bin.exists()); // Ensure `execpath` expanded variables map to real files and have absolute paths - let hello_world_src = std::path::PathBuf::from(std::env::var("HELLO_WORLD_SRC_EXECPATH").unwrap()); + let hello_world_src = + std::path::PathBuf::from(std::env::var("HELLO_WORLD_SRC_EXECPATH").unwrap()); assert!(hello_world_src.is_absolute()); assert!(hello_world_src.exists()); } diff --git a/test/transitive_lib/build.rs b/test/transitive_lib/build.rs index c3e700116c..90b5a12c8f 100644 --- a/test/transitive_lib/build.rs +++ b/test/transitive_lib/build.rs @@ -1,3 +1,3 @@ fn main() { - println!("cargo:rustc-link-lib=alias:shell32"); + println!("cargo:rustc-link-lib=alias:shell32"); } diff --git a/test/unit/cc_info/bin_using_native_dep.rs b/test/unit/cc_info/bin_using_native_dep.rs index 6250ab356b..b128c4f19f 100644 --- a/test/unit/cc_info/bin_using_native_dep.rs +++ b/test/unit/cc_info/bin_using_native_dep.rs @@ -3,4 +3,4 @@ extern "C" { } fn main() { println!("{}", unsafe { native_dep() }) -} \ No newline at end of file +} diff --git a/test/unit/cc_info/foo.rs b/test/unit/cc_info/foo.rs index 9bda8eef2c..20e63e3c2f 100644 --- a/test/unit/cc_info/foo.rs +++ b/test/unit/cc_info/foo.rs @@ -1 +1,3 @@ -pub fn main() { dbg!(42); } \ No newline at end of file +pub fn main() { + dbg!(42); +} diff --git a/test/unit/cc_info/proc_macro.rs b/test/unit/cc_info/proc_macro.rs index 0ab4b9e55c..6a745c6062 100644 --- a/test/unit/cc_info/proc_macro.rs +++ b/test/unit/cc_info/proc_macro.rs @@ -6,4 +6,4 @@ extern "C" { #[proc_macro_derive(UsingNativeDep)] pub fn use_native_dep(_input: TokenStream) -> TokenStream { panic!("done") -} \ No newline at end of file +} diff --git a/test/unit/crate_name/lib.rs b/test/unit/crate_name/lib.rs index e69de29bb2..8b13789179 100644 --- a/test/unit/crate_name/lib.rs +++ b/test/unit/crate_name/lib.rs @@ -0,0 +1 @@ + diff --git a/test/unit/interleaved_cc_info/a.rs b/test/unit/interleaved_cc_info/a.rs index e69de29bb2..8b13789179 100644 --- a/test/unit/interleaved_cc_info/a.rs +++ b/test/unit/interleaved_cc_info/a.rs @@ -0,0 +1 @@ + diff --git a/test/unit/interleaved_cc_info/c.rs b/test/unit/interleaved_cc_info/c.rs index e69de29bb2..8b13789179 100644 --- a/test/unit/interleaved_cc_info/c.rs +++ b/test/unit/interleaved_cc_info/c.rs @@ -0,0 +1 @@ + diff --git a/test/unit/interleaved_cc_info/e.rs b/test/unit/interleaved_cc_info/e.rs index e69de29bb2..8b13789179 100644 --- a/test/unit/interleaved_cc_info/e.rs +++ b/test/unit/interleaved_cc_info/e.rs @@ -0,0 +1 @@ + diff --git a/test/unit/native_deps/bin_using_native_dep.rs b/test/unit/native_deps/bin_using_native_dep.rs index 6250ab356b..b128c4f19f 100644 --- a/test/unit/native_deps/bin_using_native_dep.rs +++ b/test/unit/native_deps/bin_using_native_dep.rs @@ -3,4 +3,4 @@ extern "C" { } fn main() { println!("{}", unsafe { native_dep() }) -} \ No newline at end of file +} diff --git a/test/unit/native_deps/lib_using_native_dep.rs b/test/unit/native_deps/lib_using_native_dep.rs index 1c0a8bcdb0..0e8ddae095 100644 --- a/test/unit/native_deps/lib_using_native_dep.rs +++ b/test/unit/native_deps/lib_using_native_dep.rs @@ -3,4 +3,4 @@ extern "C" { } pub fn use_native_dep() { println!("{}", unsafe { native_dep() }) -} \ No newline at end of file +} diff --git a/test/unit/native_deps/proc_macro_using_native_dep.rs b/test/unit/native_deps/proc_macro_using_native_dep.rs index edbce61f3e..6dcfc228ae 100644 --- a/test/unit/native_deps/proc_macro_using_native_dep.rs +++ b/test/unit/native_deps/proc_macro_using_native_dep.rs @@ -7,4 +7,4 @@ extern "C" { pub fn use_native_dep(_input: TokenStream) -> TokenStream { println!("{}", unsafe { native_dep() }); panic!("done") -} \ No newline at end of file +} diff --git a/test/versioned_dylib/src/main.rs b/test/versioned_dylib/src/main.rs index bff8eda6b8..ee94707219 100644 --- a/test/versioned_dylib/src/main.rs +++ b/test/versioned_dylib/src/main.rs @@ -14,7 +14,7 @@ extern crate libc; -extern { +extern "C" { pub fn return_zero() -> libc::c_int; } @@ -23,10 +23,9 @@ fn main() { println!("Got {} from our shared lib", zero); } - #[cfg(test)] mod test { - extern { + extern "C" { pub fn return_zero() -> libc::c_int; } diff --git a/util/label/label.rs b/util/label/label.rs index bd11a6e404..6b441c58c8 100644 --- a/util/label/label.rs +++ b/util/label/label.rs @@ -255,7 +255,8 @@ mod tests { assert_eq!( analyze("foo//bar"), Err(LabelError( - "foo//bar must be a legal label; '//' cannot appear in the middle of the label.".to_string() + "foo//bar must be a legal label; '//' cannot appear in the middle of the label." + .to_string() )) ); assert_eq!( diff --git a/util/label/label_error.rs b/util/label/label_error.rs index a09d0e8237..b1d71996fd 100644 --- a/util/label/label_error.rs +++ b/util/label/label_error.rs @@ -3,7 +3,7 @@ pub struct LabelError(pub String); impl std::fmt::Display for LabelError { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - write!(f,"{}",self.0) + write!(f, "{}", self.0) } } diff --git a/util/launcher/launcher_main.rs b/util/launcher/launcher_main.rs index 0fe27a47f1..10a2a09ff8 100644 --- a/util/launcher/launcher_main.rs +++ b/util/launcher/launcher_main.rs @@ -1,6 +1,6 @@ use std::collections::BTreeMap; use std::fs::File; -use std::io::{BufReader, BufRead}; +use std::io::{BufRead, BufReader}; use std::path::PathBuf; use std::process::Command; use std::vec::Vec; @@ -11,7 +11,7 @@ use std::os::unix::process::CommandExt; /// This string must match the one found in `_create_test_launcher` const LAUNCHFILES_ENV_PATH: &'static str = ".launchfiles/env"; -/// Load environment variables from a uniquly formatted +/// Load environment variables from a uniquly formatted fn environ() -> BTreeMap { let mut environ = BTreeMap::new(); @@ -21,7 +21,7 @@ fn environ() -> BTreeMap { let env_path = std::env::args().nth(0).expect("arg 0 was not set") + LAUNCHFILES_ENV_PATH; let file = File::open(env_path).expect("Failed to load the environment file"); - // Variables will have the `${pwd}` variable replaced which is rendered by + // Variables will have the `${pwd}` variable replaced which is rendered by // `@rules_rust//rust/private:util.bzl::expand_locations` let pwd = std::env::current_dir().expect("Failed to get current working directory"); let pwd_str = pwd.to_string_lossy(); @@ -35,25 +35,28 @@ fn environ() -> BTreeMap { environ.insert( key.expect("Key is not set"), - line.expect("Failed to read line").replace("${pwd}", &pwd_str), + line.expect("Failed to read line") + .replace("${pwd}", &pwd_str), ); key = None; } - + environ } /// Locate the executable based on the name of the launcher executable fn executable() -> PathBuf { let mut exec_path = std::env::args().nth(0).expect("arg 0 was not set"); - let stem_index = exec_path.rfind(".launcher").expect("This executable should always contain `.launcher`"); + let stem_index = exec_path + .rfind(".launcher") + .expect("This executable should always contain `.launcher`"); // Remove the substring from the exec path for _char in ".launcher".chars() { exec_path.remove(stem_index); } - + PathBuf::from(exec_path) } @@ -67,9 +70,9 @@ fn args() -> Vec { #[cfg(target_family = "unix")] fn exec(environ: BTreeMap, executable: PathBuf, args: Vec) { let error = Command::new(&executable) - .envs(environ.iter()) - .args(args) - .exec(); + .envs(environ.iter()) + .args(args) + .exec(); panic!("Process failed to start: {:?} with {:?}", executable, error) } @@ -79,10 +82,10 @@ fn exec(environ: BTreeMap, executable: PathBuf, args: Vec, executable: PathBuf, args: Vec) { let output = Command::new(executable) - .envs(environ.iter()) - .args(args) - .output() - .expect("Failed to run process"); + .envs(environ.iter()) + .args(args) + .output() + .expect("Failed to run process"); std::process::exit(output.status.code().unwrap_or(1)); }