cargo-fmt This utility formats all bin and lib files of the current crate using rustfmt. USAGE: cargo fmt [OPTIONS] [-- ...] ARGS: ... Options passed to rustfmt OPTIONS: --all Format all packages, and also their local path-based dependencies --check Run rustfmt in check mode -h, --help Print help information --manifest-path Specify path to Cargo.toml --message-format Specify message-format: short|json|human -p, --package ... Specify package to format -q, --quiet No output printed to stdout -v, --verbose Use verbose output --version Print rustfmt version and exit Diff in /corp/projects/trentonio/rust-psa-crypto/psa-crypto-sys/build/bindgen.rs at line 19: impl bindgen::callbacks::ParseCallbacks for MbedtlsParseCallbacks { fn item_name(&self, original_item_name: &str) -> Option { - Some(original_item_name.trim_start_matches("mbedtls_").trim_start_matches("MBEDTLS_").to_owned()) (B+ Some( (B+ original_item_name (B+ .trim_start_matches("mbedtls_") (B+ .trim_start_matches("MBEDTLS_") (B+ .to_owned(), (B+ ) (B } fn enum_variant_name( Diff in /corp/projects/trentonio/rust-psa-crypto/psa-crypto-sys/build/bindgen.rs at line 26: &self, _enum_name: Option<&str>, original_variant_name: &str, - _variant_value: bindgen::callbacks::EnumVariantValue (B+ _variant_value: bindgen::callbacks::EnumVariantValue, (B ) -> Option { self.item_name(original_variant_name) } Diff in /corp/projects/trentonio/rust-psa-crypto/psa-crypto-sys/build/bindgen.rs at line 39: } } - fn blocklisted_type_implements_trait(&self, _name: &str, derive_trait: bindgen::callbacks::DeriveTrait) -> Option { (B+ fn blocklisted_type_implements_trait( (B+ &self, (B+ _name: &str, (B+ derive_trait: bindgen::callbacks::DeriveTrait, (B+ ) -> Option { (B if derive_trait == bindgen::callbacks::DeriveTrait::Default { Some(bindgen::callbacks::ImplementsTrait::Manually) } else { Diff in /corp/projects/trentonio/rust-psa-crypto/psa-crypto-sys/build/bindgen.rs at line 53: fn generate_deprecated_union_accessors(bindings: &str) -> String { #[derive(Default)] struct UnionImplBuilder { - impls: String (B+ impls: String, (B } impl<'ast> syn::visit::Visit<'ast> for UnionImplBuilder { Diff in /corp/projects/trentonio/rust-psa-crypto/psa-crypto-sys/build/bindgen.rs at line 60: fn visit_item_union(&mut self, i: &'ast syn::ItemUnion) { let union_name = &i.ident; - let field_name = i.fields.named.iter().map(|field| field.ident.as_ref().unwrap()); (B+ let field_name = i (B+ .fields (B+ .named (B+ .iter() (B+ .map(|field| field.ident.as_ref().unwrap()); (B let field_type = i.fields.named.iter().map(|field| &field.ty); - write!(self.impls, "{}", quote::quote! { (B- impl #union_name { (B- #( (B- #[deprecated] (B- pub unsafe fn #field_name(&mut self) -> *mut #field_type { (B- &mut self.#field_name (B- } (B- )* (B+ write!( (B+ self.impls, (B+ "{}", (B+ quote::quote! { (B+ impl #union_name { (B+ #( (B+ #[deprecated] (B+ pub unsafe fn #field_name(&mut self) -> *mut #field_type { (B+ &mut self.#field_name (B+ } (B+ )* (B+ } (B } - }).unwrap(); (B+ ) (B+ .unwrap(); (B } } Diff in /corp/projects/trentonio/rust-psa-crypto/psa-crypto-sys/build/bindgen.rs at line 88: } let mut cc = cc::Build::new(); - cc.include(&self.mbedtls_include) (B- .flag(&format!( (B+ cc.include(&self.mbedtls_include).flag(&format!( (B "-DMBEDTLS_CONFIG_FILE=\"{}\"", self.config_h.to_str().expect("config.h UTF-8 error") )); Diff in /corp/projects/trentonio/rust-psa-crypto/psa-crypto-sys/build/bindgen.rs at line 151: f.write_all(union_impls.as_bytes())?; f.write_all(b"use crate::mbedtls::types::*;\n")?; // for FILE, time_t, etc. Ok(()) - }).expect("bindings.rs I/O error"); (B+ }) (B+ .expect("bindings.rs I/O error"); (B let mod_bindings = self.out_dir.join("mod-bindings.rs"); fs::write(mod_bindings, b"mod bindings;\n").expect("mod-bindings.rs I/O error"); Diff in /corp/projects/trentonio/rust-psa-crypto/psa-crypto-sys/build/build.rs at line 33: mod config; mod features; mod headers; +mod mbedtls; (B #[path = "bindgen.rs"] mod mod_bindgen; -mod mbedtls; (B #[macro_use] extern crate lazy_static; Diff in /corp/projects/trentonio/rust-psa-crypto/psa-crypto-sys/build/build.rs at line 194: } use std::process::Command; - Command::new("git").args(&["clone", "-c", "advice.detachedHead=false", (B- mbedtls_dir, mbed_build_path]).status()?; (B+ Command::new("git") (B+ .args(&[ (B+ "clone", (B+ "-c", (B+ "advice.detachedHead=false", (B+ mbedtls_dir, (B+ mbed_build_path, (B+ ]) (B+ .status()?; (B match arch.as_str() { "xtensa-esp32-none-elf" => { Command::new("cp").args(&["xtensa.mk", &out_dir]).status()?; Diff in /corp/projects/trentonio/rust-psa-crypto/psa-crypto-sys/build/build.rs at line 202: - Command::new("make").args(&["-C", &mbed_build_path, (B- "-f", "../xtensa.mk"]).status()?; (B- }, (B+ Command::new("make") (B+ .args(&["-C", &mbed_build_path, "-f", "../xtensa.mk"]) (B+ .status()?; (B+ } (B "i686-unknown-linux-gnu" => { - Command::new("make").args(&["-C", mbed_build_path, "lib", (B- "-j", "CFLAGS=-O2 -m32 -DMBEDTLS_USE_PSA_CRYPTO=1", (B- "LDFLAGS=-m32"]).status()?; (B- }, (B+ Command::new("make") (B+ .args(&[ (B+ "-C", (B+ mbed_build_path, (B+ "lib", (B+ "-j", (B+ "CFLAGS=-O2 -m32 -DMBEDTLS_USE_PSA_CRYPTO=1", (B+ "LDFLAGS=-m32", (B+ ]) (B+ .status()?; (B+ } (B _ => { - Command::new("make").args(&["-C", mbed_build_path, "lib", (B- "-j", "CFLAGS=-O2 -DMBEDTLS_USE_PSA_CRYPTO=1"]).status()?; (B- }, (B+ Command::new("make") (B+ .args(&[ (B+ "-C", (B+ mbed_build_path, (B+ "lib", (B+ "-j", (B+ "CFLAGS=-O2 -DMBEDTLS_USE_PSA_CRYPTO=1", (B+ ]) (B+ .status()?; (B+ } (B } Ok(PathBuf::from(mbed_build_path)) Diff in /corp/projects/trentonio/rust-psa-crypto/psa-crypto-sys/build/build.rs at line 296: common::compile_shim_library(include) } } + (BDiff in /corp/projects/trentonio/rust-psa-crypto/psa-crypto-sys/build/features.rs at line 32: let have_custom_threading = self.have_feature("custom_threading"); let have_custom_gmtime_r = self.have_feature("custom_gmtime_r"); - if !self.have_feature("std") || (B- env_have_target_cfg("env", "sgx") || (B- env_have_target_cfg("os", "none") { (B- self.with_feature("c_compiler").unwrap().insert("freestanding"); (B- } (B+ if !self.have_feature("std") (B+ || env_have_target_cfg("env", "sgx") (B+ || env_have_target_cfg("os", "none") (B+ { (B+ self.with_feature("c_compiler") (B+ .unwrap() (B+ .insert("freestanding"); (B+ } (B if let Some(components) = self.with_feature("threading") { if !have_custom_threading && env_have_target_cfg("family", "unix") { components.insert("pthread"); Diff in /corp/projects/trentonio/rust-psa-crypto/psa-crypto-sys/build/features.rs at line 64: println!(r#"cargo:rustc-cfg={}_component="{}""#, feature, component); } } - println!("cargo:platform-components={}", (B- self.platform_components.iter().flat_map(|(feature, components)| { (B- components.iter().map(move |component| format!(r#"{}_component={}"#, feature, component)) (B- } ).collect::>().join(",") (B+ println!( (B+ "cargo:platform-components={}", (B+ self.platform_components (B+ .iter() (B+ .flat_map(|(feature, components)| { (B+ components (B+ .iter() (B+ .map(move |component| format!(r#"{}_component={}"#, feature, component)) (B+ }) (B+ .collect::>() (B+ .join(",") (B ); } Diff in /corp/projects/trentonio/rust-psa-crypto/psa-crypto-sys/build/features.rs at line 74: fn with_feature(&mut self, feature: &'static str) -> Option<&mut HashSet<&'static str>> { if self.have_feature(feature) { - Some(self.platform_components.entry(feature).or_insert_with(HashSet::new)) (B+ Some( (B+ self.platform_components (B+ .entry(feature) (B+ .or_insert_with(HashSet::new), (B+ ) (B } else { None } Diff in /corp/projects/trentonio/rust-psa-crypto/psa-crypto-sys/build/features.rs at line 80: } pub fn have_platform_component(&self, feature: &'static str, component: &'static str) -> bool { - self.platform_components.get(feature).map_or(false, |feat| feat.contains(component)) (B+ self.platform_components (B+ .get(feature) (B+ .map_or(false, |feat| feat.contains(component)) (B } pub fn have_feature(&self, feature: &'static str) -> bool { Diff in /corp/projects/trentonio/rust-psa-crypto/psa-crypto-sys/build/features.rs at line 89: } fn env_have_target_cfg(var: &'static str, value: &'static str) -> bool { - let env = format!("CARGO_CFG_TARGET_{}", var).to_uppercase().replace("-", "_"); (B+ let env = format!("CARGO_CFG_TARGET_{}", var) (B+ .to_uppercase() (B+ .replace("-", "_"); (B env::var_os(env).map_or(false, |s| s == value) } Diff in /corp/projects/trentonio/rust-psa-crypto/psa-crypto-sys/build/features.rs at line 96: fn env_have_feature(feature: &'static str) -> bool { - let env = format!("CARGO_FEATURE_{}", feature).to_uppercase().replace("-", "_"); (B+ let env = format!("CARGO_FEATURE_{}", feature) (B+ .to_uppercase() (B+ .replace("-", "_"); (B env::var_os(env).is_some() } Diff in /corp/projects/trentonio/rust-psa-crypto/psa-crypto-sys/build/mbedtls.rs at line 6: * option. This file may not be copied, modified, or distributed except * according to those terms. */ +use crate::config; (B+use crate::features::FEATURES; (B+use crate::headers; (B use std::env; use std::fs::File; use std::io::Write; Diff in /corp/projects/trentonio/rust-psa-crypto/psa-crypto-sys/build/mbedtls.rs at line 12: use std::path::{Path, PathBuf}; -use crate::features::FEATURES; (B-use crate::config; (B-use crate::headers; (B pub struct BuildConfig { pub out_dir: PathBuf, Diff in /corp/projects/trentonio/rust-psa-crypto/psa-crypto-sys/build/mbedtls.rs at line 82: pub fn new() -> Self { let out_dir = PathBuf::from(env::var_os("OUT_DIR").expect("OUT_DIR environment not set?")); let config_h = out_dir.join("config.h"); - let mbedtls_src = PathBuf::from(env::var("RUST_MBEDTLS_SYS_SOURCE").unwrap_or("vendor".to_owned())); (B+ let mbedtls_src = (B+ PathBuf::from(env::var("RUST_MBEDTLS_SYS_SOURCE").unwrap_or("vendor".to_owned())); (B let mbedtls_include = mbedtls_src.join("include"); let mut cflags = vec![]; Diff in /corp/projects/trentonio/rust-psa-crypto/psa-crypto-sys/build/mbedtls.rs at line 102: } } } - (B Diff in /corp/projects/trentonio/rust-psa-crypto/psa-crypto-sys/src/lib.rs at line 8: //! [here](https://developer.arm.com/architectures/security-architectures/platform-security-architecture/documentation). #![cfg_attr(not(feature = "std"), no_std)] - (B // This one is hard to avoid. #![allow(clippy::multiple_crate_versions)] #![allow(clippy::missing_safety_doc)] Diff in /corp/projects/trentonio/rust-psa-crypto/psa-crypto-sys/src/lib.rs at line 29: } mod mbedtls; -pub use mbedtls::{*, types::*}; (B+pub use mbedtls::{types::*, *}; (B mod constants; #[cfg(feature = "interface")] Diff in /corp/projects/trentonio/rust-psa-crypto/psa-crypto-sys/src/mbedtls/mod.rs at line 17: /* This value is defined by a C function macro, something which is not supported by bindgen currently https://github.com/rust-lang-nursery/rust-bindgen/issues/231 */ -pub const ECDSA_MAX_LEN : u32 = 141; (B+pub const ECDSA_MAX_LEN: u32 = 141; (B