Skip to content

Commit

Permalink
enforces Module imports granularity (google#445)
Browse files Browse the repository at this point in the history
  • Loading branch information
kaczmarczyck authored Mar 14, 2022
1 parent ba0c583 commit 7e7d5e3
Show file tree
Hide file tree
Showing 12 changed files with 22 additions and 37 deletions.
6 changes: 2 additions & 4 deletions bootloader/src/registers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,8 @@
use super::bitfields::{
Busy, CryptoMode, HashControl, Interrupts, LliWord1, PaddingConfig, RgfEndianness, Task,
};
use tock_registers::{
register_structs,
registers::{ReadOnly, ReadWrite, WriteOnly},
};
use tock_registers::register_structs;
use tock_registers::registers::{ReadOnly, ReadWrite, WriteOnly};

register_structs! {
pub CryptoCellControlRegisters {
Expand Down
10 changes: 3 additions & 7 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,12 @@

extern crate alloc;

use openssl::bn;
use openssl::ec;
use openssl::nid;
use openssl::{bn, ec, nid};
use sk_cbor::cbor_map;
use std::env;
use std::fs;
use std::fs::File;
use std::io::Read;
use std::io::Write;
use std::io::{Read, Write};
use std::path::Path;
use std::{env, fs};
use uuid::Uuid;

fn main() {
Expand Down
3 changes: 1 addition & 2 deletions examples/crypto_bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ use crypto::{aes256, cbc, ecdsa, rng256, sha256, Hash256};
use libtock_drivers::console::Console;
use libtock_drivers::result::FlexUnwrap;
use libtock_drivers::timer;
use libtock_drivers::timer::Timer;
use libtock_drivers::timer::Timestamp;
use libtock_drivers::timer::{Timer, Timestamp};

libtock_core::stack_size! {0x800}

Expand Down
15 changes: 5 additions & 10 deletions examples/nfct_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ libtock_core::stack_size! {0x4000}

#[cfg(not(feature = "with_nfc"))]
mod example {
use super::Console;
use super::Write;
use super::{Console, Write};

pub fn nfc(console: &mut Console) {
writeln!(console, "NFC feature flag is missing!").unwrap();
Expand All @@ -21,16 +20,12 @@ mod example {

#[cfg(feature = "with_nfc")]
mod example {
use super::Console;
use super::Write;
use super::{Console, Write};
use libtock_core::result::CommandError;
use libtock_drivers::nfc::NfcTag;
use libtock_drivers::nfc::RecvOp;
use libtock_drivers::result::FlexUnwrap;
use libtock_drivers::result::TockError;
use libtock_drivers::nfc::{NfcTag, RecvOp};
use libtock_drivers::result::{FlexUnwrap, TockError};
use libtock_drivers::timer;
use libtock_drivers::timer::Timer;
use libtock_drivers::timer::Timestamp;
use libtock_drivers::timer::{Timer, Timestamp};

#[derive(Copy, Clone, Debug, PartialEq)]
#[allow(clippy::upper_case_acronyms)]
Expand Down
4 changes: 3 additions & 1 deletion libraries/cbor/src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,9 @@ macro_rules! cbor_bytes_lit {
#[cfg(test)]
mod test {
use super::super::values::{SimpleValue, Value};
use alloc::{string::String, vec, vec::Vec};
use alloc::string::String;
use alloc::vec;
use alloc::vec::Vec;

#[test]
fn test_cbor_simple_values() {
Expand Down
3 changes: 2 additions & 1 deletion rustfmt.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use_field_init_shorthand = true
use_try_shorthand = true
edition = "2018"
edition = "2018"
imports_granularity = "Module"
3 changes: 1 addition & 2 deletions src/ctap/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

use super::cbor_read;
use super::customization::{MAX_CREDENTIAL_COUNT_IN_LIST, MAX_LARGE_BLOB_ARRAY_SIZE};
use super::data_formats::{
extract_array, extract_bool, extract_byte_string, extract_map, extract_text_string,
Expand All @@ -23,8 +22,8 @@ use super::data_formats::{
PublicKeyCredentialDescriptor, PublicKeyCredentialParameter, PublicKeyCredentialRpEntity,
PublicKeyCredentialUserEntity, SetMinPinLengthParams,
};
use super::key_material;
use super::status_code::Ctap2StatusCode;
use super::{cbor_read, key_material};
use alloc::string::String;
use alloc::vec::Vec;
use arrayref::array_ref;
Expand Down
3 changes: 1 addition & 2 deletions src/ctap/ctap1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ use crate::ctap::storage;
use crate::env::Env;
use alloc::vec::Vec;
use arrayref::array_ref;
use core::convert::Into;
use core::convert::TryFrom;
use core::convert::{Into, TryFrom};

// For now, they're the same thing with apdu.rs containing the authoritative definition
pub type Ctap1StatusCode = ApduStatusCode;
Expand Down
3 changes: 1 addition & 2 deletions src/ctap/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,10 @@ use alloc::vec::Vec;
use arrayref::array_ref;
use byteorder::{BigEndian, ByteOrder};
use core::convert::TryFrom;
use crypto::ecdsa;
use crypto::hmac::{hmac_256, verify_hmac_256};
use crypto::rng256::Rng256;
use crypto::sha256::Sha256;
use crypto::Hash256;
use crypto::{ecdsa, Hash256};
use embedded_time::duration::Milliseconds;
use sk_cbor as cbor;
use sk_cbor::cbor_map_options;
Expand Down
3 changes: 1 addition & 2 deletions src/ctap/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@ use crate::ctap::data_formats::{
extract_array, extract_text_string, CredentialProtectionPolicy, PublicKeyCredentialSource,
PublicKeyCredentialUserEntity,
};
use crate::ctap::key_material;
use crate::ctap::status_code::Ctap2StatusCode;
use crate::ctap::INITIAL_SIGNATURE_COUNTER;
use crate::ctap::{key_material, INITIAL_SIGNATURE_COUNTER};
use crate::env::Env;
use alloc::string::String;
use alloc::vec;
Expand Down
3 changes: 1 addition & 2 deletions third_party/lang-items/src/allocator.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use crate::util;
use core::alloc::GlobalAlloc;
use core::alloc::Layout;
use core::alloc::{GlobalAlloc, Layout};
#[cfg(any(feature = "debug_allocations", feature = "panic_console"))]
use core::fmt::Write;
use core::ptr;
Expand Down
3 changes: 1 addition & 2 deletions third_party/libtock-drivers/src/usb_ctap_hid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@
#[cfg(feature = "debug_ctap")]
use crate::console::Console;
use crate::result::TockError;
use crate::timer;
use crate::timer::Duration;
use crate::util;
use crate::{timer, util};
use core::cell::Cell;
#[cfg(feature = "debug_ctap")]
use core::fmt::Write;
Expand Down

0 comments on commit 7e7d5e3

Please sign in to comment.