From d0d9683df8398696147e7ee1fcffb2e4e957008c Mon Sep 17 00:00:00 2001 From: Daniel Mueller Date: Sat, 4 Apr 2020 14:39:19 -0700 Subject: Remove vendored dependencies While it appears that by now we actually can get successful builds without Cargo insisting on Internet access by virtue of using the --frozen flag, maintaining vendored dependencies is somewhat of a pain point. This state will also get worse with upcoming changes that replace argparse in favor of structopt and pull in a slew of new dependencies by doing so. Then there is also the repository structure aspect, which is non-standard due to the way we vendor dependencies and a potential source of confusion. In order to fix these problems, this change removes all the vendored dependencies we have. Delete subrepo argparse/:argparse Delete subrepo base32/:base32 Delete subrepo cc/:cc Delete subrepo cfg-if/:cfg-if Delete subrepo getrandom/:getrandom Delete subrepo lazy-static/:lazy-static Delete subrepo libc/:libc Delete subrepo nitrokey-sys/:nitrokey-sys Delete subrepo nitrokey/:nitrokey Delete subrepo rand/:rand --- lazy-static/tests/test.rs | 164 ---------------------------------------------- 1 file changed, 164 deletions(-) delete mode 100644 lazy-static/tests/test.rs (limited to 'lazy-static/tests/test.rs') diff --git a/lazy-static/tests/test.rs b/lazy-static/tests/test.rs deleted file mode 100644 index 03d0ab6..0000000 --- a/lazy-static/tests/test.rs +++ /dev/null @@ -1,164 +0,0 @@ -#[macro_use] -extern crate lazy_static; -use std::collections::HashMap; - -lazy_static! { - /// Documentation! - pub static ref NUMBER: u32 = times_two(3); - - static ref ARRAY_BOXES: [Box; 3] = [Box::new(1), Box::new(2), Box::new(3)]; - - /// More documentation! - #[allow(unused_variables)] - #[derive(Copy, Clone, Debug)] - pub static ref STRING: String = "hello".to_string(); - - static ref HASHMAP: HashMap = { - let mut m = HashMap::new(); - m.insert(0, "abc"); - m.insert(1, "def"); - m.insert(2, "ghi"); - m - }; - - // This should not compile if the unsafe is removed. - static ref UNSAFE: u32 = unsafe { - std::mem::transmute::(-1) - }; -} - -lazy_static! { - static ref S1: &'static str = "a"; - static ref S2: &'static str = "b"; -} -lazy_static! { - static ref S3: String = [*S1, *S2].join(""); -} - -#[test] -fn s3() { - assert_eq!(&*S3, "ab"); -} - -fn times_two(n: u32) -> u32 { - n * 2 -} - -#[test] -fn test_basic() { - assert_eq!(&**STRING, "hello"); - assert_eq!(*NUMBER, 6); - assert!(HASHMAP.get(&1).is_some()); - assert!(HASHMAP.get(&3).is_none()); - assert_eq!(&*ARRAY_BOXES, &[Box::new(1), Box::new(2), Box::new(3)]); - assert_eq!(*UNSAFE, std::u32::MAX); -} - -#[test] -fn test_repeat() { - assert_eq!(*NUMBER, 6); - assert_eq!(*NUMBER, 6); - assert_eq!(*NUMBER, 6); -} - -#[test] -fn test_meta() { - // this would not compile if STRING were not marked #[derive(Copy, Clone)] - let copy_of_string = STRING; - // just to make sure it was copied - assert!(&STRING as *const _ != ©_of_string as *const _); - - // this would not compile if STRING were not marked #[derive(Debug)] - assert_eq!(format!("{:?}", STRING), "STRING { __private_field: () }".to_string()); -} - -mod visibility { - lazy_static! { - pub static ref FOO: Box = Box::new(0); - static ref BAR: Box = Box::new(98); - } - - pub mod inner { - lazy_static! { - pub(in visibility) static ref BAZ: Box = Box::new(42); - pub(crate) static ref BAG: Box = Box::new(37); - } - } - - #[test] - fn sub_test() { - assert_eq!(**FOO, 0); - assert_eq!(**BAR, 98); - assert_eq!(**inner::BAZ, 42); - assert_eq!(**inner::BAG, 37); - } -} - -#[test] -fn test_visibility() { - assert_eq!(*visibility::FOO, Box::new(0)); - assert_eq!(*visibility::inner::BAG, Box::new(37)); -} - -// This should not cause a warning about a missing Copy implementation -lazy_static! { - pub static ref VAR: i32 = { 0 }; -} - -#[derive(Copy, Clone, Debug, PartialEq)] -struct X; -struct Once(X); -const ONCE_INIT: Once = Once(X); -static DATA: X = X; -static ONCE: X = X; -fn require_sync() -> X { X } -fn transmute() -> X { X } -fn __static_ref_initialize() -> X { X } -fn test(_: Vec) -> X { X } - -// All these names should not be shadowed -lazy_static! { - static ref ITEM_NAME_TEST: X = { - test(vec![X, Once(X).0, ONCE_INIT.0, DATA, ONCE, - require_sync(), transmute(), - // Except this, which will sadly be shadowed by internals: - // __static_ref_initialize() - ]) - }; -} - -#[test] -fn item_name_shadowing() { - assert_eq!(*ITEM_NAME_TEST, X); -} - -use std::sync::atomic::AtomicBool; -#[allow(deprecated)] -use std::sync::atomic::ATOMIC_BOOL_INIT; -use std::sync::atomic::Ordering::SeqCst; - -#[allow(deprecated)] -static PRE_INIT_FLAG: AtomicBool = ATOMIC_BOOL_INIT; - -lazy_static! { - static ref PRE_INIT: () = { - PRE_INIT_FLAG.store(true, SeqCst); - () - }; -} - -#[test] -fn pre_init() { - assert_eq!(PRE_INIT_FLAG.load(SeqCst), false); - lazy_static::initialize(&PRE_INIT); - assert_eq!(PRE_INIT_FLAG.load(SeqCst), true); -} - -lazy_static! { - static ref LIFETIME_NAME: for<'a> fn(&'a u8) = { fn f(_: &u8) {} f }; -} - -#[test] -fn lifetime_name() { - let _ = LIFETIME_NAME; -} -- cgit v1.2.3