chore: checkpoint before Python removal

This commit is contained in:
2026-03-26 22:33:59 +00:00
parent 683cec9307
commit e568ddf82a
29972 changed files with 11269302 additions and 2 deletions

View File

@@ -0,0 +1 @@
{"files":{".cargo_vcs_info.json":"faa240859908e21e77754ffae8991ca103362e05be86a4119014e09b2aa2d9c0","Cargo.lock":"b5189fed79a2e1da13eb2bfd20ffb3dc70e43d306d2dd6d186cfaab624b28cb4","Cargo.toml":"a1cc9f5d8a95afc23a3e514e52bc5e2d3f59e30f28c0803eb084e3f2f16dfd3c","Cargo.toml.orig":"a3b7bfea0e3ea18ed568829a3fd68e5a77dbf7d4d59e229efce497b0afa15c76","LICENSE":"219920e865eee70b7dcfc948a86b099e7f4fe2de01bcca2ca9a20c0a033f2b59","README.md":"d814fda4bf729aa194392480ef0aa0d02f2b6d24cb4a5a421e62c199e1313eae","src/lib.rs":"3b5257f913626d42994c3d7e93a2a7c37aa7b918ac74c52a9bcd013fdfffd631","src/macros.rs":"aeb108a0cc8e536286eef6bf041e21716a04116303ec233920f221e2df7f7d40"},"package":"728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2"}

View File

@@ -0,0 +1,6 @@
{
"git": {
"sha1": "91ead072fa43c55f35880bd7f75a2b0eab72a04e"
},
"path_in_vcs": ""
}

54
vendor/synstructure/Cargo.lock generated vendored Normal file
View File

@@ -0,0 +1,54 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 4
[[package]]
name = "proc-macro2"
version = "1.0.60"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dec2b086b7a862cf4de201096214fa870344cf922b2b30c167badb3af3195406"
dependencies = [
"unicode-ident",
]
[[package]]
name = "quote"
version = "1.0.26"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4424af4bf778aae2051a77b60283332f386554255d722233d09fbfc7e30da2fc"
dependencies = [
"proc-macro2",
]
[[package]]
name = "syn"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4cff13bb1732bccfe3b246f3fdb09edfd51c01d6f5299b7ccd9457c2e4e37774"
dependencies = [
"proc-macro2",
"quote",
"unicode-ident",
]
[[package]]
name = "synstructure"
version = "0.13.2"
dependencies = [
"proc-macro2",
"quote",
"syn",
"synstructure_test_traits",
]
[[package]]
name = "synstructure_test_traits"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c6e0c1828b7994d45bbef3cbbe56a6157c42db92b82b1a5bf22fb09996d06eac"
[[package]]
name = "unicode-ident"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d22af068fba1eb5edcb4aea19d382b2a3deb4c8f9d475c589b6ada9e0fd493ee"

75
vendor/synstructure/Cargo.toml vendored Normal file
View File

@@ -0,0 +1,75 @@
# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO
#
# When uploading crates to the registry Cargo will automatically
# "normalize" Cargo.toml files for maximal compatibility
# with all versions of Cargo and also rewrite `path` dependencies
# to registry (e.g., crates.io) dependencies.
#
# If you are reading this file be aware that the original Cargo.toml
# will likely look very different (and much more reasonable).
# See Cargo.toml.orig for the original contents.
[package]
edition = "2018"
name = "synstructure"
version = "0.13.2"
authors = ["Nika Layzell <nika@thelayzells.com>"]
build = false
include = [
"src/**/*",
"Cargo.toml",
"README.md",
"LICENSE",
]
autolib = false
autobins = false
autoexamples = false
autotests = false
autobenches = false
description = "Helper methods and macros for custom derives"
documentation = "https://docs.rs/synstructure"
readme = "README.md"
keywords = [
"syn",
"macros",
"derive",
"expand_substructure",
"enum",
]
license = "MIT"
repository = "https://github.com/mystor/synstructure"
[lib]
name = "synstructure"
path = "src/lib.rs"
[dependencies.proc-macro2]
version = "1.0.60"
default-features = false
[dependencies.quote]
version = "1"
default-features = false
[dependencies.syn]
version = "2"
features = [
"derive",
"parsing",
"printing",
"clone-impls",
"visit",
"extra-traits",
]
default-features = false
[dev-dependencies.synstructure_test_traits]
version = "0.1"
[features]
default = ["proc-macro"]
proc-macro = [
"proc-macro2/proc-macro",
"syn/proc-macro",
"quote/proc-macro",
]

7
vendor/synstructure/LICENSE vendored Normal file
View File

@@ -0,0 +1,7 @@
Copyright 2016 Nika Layzell
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

157
vendor/synstructure/README.md vendored Normal file
View File

@@ -0,0 +1,157 @@
# synstructure
[![Latest Version](https://img.shields.io/crates/v/synstructure.svg)](https://crates.io/crates/synstructure)
[![Documentation](https://docs.rs/synstructure/badge.svg)](https://docs.rs/synstructure)
[![Build Status](https://github.com/mystor/synstructure/actions/workflows/ci.yml/badge.svg)](https://github.com/mystor/synstructure/actions)
[![Rustc Version 1.31+](https://img.shields.io/badge/rustc-1.31+-lightgray.svg)](https://blog.rust-lang.org/2018/12/06/Rust-1.31-and-rust-2018.html)
> NOTE: What follows is an exerpt from the module level documentation. For full
> details read the docs on [docs.rs](https://docs.rs/synstructure/)
This crate provides helper types for matching against enum variants, and
extracting bindings to each of the fields in the deriving Struct or Enum in
a generic way.
If you are writing a `#[derive]` which needs to perform some operation on
every field, then you have come to the right place!
# Example: `WalkFields`
### Trait Implementation
```rust
pub trait WalkFields: std::any::Any {
fn walk_fields(&self, walk: &mut FnMut(&WalkFields));
}
impl WalkFields for i32 {
fn walk_fields(&self, _walk: &mut FnMut(&WalkFields)) {}
}
```
### Custom Derive
```rust
#[macro_use]
extern crate synstructure;
#[macro_use]
extern crate quote;
extern crate proc_macro2;
fn walkfields_derive(s: synstructure::Structure) -> proc_macro2::TokenStream {
let body = s.each(|bi| quote!{
walk(#bi)
});
s.bound_impl(quote!(example_traits::WalkFields), quote!{
fn walk_fields(&self, walk: &mut FnMut(&example_traits::WalkFields)) {
match *self { #body }
}
})
}
decl_derive!([WalkFields] => walkfields_derive);
/*
* Test Case
*/
fn main() {
test_derive! {
walkfields_derive {
enum A<T> {
B(i32, T),
C(i32),
}
}
expands to {
const _: () = {
extern crate example_traits;
impl<T> example_traits::WalkFields for A<T>
where T: example_traits::WalkFields
{
fn walk_fields(&self, walk: &mut FnMut(&example_traits::WalkFields)) {
match *self {
A::B(ref __binding_0, ref __binding_1,) => {
{ walk(__binding_0) }
{ walk(__binding_1) }
}
A::C(ref __binding_0,) => {
{ walk(__binding_0) }
}
}
}
}
};
}
}
}
```
# Example: `Interest`
### Trait Implementation
```rust
pub trait Interest {
fn interesting(&self) -> bool;
}
impl Interest for i32 {
fn interesting(&self) -> bool { *self > 0 }
}
```
### Custom Derive
```rust
#[macro_use]
extern crate synstructure;
#[macro_use]
extern crate quote;
extern crate proc_macro2;
fn interest_derive(mut s: synstructure::Structure) -> proc_macro2::TokenStream {
let body = s.fold(false, |acc, bi| quote!{
#acc || example_traits::Interest::interesting(#bi)
});
s.bound_impl(quote!(example_traits::Interest), quote!{
fn interesting(&self) -> bool {
match *self {
#body
}
}
})
}
decl_derive!([Interest] => interest_derive);
/*
* Test Case
*/
fn main() {
test_derive!{
interest_derive {
enum A<T> {
B(i32, T),
C(i32),
}
}
expands to {
const _: () = {
extern crate example_traits;
impl<T> example_traits::Interest for A<T>
where T: example_traits::Interest
{
fn interesting(&self) -> bool {
match *self {
A::B(ref __binding_0, ref __binding_1,) => {
false ||
example_traits::Interest::interesting(__binding_0) ||
example_traits::Interest::interesting(__binding_1)
}
A::C(ref __binding_0,) => {
false ||
example_traits::Interest::interesting(__binding_0)
}
}
}
}
};
}
}
}
```
For more example usage, consider investigating the `abomonation_derive` crate,
which makes use of this crate, and is fairly simple.

2559
vendor/synstructure/src/lib.rs vendored Normal file

File diff suppressed because it is too large Load Diff

262
vendor/synstructure/src/macros.rs vendored Normal file
View File

@@ -0,0 +1,262 @@
//! This module provides two utility macros for testing custom derives. They can
//! be used together to eliminate some of the boilerplate required in order to
//! declare and test custom derive implementations.
// Re-exports used by the decl_derive! and test_derive!
pub use proc_macro2::TokenStream as TokenStream2;
pub use quote::quote;
pub use syn::{parse2, parse_str, DeriveInput};
#[cfg(all(
not(all(target_arch = "wasm32", any(target_os = "unknown", target_os = "wasi"))),
feature = "proc-macro"
))]
pub use proc_macro::TokenStream;
#[cfg(all(
not(all(target_arch = "wasm32", any(target_os = "unknown", target_os = "wasi"))),
feature = "proc-macro"
))]
pub use syn::parse;
/// The `decl_derive!` macro declares a custom derive wrapper. It will parse the
/// incoming `TokenStream` into a `synstructure::Structure` object, and pass it
/// into the inner function.
///
/// Your inner function should take a `synstructure::Structure` by value, and
/// return a type implementing `synstructure::MacroResult`, for example:
///
/// ```
/// fn derive_simple(input: synstructure::Structure) -> proc_macro2::TokenStream {
/// unimplemented!()
/// }
///
/// fn derive_result(input: synstructure::Structure)
/// -> syn::Result<proc_macro2::TokenStream>
/// {
/// unimplemented!()
/// }
/// ```
///
/// # Usage
///
/// ### Without Attributes
/// ```
/// fn derive_interesting(_input: synstructure::Structure) -> proc_macro2::TokenStream {
/// quote::quote! { ... }
/// }
///
/// # const _IGNORE: &'static str = stringify! {
/// decl_derive!([Interesting] => derive_interesting);
/// # };
/// ```
///
/// ### With Attributes
/// ```
/// # fn main() {}
/// fn derive_interesting(_input: synstructure::Structure) -> proc_macro2::TokenStream {
/// quote::quote! { ... }
/// }
///
/// # const _IGNORE: &'static str = stringify! {
/// decl_derive!([Interesting, attributes(interesting_ignore)] => derive_interesting);
/// # };
/// ```
///
/// ### Decl Attributes & Doc Comments
/// ```
/// # fn main() {}
/// fn derive_interesting(_input: synstructure::Structure) -> proc_macro2::TokenStream {
/// quote::quote! { ... }
/// }
///
/// # const _IGNORE: &'static str = stringify! {
/// decl_derive! {
/// [Interesting] =>
/// #[allow(some_lint)]
/// /// Documentation Comments
/// derive_interesting
/// }
/// # };
/// ```
///
/// *This macro is available if `synstructure` is built with the `"proc-macro"`
/// feature.*
#[cfg(all(
not(all(target_arch = "wasm32", any(target_os = "unknown", target_os = "wasi"))),
feature = "proc-macro"
))]
#[macro_export]
macro_rules! decl_derive {
// XXX: Switch to using this variant everywhere?
([$derives:ident $($derive_t:tt)*] => $(#[$($attrs:tt)*])* $inner:path) => {
#[proc_macro_derive($derives $($derive_t)*)]
#[allow(non_snake_case)]
$(#[$($attrs)*])*
pub fn $derives(
i: $crate::macros::TokenStream
) -> $crate::macros::TokenStream {
match $crate::macros::parse::<$crate::macros::DeriveInput>(i) {
::core::result::Result::Ok(p) => {
match $crate::Structure::try_new(&p) {
::core::result::Result::Ok(s) => $crate::MacroResult::into_stream($inner(s)),
::core::result::Result::Err(e) => {
::core::convert::Into::into(e.to_compile_error())
}
}
}
::core::result::Result::Err(e) => {
::core::convert::Into::into(e.to_compile_error())
}
}
}
};
}
/// The `decl_attribute!` macro declares a custom attribute wrapper. It will
/// parse the incoming `TokenStream` into a `synstructure::Structure` object,
/// and pass it into the inner function.
///
/// Your inner function should have the following type:
///
/// ```
/// fn attribute(
/// attr: proc_macro2::TokenStream,
/// structure: synstructure::Structure,
/// ) -> proc_macro2::TokenStream {
/// unimplemented!()
/// }
/// ```
///
/// # Usage
///
/// ```
/// fn attribute_interesting(
/// _attr: proc_macro2::TokenStream,
/// _structure: synstructure::Structure,
/// ) -> proc_macro2::TokenStream {
/// quote::quote! { ... }
/// }
///
/// # const _IGNORE: &'static str = stringify! {
/// decl_attribute!([interesting] => attribute_interesting);
/// # };
/// ```
///
/// *This macro is available if `synstructure` is built with the `"proc-macro"`
/// feature.*
#[cfg(all(
not(all(target_arch = "wasm32", any(target_os = "unknown", target_os = "wasi"))),
feature = "proc-macro"
))]
#[macro_export]
macro_rules! decl_attribute {
([$attribute:ident] => $(#[$($attrs:tt)*])* $inner:path) => {
#[proc_macro_attribute]
$(#[$($attrs)*])*
pub fn $attribute(
attr: $crate::macros::TokenStream,
i: $crate::macros::TokenStream,
) -> $crate::macros::TokenStream {
match $crate::macros::parse::<$crate::macros::DeriveInput>(i) {
::core::result::Result::Ok(p) => match $crate::Structure::try_new(&p) {
::core::result::Result::Ok(s) => {
$crate::MacroResult::into_stream(
$inner(::core::convert::Into::into(attr), s)
)
}
::core::result::Result::Err(e) => {
::core::convert::Into::into(e.to_compile_error())
}
},
::core::result::Result::Err(e) => {
::core::convert::Into::into(e.to_compile_error())
}
}
}
};
}
/// Run a test on a custom derive. This macro expands both the original struct
/// and the expansion to ensure that they compile correctly, and confirms that
/// feeding the original struct into the named derive will produce the written
/// output.
///
/// You can add `no_build` to the end of the macro invocation to disable
/// checking that the written code compiles. This is useful in contexts where
/// the procedural macro cannot depend on the crate where it is used during
/// tests.
///
/// # Usage
///
/// ```
/// fn test_derive_example(_s: synstructure::Structure)
/// -> Result<proc_macro2::TokenStream, syn::Error>
/// {
/// Ok(quote::quote! { const YOUR_OUTPUT: &'static str = "here"; })
/// }
///
/// fn main() {
/// synstructure::test_derive!{
/// test_derive_example {
/// struct A;
/// }
/// expands to {
/// const YOUR_OUTPUT: &'static str = "here";
/// }
/// }
/// }
/// ```
#[macro_export]
macro_rules! test_derive {
($name:path { $($i:tt)* } expands to { $($o:tt)* }) => {
{
#[allow(dead_code)]
fn ensure_compiles() {
$($i)*
$($o)*
}
$crate::test_derive!($name { $($i)* } expands to { $($o)* } no_build);
}
};
($name:path { $($i:tt)* } expands to { $($o:tt)* } no_build) => {
{
let i = $crate::macros::quote!( $($i)* );
let parsed = $crate::macros::parse2::<$crate::macros::DeriveInput>(i)
.expect(::core::concat!(
"Failed to parse input to `#[derive(",
::core::stringify!($name),
")]`",
));
let raw_res = $name($crate::Structure::new(&parsed));
let res = $crate::MacroResult::into_result(raw_res)
.expect(::core::concat!(
"Procedural macro failed for `#[derive(",
::core::stringify!($name),
")]`",
));
let expected_toks = $crate::macros::quote!( $($o)* );
if <$crate::macros::TokenStream2 as ::std::string::ToString>::to_string(&res)
!= <$crate::macros::TokenStream2 as ::std::string::ToString>::to_string(&expected_toks)
{
panic!("\
test_derive failed:
expected:
```
{}
```
got:
```
{}
```\n",
$crate::unpretty_print(&expected_toks),
$crate::unpretty_print(&res),
);
}
}
};
}