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 --- cfg-if/src/lib.rs | 176 ------------------------------------------------------ 1 file changed, 176 deletions(-) delete mode 100644 cfg-if/src/lib.rs (limited to 'cfg-if/src/lib.rs') diff --git a/cfg-if/src/lib.rs b/cfg-if/src/lib.rs deleted file mode 100644 index 6c5058d..0000000 --- a/cfg-if/src/lib.rs +++ /dev/null @@ -1,176 +0,0 @@ -//! A macro for defining `#[cfg]` if-else statements. -//! -//! The macro provided by this crate, `cfg_if`, is similar to the `if/elif` C -//! preprocessor macro by allowing definition of a cascade of `#[cfg]` cases, -//! emitting the implementation which matches first. -//! -//! This allows you to conveniently provide a long list `#[cfg]`'d blocks of code -//! without having to rewrite each clause multiple times. -//! -//! # Example -//! -//! ``` -//! cfg_if::cfg_if! { -//! if #[cfg(unix)] { -//! fn foo() { /* unix specific functionality */ } -//! } else if #[cfg(target_pointer_width = "32")] { -//! fn foo() { /* non-unix, 32-bit functionality */ } -//! } else { -//! fn foo() { /* fallback implementation */ } -//! } -//! } -//! -//! # fn main() {} -//! ``` - -#![no_std] -#![doc(html_root_url = "https://docs.rs/cfg-if")] -#![deny(missing_docs)] -#![cfg_attr(test, deny(warnings))] - -/// The main macro provided by this crate. See crate documentation for more -/// information. -#[macro_export] -macro_rules! cfg_if { - // match if/else chains with a final `else` - ($( - if #[cfg($($meta:meta),*)] { $($tokens:tt)* } - ) else * else { - $($tokens2:tt)* - }) => { - $crate::cfg_if! { - @__items - () ; - $( ( ($($meta),*) ($($tokens)*) ), )* - ( () ($($tokens2)*) ), - } - }; - - // match if/else chains lacking a final `else` - ( - if #[cfg($($i_met:meta),*)] { $($i_tokens:tt)* } - $( - else if #[cfg($($e_met:meta),*)] { $($e_tokens:tt)* } - )* - ) => { - $crate::cfg_if! { - @__items - () ; - ( ($($i_met),*) ($($i_tokens)*) ), - $( ( ($($e_met),*) ($($e_tokens)*) ), )* - ( () () ), - } - }; - - // Internal and recursive macro to emit all the items - // - // Collects all the negated cfgs in a list at the beginning and after the - // semicolon is all the remaining items - (@__items ($($not:meta,)*) ; ) => {}; - (@__items ($($not:meta,)*) ; ( ($($m:meta),*) ($($tokens:tt)*) ), $($rest:tt)*) => { - // Emit all items within one block, applying an appropriate #[cfg]. The - // #[cfg] will require all `$m` matchers specified and must also negate - // all previous matchers. - #[cfg(all($($m,)* not(any($($not),*))))] $crate::cfg_if! { @__identity $($tokens)* } - - // Recurse to emit all other items in `$rest`, and when we do so add all - // our `$m` matchers to the list of `$not` matchers as future emissions - // will have to negate everything we just matched as well. - $crate::cfg_if! { @__items ($($not,)* $($m,)*) ; $($rest)* } - }; - - // Internal macro to make __apply work out right for different match types, - // because of how macros matching/expand stuff. - (@__identity $($tokens:tt)*) => { - $($tokens)* - }; -} - -#[cfg(test)] -mod tests { - cfg_if! { - if #[cfg(test)] { - use core::option::Option as Option2; - fn works1() -> Option2 { Some(1) } - } else { - fn works1() -> Option { None } - } - } - - cfg_if! { - if #[cfg(foo)] { - fn works2() -> bool { false } - } else if #[cfg(test)] { - fn works2() -> bool { true } - } else { - fn works2() -> bool { false } - } - } - - cfg_if! { - if #[cfg(foo)] { - fn works3() -> bool { false } - } else { - fn works3() -> bool { true } - } - } - - cfg_if! { - if #[cfg(test)] { - use core::option::Option as Option3; - fn works4() -> Option3 { Some(1) } - } - } - - cfg_if! { - if #[cfg(foo)] { - fn works5() -> bool { false } - } else if #[cfg(test)] { - fn works5() -> bool { true } - } - } - - #[test] - fn it_works() { - assert!(works1().is_some()); - assert!(works2()); - assert!(works3()); - assert!(works4().is_some()); - assert!(works5()); - } - - #[test] - #[allow(clippy::assertions_on_constants)] - fn test_usage_within_a_function() { - cfg_if! {if #[cfg(debug_assertions)] { - // we want to put more than one thing here to make sure that they - // all get configured properly. - assert!(cfg!(debug_assertions)); - assert_eq!(4, 2+2); - } else { - assert!(works1().is_some()); - assert_eq!(10, 5+5); - }} - } - - trait Trait { - fn blah(&self); - } - - #[allow(dead_code)] - struct Struct; - - impl Trait for Struct { - cfg_if! { - if #[cfg(feature = "blah")] { - fn blah(&self) { - unimplemented!(); - } - } else { - fn blah(&self) { - unimplemented!(); - } - } - } - } -} -- cgit v1.2.1