Vendor dependencies for 0.3.0 release

This commit is contained in:
2025-09-27 10:29:08 -05:00
parent 0c8d39d483
commit 82ab7f317b
26803 changed files with 16134934 additions and 0 deletions

View File

@@ -0,0 +1,8 @@
#[macro_use]
extern crate lazy_static;
lazy_static! {
pub(nonsense) static ref WRONG: () = ();
}
fn main() { }

View File

@@ -0,0 +1,10 @@
error[E0704]: incorrect visibility restriction
--> tests/compile_fail/incorrect_visibility_restriction.rs:5:9
|
5 | pub(nonsense) static ref WRONG: () = ();
| ^^^^^^^^ help: make this visible only to module `nonsense` with `in`: `in nonsense`
|
= help: some possible visibility restrictions are:
`pub(crate)`: visible only on the current crate
`pub(super)`: visible only in the current module's parent
`pub(in path::to::module)`: visible only on the specified path

View File

@@ -0,0 +1,14 @@
#[macro_use]
extern crate lazy_static;
mod outer {
pub mod inner {
lazy_static! {
pub(in outer) static ref FOO: () = ();
}
}
}
fn main() {
assert_eq!(*outer::inner::FOO, ());
}

View File

@@ -0,0 +1,14 @@
error[E0603]: static `FOO` is private
--> tests/compile_fail/static_is_private.rs:13:31
|
13 | assert_eq!(*outer::inner::FOO, ());
| ^^^ private static
|
note: the static `FOO` is defined here
--> tests/compile_fail/static_is_private.rs:6:9
|
6 | / lazy_static! {
7 | | pub(in outer) static ref FOO: () = ();
8 | | }
| |_________^
= note: this error originates in the macro `lazy_static` (in Nightly builds, run with -Z macro-backtrace for more info)

View File

@@ -0,0 +1,9 @@
#[macro_use]
extern crate lazy_static;
lazy_static! {
pub static ref FOO: str = panic!();
}
fn main() { }

View File

@@ -0,0 +1,64 @@
error[E0277]: the size for values of type `str` cannot be known at compilation time
--> tests/compile_fail/static_is_sized.rs:4:1
|
4 | / lazy_static! {
5 | | pub static ref FOO: str = panic!();
6 | | }
| |_^ doesn't have a size known at compile-time
|
= help: the trait `Sized` is not implemented for `str`
note: required by an implicit `Sized` bound in `Lazy`
--> src/inline_lazy.rs
|
| pub struct Lazy<T: Sync>(Cell<MaybeUninit<T>>, Once);
| ^ required by the implicit `Sized` requirement on this type parameter in `Lazy`
= note: this error originates in the macro `__lazy_static_create` which comes from the expansion of the macro `lazy_static` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the size for values of type `str` cannot be known at compilation time
--> tests/compile_fail/static_is_sized.rs:4:1
|
4 | / lazy_static! {
5 | | pub static ref FOO: str = panic!();
6 | | }
| |_^ doesn't have a size known at compile-time
|
= help: the trait `Sized` is not implemented for `str`
note: required by an implicit `Sized` bound in `Lazy`
--> src/inline_lazy.rs
|
| pub struct Lazy<T: Sync>(Cell<MaybeUninit<T>>, Once);
| ^ required by the implicit `Sized` requirement on this type parameter in `Lazy`
= note: this error originates in the macro `__lazy_static_create` which comes from the expansion of the macro `lazy_static` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the size for values of type `str` cannot be known at compilation time
--> tests/compile_fail/static_is_sized.rs:5:25
|
5 | pub static ref FOO: str = panic!();
| ^^^ doesn't have a size known at compile-time
|
= help: the trait `Sized` is not implemented for `str`
= note: the return type of a function must have a statically known size
error[E0599]: the method `get` exists for struct `Lazy<str>`, but its trait bounds were not satisfied
--> tests/compile_fail/static_is_sized.rs:4:1
|
4 | / lazy_static! {
5 | | pub static ref FOO: str = panic!();
6 | | }
| |_^ method cannot be called on `Lazy<str>` due to unsatisfied trait bounds
|
= note: the following trait bounds were not satisfied:
`str: Sized`
= note: this error originates in the macro `__lazy_static_internal` which comes from the expansion of the macro `lazy_static` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the size for values of type `str` cannot be known at compilation time
--> tests/compile_fail/static_is_sized.rs:4:1
|
4 | / lazy_static! {
5 | | pub static ref FOO: str = panic!();
6 | | }
| |_^ doesn't have a size known at compile-time
|
= help: the trait `Sized` is not implemented for `str`
= note: the return type of a function must have a statically known size
= note: this error originates in the macro `__lazy_static_internal` which comes from the expansion of the macro `lazy_static` (in Nightly builds, run with -Z macro-backtrace for more info)

19
vendor/lazy_static/tests/no_std.rs vendored Normal file
View File

@@ -0,0 +1,19 @@
#![cfg(feature = "spin_no_std")]
#![no_std]
#[macro_use]
extern crate lazy_static;
lazy_static! {
/// Documentation!
pub static ref NUMBER: u32 = times_two(3);
}
fn times_two(n: u32) -> u32 {
n * 2
}
#[test]
fn test_basic() {
assert_eq!(*NUMBER, 6);
}

185
vendor/lazy_static/tests/test.rs vendored Normal file
View File

@@ -0,0 +1,185 @@
#![deny(warnings)]
#[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<u32>; 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<u32, &'static str> = {
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::<i32, u32>(-1)
};
}
lazy_static! {
static ref S1: &'static str = "a";
static ref S2: &'static str = "b";
}
lazy_static! {
static ref S3: String = [*S1, *S2].join("");
}
lazy_static! {
#[allow(non_upper_case_globals)]
pub static ref string: String = "hello".to_string();
}
#[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 _ != &copy_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<u32> = Box::new(0);
static ref BAR: Box<u32> = Box::new(98);
}
pub mod inner {
lazy_static! {
pub(in visibility) static ref BAZ: Box<u32> = Box::new(42);
pub(crate) static ref BAG: Box<u32> = 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 {
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;
use std::sync::atomic::Ordering::SeqCst;
#[allow(deprecated)]
use std::sync::atomic::ATOMIC_BOOL_INIT;
#[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;
}

6
vendor/lazy_static/tests/ui.rs vendored Normal file
View File

@@ -0,0 +1,6 @@
#[test]
#[cfg(not(miri))]
fn ui() {
let t = trybuild::TestCases::new();
t.compile_fail("tests/compile_fail/*.rs");
}