diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2018-12-13 17:26:22 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-12-13 17:26:22 -0600 |
| commit | 5a45175fe150d49347d665a0716e842ab3c60bcc (patch) | |
| tree | 1802da50fc461b22cea7b5fe7e9c3bf6100d65cc /library/stdarch/crates | |
| parent | 80a3099792351411e7024e26743ea98887477fb6 (diff) | |
| download | rust-5a45175fe150d49347d665a0716e842ab3c60bcc.tar.gz rust-5a45175fe150d49347d665a0716e842ab3c60bcc.zip | |
Run rustfmt on stable, delete rustfmt.toml (#619)
This commit switches CI to running `rustfmt` on the stable compiler (as rustfmt is stable now!). Additionally it deletes `rustfmt.toml` to ensure we're following the same style as the rest of the ecosystem.
Diffstat (limited to 'library/stdarch/crates')
7 files changed, 69 insertions, 102 deletions
diff --git a/library/stdarch/crates/assert-instr-macro/src/lib.rs b/library/stdarch/crates/assert-instr-macro/src/lib.rs index b6375154f5f..43a8b8a7e62 100644 --- a/library/stdarch/crates/assert-instr-macro/src/lib.rs +++ b/library/stdarch/crates/assert-instr-macro/src/lib.rs @@ -19,12 +19,11 @@ use quote::ToTokens; #[proc_macro_attribute] pub fn assert_instr( - attr: proc_macro::TokenStream, item: proc_macro::TokenStream, + attr: proc_macro::TokenStream, + item: proc_macro::TokenStream, ) -> proc_macro::TokenStream { - let invoc = syn::parse::<Invoc>(attr) - .expect("expected #[assert_instr(instr, a = b, ...)]"); - let item = - syn::parse::<syn::Item>(item).expect("must be attached to an item"); + let invoc = syn::parse::<Invoc>(attr).expect("expected #[assert_instr(instr, a = b, ...)]"); + let item = syn::parse::<syn::Item>(item).expect("must be attached to an item"); let func = match item { syn::Item::Fn(ref f) => f, _ => panic!("must be attached to a function"), @@ -36,16 +35,12 @@ pub fn assert_instr( // Disable assert_instr for x86 targets compiled with avx enabled, which // causes LLVM to generate different intrinsics that the ones we are // testing for. - let disable_assert_instr = - std::env::var("STDSIMD_DISABLE_ASSERT_INSTR").is_ok(); + let disable_assert_instr = std::env::var("STDSIMD_DISABLE_ASSERT_INSTR").is_ok(); let instr_str = instr .replace('.', "_") .replace(|c: char| c.is_whitespace(), ""); - let assert_name = syn::Ident::new( - &format!("assert_{}_{}", name, instr_str), - name.span(), - ); + let assert_name = syn::Ident::new(&format!("assert_{}_{}", name, instr_str), name.span()); let shim_name = syn::Ident::new(&format!("{}_shim", name), name.span()); let mut inputs = Vec::new(); let mut input_vals = Vec::new(); @@ -62,8 +57,7 @@ pub fn assert_instr( syn::Pat::Ident(ref i) => &i.ident, _ => panic!("must have bare arguments"), }; - if let Some(&(_, ref tts)) = invoc.args.iter().find(|a| *ident == a.0) - { + if let Some(&(_, ref tts)) = invoc.args.iter().find(|a| *ident == a.0) { input_vals.push(quote! { #tts }); } else { inputs.push(capture); @@ -133,8 +127,7 @@ pub fn assert_instr( } }; // why? necessary now to get tests to work? - let tts: TokenStream = - tts.to_string().parse().expect("cannot parse tokenstream"); + let tts: TokenStream = tts.to_string().parse().expect("cannot parse tokenstream"); let tts: TokenStream = quote! { #item diff --git a/library/stdarch/crates/coresimd/tests/cpu-detection.rs b/library/stdarch/crates/coresimd/tests/cpu-detection.rs index 59591b0fbd3..ccbb9eef1c4 100644 --- a/library/stdarch/crates/coresimd/tests/cpu-detection.rs +++ b/library/stdarch/crates/coresimd/tests/cpu-detection.rs @@ -2,11 +2,7 @@ #![cfg_attr(stdsimd_strict, deny(warnings))] #![cfg_attr( feature = "cargo-clippy", - allow( - clippy::option_unwrap_used, - clippy::print_stdout, - clippy::use_debug - ) + allow(clippy::option_unwrap_used, clippy::print_stdout, clippy::use_debug) )] #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] diff --git a/library/stdarch/crates/simd-test-macro/src/lib.rs b/library/stdarch/crates/simd-test-macro/src/lib.rs index 4c98de41fdf..01f8db29c01 100644 --- a/library/stdarch/crates/simd-test-macro/src/lib.rs +++ b/library/stdarch/crates/simd-test-macro/src/lib.rs @@ -18,7 +18,8 @@ fn string(s: &str) -> TokenTree { #[proc_macro_attribute] pub fn simd_test( - attr: proc_macro::TokenStream, item: proc_macro::TokenStream, + attr: proc_macro::TokenStream, + item: proc_macro::TokenStream, ) -> proc_macro::TokenStream { let tokens = TokenStream::from(attr).into_iter().collect::<Vec<_>>(); if tokens.len() != 3 { @@ -49,16 +50,18 @@ pub fn simd_test( let item = TokenStream::from(item); let name = find_name(item.clone()); - let name: TokenStream = name.to_string().parse().unwrap_or_else(|_| { - panic!("failed to parse name: {}", name.to_string()) - }); + let name: TokenStream = name + .to_string() + .parse() + .unwrap_or_else(|_| panic!("failed to parse name: {}", name.to_string())); - let target = env::var("TARGET") - .expect("TARGET environment variable should be set for rustc"); + let target = env::var("TARGET").expect("TARGET environment variable should be set for rustc"); let mut force_test = false; - let macro_test = match target.split('-').next().unwrap_or_else(|| { - panic!("target triple contained no \"-\": {}", target) - }) { + let macro_test = match target + .split('-') + .next() + .unwrap_or_else(|| panic!("target triple contained no \"-\": {}", target)) + { "i686" | "x86_64" | "i586" => "is_x86_feature_detected", "arm" | "armv7" => "is_arm_feature_detected", "aarch64" => "is_aarch64_feature_detected", diff --git a/library/stdarch/crates/stdsimd-test/src/lib.rs b/library/stdarch/crates/stdsimd-test/src/lib.rs index 4d11b030a4c..94bcd60fa10 100644 --- a/library/stdarch/crates/stdsimd-test/src/lib.rs +++ b/library/stdarch/crates/stdsimd-test/src/lib.rs @@ -36,8 +36,7 @@ cfg_if! { } lazy_static! { - static ref DISASSEMBLY: HashMap<String, Vec<Function>> = - disassemble_myself(); + static ref DISASSEMBLY: HashMap<String, Vec<Function>> = disassemble_myself(); } struct Function { diff --git a/library/stdarch/crates/stdsimd-verify/src/lib.rs b/library/stdarch/crates/stdsimd-verify/src/lib.rs index 256da4b7ca3..db213c80d37 100644 --- a/library/stdarch/crates/stdsimd-verify/src/lib.rs +++ b/library/stdarch/crates/stdsimd-verify/src/lib.rs @@ -64,8 +64,7 @@ pub fn x86_functions(input: TokenStream) -> TokenStream { } }; let instrs = find_instrs(&f.attrs); - let target_feature = if let Some(i) = find_target_feature(&f.attrs) - { + let target_feature = if let Some(i) = find_target_feature(&f.attrs) { quote! { Some(#i) } } else { quote! { None } @@ -92,30 +91,28 @@ pub fn x86_functions(input: TokenStream) -> TokenStream { fn to_type(t: &syn::Type) -> proc_macro2::TokenStream { match *t { - syn::Type::Path(ref p) => { - match extract_path_ident(&p.path).to_string().as_ref() { - "__m128" => quote! { &M128 }, - "__m128d" => quote! { &M128D }, - "__m128i" => quote! { &M128I }, - "__m256" => quote! { &M256 }, - "__m256d" => quote! { &M256D }, - "__m256i" => quote! { &M256I }, - "__m64" => quote! { &M64 }, - "bool" => quote! { &BOOL }, - "f32" => quote! { &F32 }, - "f64" => quote! { &F64 }, - "i16" => quote! { &I16 }, - "i32" => quote! { &I32 }, - "i64" => quote! { &I64 }, - "i8" => quote! { &I8 }, - "u16" => quote! { &U16 }, - "u32" => quote! { &U32 }, - "u64" => quote! { &U64 }, - "u8" => quote! { &U8 }, - "CpuidResult" => quote! { &CPUID }, - s => panic!("unspported type: \"{}\"", s), - } - } + syn::Type::Path(ref p) => match extract_path_ident(&p.path).to_string().as_ref() { + "__m128" => quote! { &M128 }, + "__m128d" => quote! { &M128D }, + "__m128i" => quote! { &M128I }, + "__m256" => quote! { &M256 }, + "__m256d" => quote! { &M256D }, + "__m256i" => quote! { &M256I }, + "__m64" => quote! { &M64 }, + "bool" => quote! { &BOOL }, + "f32" => quote! { &F32 }, + "f64" => quote! { &F64 }, + "i16" => quote! { &I16 }, + "i32" => quote! { &I32 }, + "i64" => quote! { &I64 }, + "i8" => quote! { &I8 }, + "u16" => quote! { &U16 }, + "u32" => quote! { &U32 }, + "u64" => quote! { &U64 }, + "u8" => quote! { &U8 }, + "CpuidResult" => quote! { &CPUID }, + s => panic!("unspported type: \"{}\"", s), + }, syn::Type::Ptr(syn::TypePtr { ref elem, .. }) | syn::Type::Reference(syn::TypeReference { ref elem, .. }) => { let tokens = to_type(&elem); @@ -221,9 +218,7 @@ fn find_target_feature(attrs: &[syn::Attribute]) -> Option<syn::Lit> { syn::NestedMeta::Literal(_) => None, }) .filter_map(|m| match m { - syn::Meta::NameValue(ref i) if i.ident == "enable" => { - Some(i.clone().lit) - } + syn::Meta::NameValue(ref i) if i.ident == "enable" => Some(i.clone().lit), _ => None, }) .next() @@ -249,15 +244,12 @@ struct RustcArgsRequiredConst { } impl syn::parse::Parse for RustcArgsRequiredConst { - #[cfg_attr( - feature = "cargo-clippy", - allow(clippy::cast_possible_truncation) - )] + #[cfg_attr(feature = "cargo-clippy", allow(clippy::cast_possible_truncation))] fn parse(input: syn::parse::ParseStream) -> syn::parse::Result<Self> { let content; parenthesized!(content in input); - let list = syn::punctuated::Punctuated::<syn::LitInt, Token![,]> - ::parse_terminated(&content)?; + let list = + syn::punctuated::Punctuated::<syn::LitInt, Token![,]>::parse_terminated(&content)?; Ok(Self { args: list.into_iter().map(|a| a.value() as usize).collect(), }) diff --git a/library/stdarch/crates/stdsimd-verify/tests/x86-intel.rs b/library/stdarch/crates/stdsimd-verify/tests/x86-intel.rs index 4f6015b99ad..b1d12d10aa5 100644 --- a/library/stdarch/crates/stdsimd-verify/tests/x86-intel.rs +++ b/library/stdarch/crates/stdsimd-verify/tests/x86-intel.rs @@ -125,8 +125,7 @@ fn verify_all_signatures() { let xml = include_bytes!("../x86-intel.xml"); let xml = &xml[..]; - let data: Data = - serde_xml_rs::deserialize(xml).expect("failed to deserialize xml"); + let data: Data = serde_xml_rs::deserialize(xml).expect("failed to deserialize xml"); let mut map = HashMap::new(); for intrinsic in &data.intrinsics { map.entry(&intrinsic.name[..]) @@ -293,10 +292,7 @@ fn matches(rust: &Function, intel: &Intrinsic) -> Result<(), String> { // some extra assertions on our end. } else if !intel.instruction.is_empty() { for instr in rust.instrs { - let asserting = intel - .instruction - .iter() - .any(|a| a.name.starts_with(instr)); + let asserting = intel.instruction.iter().any(|a| a.name.starts_with(instr)); if !asserting { println!( "intel failed to list `{}` as an instruction for `{}`", @@ -329,34 +325,32 @@ fn matches(rust: &Function, intel: &Intrinsic) -> Result<(), String> { if rust.arguments.len() != intel.parameters.len() { bail!("wrong number of arguments on {}", rust.name) } - for (i, (a, b)) in - intel.parameters.iter().zip(rust.arguments).enumerate() - { + for (i, (a, b)) in intel.parameters.iter().zip(rust.arguments).enumerate() { let is_const = rust.required_const.contains(&i); equate(b, &a.type_, &intel.name, is_const)?; } } - let any_i64 = - rust.arguments - .iter() - .cloned() - .chain(rust.ret) - .any(|arg| match *arg { - Type::PrimSigned(64) | Type::PrimUnsigned(64) => true, - _ => false, - }); + let any_i64 = rust + .arguments + .iter() + .cloned() + .chain(rust.ret) + .any(|arg| match *arg { + Type::PrimSigned(64) | Type::PrimUnsigned(64) => true, + _ => false, + }); let any_i64_exempt = match rust.name { // These intrinsics have all been manually verified against Clang's // headers to be available on x86, and the u64 arguments seem // spurious I guess? - "_xsave" | "_xrstor" | "_xsetbv" | "_xgetbv" | "_xsaveopt" - | "_xsavec" | "_xsaves" | "_xrstors" => true, + "_xsave" | "_xrstor" | "_xsetbv" | "_xgetbv" | "_xsaveopt" | "_xsavec" | "_xsaves" + | "_xrstors" => true, // Apparently all of clang/msvc/gcc accept these intrinsics on // 32-bit, so let's do the same - "_mm_set_epi64x" | "_mm_set1_epi64x" | "_mm256_set_epi64x" - | "_mm256_setr_epi64x" | "_mm256_set1_epi64x" => true, + "_mm_set_epi64x" | "_mm_set1_epi64x" | "_mm256_set_epi64x" | "_mm256_setr_epi64x" + | "_mm256_set1_epi64x" => true, // These return a 64-bit argument but they're assembled from other // 32-bit registers, so these work on 32-bit just fine. See #308 for @@ -375,9 +369,7 @@ fn matches(rust: &Function, intel: &Intrinsic) -> Result<(), String> { Ok(()) } -fn equate( - t: &Type, intel: &str, intrinsic: &str, is_const: bool, -) -> Result<(), String> { +fn equate(t: &Type, intel: &str, intrinsic: &str, is_const: bool) -> Result<(), String> { let intel = intel.replace(" *", "*"); let intel = intel.replace(" const*", "*"); let require_const = || { @@ -433,8 +425,7 @@ fn equate( // This is a macro (?) in C which seems to mutate its arguments, but // that means that we're taking pointers to arguments in rust // as we're not exposing it as a macro. - (&Type::Ptr(&Type::M128), "__m128") - if intrinsic == "_MM_TRANSPOSE4_PS" => {} + (&Type::Ptr(&Type::M128), "__m128") if intrinsic == "_MM_TRANSPOSE4_PS" => {} _ => bail!( "failed to equate: `{}` and {:?} for {}", diff --git a/library/stdarch/crates/stdsimd/tests/cpu-detection.rs b/library/stdarch/crates/stdsimd/tests/cpu-detection.rs index 3a8cf30bfa4..636d530ef9a 100644 --- a/library/stdarch/crates/stdsimd/tests/cpu-detection.rs +++ b/library/stdarch/crates/stdsimd/tests/cpu-detection.rs @@ -2,11 +2,7 @@ #![cfg_attr(stdsimd_strict, deny(warnings))] #![cfg_attr( feature = "cargo-clippy", - allow( - clippy::option_unwrap_used, - clippy::use_debug, - clippy::print_stdout - ) + allow(clippy::option_unwrap_used, clippy::use_debug, clippy::print_stdout) )] #[cfg(any( @@ -21,10 +17,7 @@ extern crate stdsimd; #[test] -#[cfg(all( - target_arch = "arm", - any(target_os = "linux", target_os = "android") -))] +#[cfg(all(target_arch = "arm", any(target_os = "linux", target_os = "android")))] fn arm_linux() { println!("neon: {}", is_arm_feature_detected!("neon")); println!("pmull: {}", is_arm_feature_detected!("pmull")); |
