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

7
vendor/paste/tests/compiletest.rs vendored Normal file
View File

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

62
vendor/paste/tests/test_attr.rs vendored Normal file
View File

@@ -0,0 +1,62 @@
#![allow(clippy::let_underscore_untyped)]
use paste::paste;
use paste_test_suite::paste_test;
#[test]
fn test_attr() {
paste! {
#[paste_test(k = "val" "ue")]
struct A;
#[paste_test_suite::paste_test(k = "val" "ue")]
struct B;
#[::paste_test_suite::paste_test(k = "val" "ue")]
struct C;
#[paste_test(k = "va" [<l u>] e)]
struct D;
}
let _ = A;
let _ = B;
let _ = C;
let _ = D;
}
#[test]
fn test_paste_cfg() {
macro_rules! m {
($ret:ident, $width:expr) => {
paste! {
#[cfg(any(feature = "protocol_feature_" $ret:snake, target_pointer_width = "" $width))]
fn new() -> $ret { todo!() }
}
};
}
struct Paste;
#[cfg(target_pointer_width = "64")]
m!(Paste, 64);
#[cfg(target_pointer_width = "32")]
m!(Paste, 32);
let _ = new;
}
#[test]
fn test_path_in_attr() {
macro_rules! m {
(#[x = $x:ty]) => {
stringify!($x)
};
}
let ty = paste! {
m!(#[x = foo::Bar])
};
assert_eq!("foo::Bar", ty);
}

79
vendor/paste/tests/test_doc.rs vendored Normal file
View File

@@ -0,0 +1,79 @@
#![allow(clippy::let_underscore_untyped)]
use paste::paste;
#[test]
fn test_paste_doc() {
macro_rules! m {
($ret:ident) => {
paste! {
#[doc = "Create a new [`" $ret "`] object."]
fn new() -> $ret { todo!() }
}
};
}
struct Paste;
m!(Paste);
let _ = new;
}
macro_rules! get_doc {
(#[doc = $literal:tt]) => {
$literal
};
}
#[test]
fn test_escaping() {
let doc = paste! {
get_doc!(#[doc = "s\"" r#"r#""#])
};
let expected = "s\"r#\"";
assert_eq!(doc, expected);
}
#[test]
fn test_literals() {
let doc = paste! {
get_doc!(#[doc = "int=" 0x1 " bool=" true " float=" 0.01])
};
let expected = "int=0x1 bool=true float=0.01";
assert_eq!(doc, expected);
}
#[test]
fn test_case() {
let doc = paste! {
get_doc!(#[doc = "HTTP " get:upper "!"])
};
let expected = "HTTP GET!";
assert_eq!(doc, expected);
}
// https://github.com/dtolnay/paste/issues/63
#[test]
fn test_stringify() {
macro_rules! create {
($doc:expr) => {
paste! {
#[doc = $doc]
pub struct Struct;
}
};
}
macro_rules! forward {
($name:ident) => {
create!(stringify!($name));
};
}
forward!(documentation);
let _ = Struct;
}

285
vendor/paste/tests/test_expr.rs vendored Normal file
View File

@@ -0,0 +1,285 @@
#![allow(clippy::let_underscore_untyped)]
use paste::paste;
#[test]
fn test_shared_hygiene() {
paste! {
let [<a a>] = 1;
assert_eq!([<a a>], 1);
}
}
#[test]
fn test_repeat() {
const ROCKET_A: &str = "/a";
const ROCKET_B: &str = "/b";
macro_rules! routes {
($($route:ident),*) => {{
paste! {
vec![$( [<ROCKET_ $route>] ),*]
}
}}
}
let routes = routes!(A, B);
assert_eq!(routes, vec!["/a", "/b"]);
}
#[test]
fn test_literal_to_identifier() {
const CONST0: &str = "const0";
let pasted = paste!([<CONST 0>]);
assert_eq!(pasted, CONST0);
let pasted = paste!([<CONST '0'>]);
assert_eq!(pasted, CONST0);
let pasted = paste!([<CONST "0">]);
assert_eq!(pasted, CONST0);
let pasted = paste!([<CONST r"0">]);
assert_eq!(pasted, CONST0);
let pasted = paste!([<CONST '\u{30}'>]);
assert_eq!(pasted, CONST0);
}
#[test]
fn test_literal_suffix() {
macro_rules! literal {
($bit:tt) => {
paste!([<1_u $bit>])
};
}
assert_eq!(literal!(32), 1);
}
#[test]
fn test_underscore() {
paste! {
const A_B: usize = 0;
assert_eq!([<A _ B>], 0);
}
}
#[test]
fn test_lifetime() {
paste! {
#[allow(dead_code)]
struct S<[<'d e>]> {
q: &[<'d e>] str,
}
}
}
#[test]
fn test_keyword() {
paste! {
struct [<F move>];
let _ = Fmove;
}
}
#[test]
fn test_literal_str() {
paste! {
#[allow(non_camel_case_types)]
struct [<Foo "Bar-Baz">];
let _ = FooBar_Baz;
}
}
#[test]
fn test_env_literal() {
paste! {
struct [<Lib env bar>];
let _ = Libenvbar;
}
}
#[test]
fn test_env_present() {
paste! {
struct [<Lib env!("CARGO_PKG_NAME")>];
let _ = Libpaste;
}
}
#[test]
fn test_raw_identifier() {
paste! {
struct [<F r#move>];
let _ = Fmove;
}
}
#[test]
fn test_false_start() {
trait Trait {
fn f() -> usize;
}
struct S;
impl Trait for S {
fn f() -> usize {
0
}
}
paste! {
let x = [<S as Trait>::f()];
assert_eq!(x[0], 0);
}
}
#[test]
fn test_local_variable() {
let yy = 0;
paste! {
assert_eq!([<y y>], 0);
}
}
#[test]
fn test_empty() {
paste! {
assert_eq!(stringify!([<y y>]), "yy");
assert_eq!(stringify!([<>]).replace(' ', ""), "[<>]");
}
}
#[test]
fn test_env_to_lower() {
paste! {
struct [<Lib env!("CARGO_PKG_NAME"):lower>];
let _ = Libpaste;
}
}
#[test]
fn test_env_to_upper() {
paste! {
const [<LIB env!("CARGO_PKG_NAME"):upper>]: &str = "libpaste";
let _ = LIBPASTE;
}
}
#[test]
fn test_env_to_snake() {
paste! {
const [<LIB env!("CARGO_PKG_NAME"):snake:upper>]: &str = "libpaste";
let _ = LIBPASTE;
}
}
#[test]
fn test_env_to_camel() {
paste! {
#[allow(non_upper_case_globals)]
const [<LIB env!("CARGO_PKG_NAME"):camel>]: &str = "libpaste";
let _ = LIBPaste;
}
}
mod test_x86_feature_literal {
// work around https://github.com/rust-lang/rust/issues/72726
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
macro_rules! my_is_x86_feature_detected {
($feat:literal) => {
use paste::paste;
paste! {
#[test]
fn test() {
let _ = is_x86_feature_detected!($feat);
}
}
};
}
#[cfg(not(any(target_arch = "x86", target_arch = "x86_64")))]
macro_rules! my_is_x86_feature_detected {
($feat:literal) => {
#[ignore]
#[test]
fn test() {}
};
}
my_is_x86_feature_detected!("mmx");
}
#[rustversion::since(1.46)]
mod test_local_setter {
// https://github.com/dtolnay/paste/issues/7
use paste::paste;
#[derive(Default)]
struct Test {
val: i32,
}
impl Test {
fn set_val(&mut self, arg: i32) {
self.val = arg;
}
}
macro_rules! setter {
($obj:expr, $field:ident, $value:expr) => {
paste! { $obj.[<set_ $field>]($value); }
};
($field:ident, $value:expr) => {{
let mut new = Test::default();
setter!(new, val, $value);
new
}};
}
#[test]
fn test_local_setter() {
let a = setter!(val, 42);
assert_eq!(a.val, 42);
}
}
// https://github.com/dtolnay/paste/issues/85
#[test]
fn test_top_level_none_delimiter() {
macro_rules! clone {
($val:expr) => {
paste! {
$val.clone()
}
};
}
#[derive(Clone)]
struct A;
impl A {
fn consume_self(self) {
let _ = self;
}
}
clone!(&A).consume_self();
}

271
vendor/paste/tests/test_item.rs vendored Normal file
View File

@@ -0,0 +1,271 @@
#![allow(clippy::let_underscore_untyped)]
mod test_basic {
use paste::paste;
struct Struct;
paste! {
impl Struct {
fn [<a b c>]() {}
}
}
#[test]
fn test() {
Struct::abc();
}
}
mod test_in_impl {
use paste::paste;
struct Struct;
impl Struct {
paste! {
fn [<a b c>]() {}
}
}
#[test]
fn test() {
Struct::abc();
}
}
mod test_none_delimited_single_ident {
use paste::paste;
macro_rules! m {
($id:ident) => {
paste! {
fn f() -> &'static str {
stringify!($id)
}
}
};
}
m!(i32x4);
#[test]
fn test() {
assert_eq!(f(), "i32x4");
}
}
mod test_none_delimited_single_lifetime {
use paste::paste;
macro_rules! m {
($life:lifetime) => {
paste! {
pub struct S<$life>(#[allow(dead_code)] pub &$life ());
impl<$life> S<$life> {
fn f() {}
}
}
};
}
m!('a);
#[test]
fn test() {
S::f();
}
}
mod test_to_lower {
use paste::paste;
macro_rules! m {
($id:ident) => {
paste! {
fn [<my_ $id:lower _here>](_arg: u8) -> &'static str {
stringify!([<$id:lower>])
}
}
};
}
m!(Test);
#[test]
fn test_to_lower() {
assert_eq!(my_test_here(0), "test");
}
}
mod test_to_upper {
use paste::paste;
macro_rules! m {
($id:ident) => {
paste! {
const [<MY_ $id:upper _HERE>]: &str = stringify!([<$id:upper>]);
}
};
}
m!(Test);
#[test]
fn test_to_upper() {
assert_eq!(MY_TEST_HERE, "TEST");
}
}
mod test_to_snake {
use paste::paste;
macro_rules! m {
($id:ident) => {
paste! {
const DEFAULT_SNAKE: &str = stringify!([<$id:snake>]);
const LOWER_SNAKE: &str = stringify!([<$id:snake:lower>]);
const UPPER_SNAKE: &str = stringify!([<$id:snake:upper>]);
}
};
}
m!(ThisIsButATest);
#[test]
fn test_to_snake() {
assert_eq!(DEFAULT_SNAKE, "this_is_but_a_test");
assert_eq!(LOWER_SNAKE, "this_is_but_a_test");
assert_eq!(UPPER_SNAKE, "THIS_IS_BUT_A_TEST");
}
}
mod test_to_camel {
use paste::paste;
macro_rules! m {
($id:ident) => {
paste! {
const DEFAULT_CAMEL: &str = stringify!([<$id:camel>]);
const LOWER_CAMEL: &str = stringify!([<$id:camel:lower>]);
const UPPER_CAMEL: &str = stringify!([<$id:camel:upper>]);
}
};
}
m!(this_is_but_a_test);
#[test]
fn test_to_camel() {
assert_eq!(DEFAULT_CAMEL, "ThisIsButATest");
assert_eq!(LOWER_CAMEL, "thisisbutatest");
assert_eq!(UPPER_CAMEL, "THISISBUTATEST");
}
}
mod test_doc_expr {
// https://github.com/dtolnay/paste/issues/29
use paste::paste;
macro_rules! doc_expr {
($doc:expr) => {
paste! {
#[doc = $doc]
pub struct S;
}
};
}
doc_expr!(stringify!(...));
#[test]
fn test_doc_expr() {
let _: S;
}
}
mod test_type_in_path {
// https://github.com/dtolnay/paste/issues/31
use paste::paste;
mod keys {
#[derive(Default)]
pub struct Mib<T = ()>(std::marker::PhantomData<T>);
}
macro_rules! types {
($mib:ty) => {
paste! {
#[derive(Default)]
pub struct S(pub keys::$mib);
}
};
}
macro_rules! write {
($fn:ident, $field:ty) => {
paste! {
pub fn $fn() -> $field {
$field::default()
}
}
};
}
types! {Mib<[usize; 2]>}
write! {get_a, keys::Mib}
write! {get_b, usize}
#[test]
fn test_type_in_path() {
let _: S;
let _ = get_a;
let _ = get_b;
}
}
mod test_type_in_fn_arg {
// https://github.com/dtolnay/paste/issues/38
use paste::paste;
fn _jit_address(_node: ()) {}
macro_rules! jit_reexport {
($fn:ident, $arg:ident : $typ:ty) => {
paste! {
pub fn $fn($arg: $typ) {
[<_jit_ $fn>]($arg);
}
}
};
}
jit_reexport!(address, node: ());
#[test]
fn test_type_in_fn_arg() {
let _ = address;
}
}
mod test_pat_in_expr_position {
// https://github.com/xiph/rav1e/pull/2324/files
use paste::paste;
macro_rules! rav1e_bad {
($e:pat) => {
paste! {
#[test]
fn test() {
let _ = $e;
}
}
};
}
rav1e_bad!(std::fmt::Error);
}

15
vendor/paste/tests/ui/case-warning.rs vendored Normal file
View File

@@ -0,0 +1,15 @@
#![deny(warnings)]
use paste::paste;
macro_rules! m {
($i:ident) => {
paste! {
pub fn [<foo $i>]() {}
}
};
}
m!(Bar);
fn main() {}

View File

@@ -0,0 +1,16 @@
error: function `fooBar` should have a snake case name
--> tests/ui/case-warning.rs:8:20
|
8 | pub fn [<foo $i>]() {}
| ^^^^^^^^^^ help: convert the identifier to snake case: `foo_bar`
...
13 | m!(Bar);
| ------- in this macro invocation
|
note: the lint level is defined here
--> tests/ui/case-warning.rs:1:9
|
1 | #![deny(warnings)]
| ^^^^^^^^
= note: `#[deny(non_snake_case)]` implied by `#[deny(warnings)]`
= note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info)

7
vendor/paste/tests/ui/env-empty.rs vendored Normal file
View File

@@ -0,0 +1,7 @@
use paste::paste;
paste! {
fn [<env!()>]() {}
}
fn main() {}

View File

@@ -0,0 +1,5 @@
error: expected string literal as argument to env! macro
--> tests/ui/env-empty.rs:4:10
|
4 | fn [<env!()>]() {}
| ^^^^^^

View File

@@ -0,0 +1,7 @@
use paste::paste;
paste! {
fn [<env!(1.31)>]() {}
}
fn main() {}

View File

@@ -0,0 +1,5 @@
error: expected string literal
--> tests/ui/env-non-string.rs:4:15
|
4 | fn [<env!(1.31)>]() {}
| ^^^^

7
vendor/paste/tests/ui/env-suffix.rs vendored Normal file
View File

@@ -0,0 +1,7 @@
use paste::paste;
paste! {
fn [<env!("VAR"suffix)>]() {}
}
fn main() {}

View File

@@ -0,0 +1,5 @@
error: expected string literal
--> tests/ui/env-suffix.rs:4:15
|
4 | fn [<env!("VAR"suffix)>]() {}
| ^^^^^^^^^^^

View File

@@ -0,0 +1,7 @@
use paste::paste;
paste! {
fn [<env!("VAR" "VAR")>]() {}
}
fn main() {}

View File

@@ -0,0 +1,5 @@
error: unexpected token in env! macro
--> tests/ui/env-unexpected.rs:4:21
|
4 | fn [<env!("VAR" "VAR")>]() {}
| ^^^^^

15
vendor/paste/tests/ui/invalid-ident.rs vendored Normal file
View File

@@ -0,0 +1,15 @@
use paste::paste;
paste! {
fn [<0 f>]() {}
}
paste! {
fn [<f '"'>]() {}
}
paste! {
fn [<f "'">]() {}
}
fn main() {}

View File

@@ -0,0 +1,26 @@
error: expected identifier, found `0f`
--> tests/ui/invalid-ident.rs:3:1
|
3 | / paste! {
4 | | fn [<0 f>]() {}
5 | | }
| |_^ expected identifier
|
help: identifiers cannot start with a number
--> tests/ui/invalid-ident.rs:3:1
|
3 | paste! {
| ^
= note: this error originates in the macro `paste` (in Nightly builds, run with -Z macro-backtrace for more info)
error: `"f\""` is not a valid identifier
--> tests/ui/invalid-ident.rs:8:8
|
8 | fn [<f '"'>]() {}
| ^^^^^^^^^
error: `"f'"` is not a valid identifier
--> tests/ui/invalid-ident.rs:12:8
|
12 | fn [<f "'">]() {}
| ^^^^^^^^^

View File

@@ -0,0 +1,7 @@
use paste::paste;
paste! {
fn [<env! huh>]() {}
}
fn main() {}

View File

@@ -0,0 +1,5 @@
error: expected `(`
--> tests/ui/missing-paren-on-env.rs:4:15
|
4 | fn [<env! huh>]() {}
| ^^^

7
vendor/paste/tests/ui/no-env-var.rs vendored Normal file
View File

@@ -0,0 +1,7 @@
use paste::paste;
paste! {
fn [<a env!("PASTE_UNKNOWN") b>]() {}
}
fn main() {}

View File

@@ -0,0 +1,5 @@
error: no such env var: "PASTE_UNKNOWN"
--> tests/ui/no-env-var.rs:4:17
|
4 | fn [<a env!("PASTE_UNKNOWN") b>]() {}
| ^^^^^^^^^^^^^^^

View File

@@ -0,0 +1,7 @@
use paste::paste;
paste! {
fn [<name:0>]() {}
}
fn main() {}

View File

@@ -0,0 +1,5 @@
error: expected identifier after `:`
--> tests/ui/no-ident-after-colon.rs:4:15
|
4 | fn [<name:0>]() {}
| ^

View File

@@ -0,0 +1,7 @@
use paste::paste;
paste! {
fn [<a {} b>]() {}
}
fn main() {}

View File

@@ -0,0 +1,5 @@
error: unexpected token
--> tests/ui/unexpected-group.rs:4:12
|
4 | fn [<a {} b>]() {}
| ^^

View File

@@ -0,0 +1,7 @@
use paste::paste;
paste! {
fn [<:lower x>]() {}
}
fn main() {}

View File

@@ -0,0 +1,5 @@
error: unexpected modifier
--> tests/ui/unexpected-modifier.rs:4:10
|
4 | fn [<:lower x>]() {}
| ^^^^^^

View File

@@ -0,0 +1,7 @@
use paste::paste;
paste! {
fn [<a + b>]() {}
}
fn main() {}

View File

@@ -0,0 +1,5 @@
error: unexpected punct
--> tests/ui/unexpected-punct.rs:4:12
|
4 | fn [<a + b>]() {}
| ^

View File

@@ -0,0 +1,21 @@
use paste::paste;
paste! {
fn [<x 1e+100 z>]() {}
}
paste! {
// `xyz` is not correct. `xbyz` is certainly not correct. Maybe `x121z`
// would be justifiable but for now don't accept this.
fn [<x b'y' z>]() {}
}
paste! {
fn [<x b"y" z>]() {}
}
paste! {
fn [<x br"y" z>]() {}
}
fn main() {}

View File

@@ -0,0 +1,23 @@
error: unsupported literal
--> tests/ui/unsupported-literal.rs:4:12
|
4 | fn [<x 1e+100 z>]() {}
| ^^^^^^
error: unsupported literal
--> tests/ui/unsupported-literal.rs:10:12
|
10 | fn [<x b'y' z>]() {}
| ^^^^
error: unsupported literal
--> tests/ui/unsupported-literal.rs:14:12
|
14 | fn [<x b"y" z>]() {}
| ^^^^
error: unsupported literal
--> tests/ui/unsupported-literal.rs:18:12
|
18 | fn [<x br"y" z>]() {}
| ^^^^^

View File

@@ -0,0 +1,7 @@
use paste::paste;
paste! {
fn [<a:pillow>]() {}
}
fn main() {}

View File

@@ -0,0 +1,5 @@
error: unsupported modifier
--> tests/ui/unsupported-modifier.rs:4:11
|
4 | fn [<a:pillow>]() {}
| ^^^^^^^