enforces Module imports granularity (#445)

This commit is contained in:
kaczmarczyck
2022-03-14 20:44:48 +01:00
committed by GitHub
parent ba0c583617
commit 7e7d5e38a1
12 changed files with 22 additions and 37 deletions

View File

@@ -15,10 +15,8 @@
use super::bitfields::{ use super::bitfields::{
Busy, CryptoMode, HashControl, Interrupts, LliWord1, PaddingConfig, RgfEndianness, Task, Busy, CryptoMode, HashControl, Interrupts, LliWord1, PaddingConfig, RgfEndianness, Task,
}; };
use tock_registers::{ use tock_registers::register_structs;
register_structs, use tock_registers::registers::{ReadOnly, ReadWrite, WriteOnly};
registers::{ReadOnly, ReadWrite, WriteOnly},
};
register_structs! { register_structs! {
pub CryptoCellControlRegisters { pub CryptoCellControlRegisters {

View File

@@ -14,16 +14,12 @@
extern crate alloc; extern crate alloc;
use openssl::bn; use openssl::{bn, ec, nid};
use openssl::ec;
use openssl::nid;
use sk_cbor::cbor_map; use sk_cbor::cbor_map;
use std::env;
use std::fs;
use std::fs::File; use std::fs::File;
use std::io::Read; use std::io::{Read, Write};
use std::io::Write;
use std::path::Path; use std::path::Path;
use std::{env, fs};
use uuid::Uuid; use uuid::Uuid;
fn main() { fn main() {

View File

@@ -24,8 +24,7 @@ use crypto::{aes256, cbc, ecdsa, rng256, sha256, Hash256};
use libtock_drivers::console::Console; use libtock_drivers::console::Console;
use libtock_drivers::result::FlexUnwrap; use libtock_drivers::result::FlexUnwrap;
use libtock_drivers::timer; use libtock_drivers::timer;
use libtock_drivers::timer::Timer; use libtock_drivers::timer::{Timer, Timestamp};
use libtock_drivers::timer::Timestamp;
libtock_core::stack_size! {0x800} libtock_core::stack_size! {0x800}

View File

@@ -11,8 +11,7 @@ libtock_core::stack_size! {0x4000}
#[cfg(not(feature = "with_nfc"))] #[cfg(not(feature = "with_nfc"))]
mod example { mod example {
use super::Console; use super::{Console, Write};
use super::Write;
pub fn nfc(console: &mut Console) { pub fn nfc(console: &mut Console) {
writeln!(console, "NFC feature flag is missing!").unwrap(); writeln!(console, "NFC feature flag is missing!").unwrap();
@@ -21,16 +20,12 @@ mod example {
#[cfg(feature = "with_nfc")] #[cfg(feature = "with_nfc")]
mod example { mod example {
use super::Console; use super::{Console, Write};
use super::Write;
use libtock_core::result::CommandError; use libtock_core::result::CommandError;
use libtock_drivers::nfc::NfcTag; use libtock_drivers::nfc::{NfcTag, RecvOp};
use libtock_drivers::nfc::RecvOp; use libtock_drivers::result::{FlexUnwrap, TockError};
use libtock_drivers::result::FlexUnwrap;
use libtock_drivers::result::TockError;
use libtock_drivers::timer; use libtock_drivers::timer;
use libtock_drivers::timer::Timer; use libtock_drivers::timer::{Timer, Timestamp};
use libtock_drivers::timer::Timestamp;
#[derive(Copy, Clone, Debug, PartialEq)] #[derive(Copy, Clone, Debug, PartialEq)]
#[allow(clippy::upper_case_acronyms)] #[allow(clippy::upper_case_acronyms)]

View File

@@ -363,7 +363,9 @@ macro_rules! cbor_bytes_lit {
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use super::super::values::{SimpleValue, Value}; 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] #[test]
fn test_cbor_simple_values() { fn test_cbor_simple_values() {

View File

@@ -1,3 +1,4 @@
use_field_init_shorthand = true use_field_init_shorthand = true
use_try_shorthand = true use_try_shorthand = true
edition = "2018" edition = "2018"
imports_granularity = "Module"

View File

@@ -12,7 +12,6 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
use super::cbor_read;
use super::customization::{MAX_CREDENTIAL_COUNT_IN_LIST, MAX_LARGE_BLOB_ARRAY_SIZE}; use super::customization::{MAX_CREDENTIAL_COUNT_IN_LIST, MAX_LARGE_BLOB_ARRAY_SIZE};
use super::data_formats::{ use super::data_formats::{
extract_array, extract_bool, extract_byte_string, extract_map, extract_text_string, extract_array, extract_bool, extract_byte_string, extract_map, extract_text_string,
@@ -23,8 +22,8 @@ use super::data_formats::{
PublicKeyCredentialDescriptor, PublicKeyCredentialParameter, PublicKeyCredentialRpEntity, PublicKeyCredentialDescriptor, PublicKeyCredentialParameter, PublicKeyCredentialRpEntity,
PublicKeyCredentialUserEntity, SetMinPinLengthParams, PublicKeyCredentialUserEntity, SetMinPinLengthParams,
}; };
use super::key_material;
use super::status_code::Ctap2StatusCode; use super::status_code::Ctap2StatusCode;
use super::{cbor_read, key_material};
use alloc::string::String; use alloc::string::String;
use alloc::vec::Vec; use alloc::vec::Vec;
use arrayref::array_ref; use arrayref::array_ref;

View File

@@ -19,8 +19,7 @@ use crate::ctap::storage;
use crate::env::Env; use crate::env::Env;
use alloc::vec::Vec; use alloc::vec::Vec;
use arrayref::array_ref; use arrayref::array_ref;
use core::convert::Into; use core::convert::{Into, TryFrom};
use core::convert::TryFrom;
// For now, they're the same thing with apdu.rs containing the authoritative definition // For now, they're the same thing with apdu.rs containing the authoritative definition
pub type Ctap1StatusCode = ApduStatusCode; pub type Ctap1StatusCode = ApduStatusCode;

View File

@@ -75,11 +75,10 @@ use alloc::vec::Vec;
use arrayref::array_ref; use arrayref::array_ref;
use byteorder::{BigEndian, ByteOrder}; use byteorder::{BigEndian, ByteOrder};
use core::convert::TryFrom; use core::convert::TryFrom;
use crypto::ecdsa;
use crypto::hmac::{hmac_256, verify_hmac_256}; use crypto::hmac::{hmac_256, verify_hmac_256};
use crypto::rng256::Rng256; use crypto::rng256::Rng256;
use crypto::sha256::Sha256; use crypto::sha256::Sha256;
use crypto::Hash256; use crypto::{ecdsa, Hash256};
use embedded_time::duration::Milliseconds; use embedded_time::duration::Milliseconds;
use sk_cbor as cbor; use sk_cbor as cbor;
use sk_cbor::cbor_map_options; use sk_cbor::cbor_map_options;

View File

@@ -23,9 +23,8 @@ use crate::ctap::data_formats::{
extract_array, extract_text_string, CredentialProtectionPolicy, PublicKeyCredentialSource, extract_array, extract_text_string, CredentialProtectionPolicy, PublicKeyCredentialSource,
PublicKeyCredentialUserEntity, PublicKeyCredentialUserEntity,
}; };
use crate::ctap::key_material;
use crate::ctap::status_code::Ctap2StatusCode; 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 crate::env::Env;
use alloc::string::String; use alloc::string::String;
use alloc::vec; use alloc::vec;

View File

@@ -1,6 +1,5 @@
use crate::util; use crate::util;
use core::alloc::GlobalAlloc; use core::alloc::{GlobalAlloc, Layout};
use core::alloc::Layout;
#[cfg(any(feature = "debug_allocations", feature = "panic_console"))] #[cfg(any(feature = "debug_allocations", feature = "panic_console"))]
use core::fmt::Write; use core::fmt::Write;
use core::ptr; use core::ptr;

View File

@@ -15,9 +15,8 @@
#[cfg(feature = "debug_ctap")] #[cfg(feature = "debug_ctap")]
use crate::console::Console; use crate::console::Console;
use crate::result::TockError; use crate::result::TockError;
use crate::timer;
use crate::timer::Duration; use crate::timer::Duration;
use crate::util; use crate::{timer, util};
use core::cell::Cell; use core::cell::Cell;
#[cfg(feature = "debug_ctap")] #[cfg(feature = "debug_ctap")]
use core::fmt::Write; use core::fmt::Write;