Vendor dependencies

This commit is contained in:
2026-08-01 16:11:49 +03:00
parent 7f139a0241
commit 6b5e7f0f8b
29706 changed files with 9575646 additions and 0 deletions
+1
View File
@@ -0,0 +1 @@
{"$comment":"This file only protects against accidental modifications. It is not a security mechanism and does not protect against malicious changes.","files":{".cargo_vcs_info.json":"fba340fd1bda4e689a1a8db5e70dd3f09b6023dd7ae99751c7f497b91cbba61e","CHANGELOG.md":"b1fb67b9efd8955c8003db6b6a7ba577705723e9c6e4c89875a70299406b5f84","Cargo.lock":"783fd73b34d1b4305fbfd61a2adaa4b83f9db268b1a03d8ad314083254db71ba","Cargo.toml":"558d8aee78698747e19a7ee9e1880bd59d6ccb64a85c35adde184376f64b51be","Cargo.toml.orig":"7f748b7c48b37b31a27a154a3e235591d90fe5610594098814254b4698d352d3","README.md":"56b7d4f3aa314ff5b4e9e96e4e976e6374049c46481672b309137a32bbd167d7","rustfmt.toml":"9bbb759b3914c49c8060bcdeeb7786f4aec083d30bcfe236bbd48d8388d06103","src/lib.rs":"ae1dd246ff8987f2851ab636244d8e00f774b8463d60997c48436597504581ee"},"package":"260bbc7148a8d6818ac5032a1b9970da1a68bdd723d45b12d59f7c1bf3565e24"}
+6
View File
@@ -0,0 +1,6 @@
{
"git": {
"sha1": "69863a9b02bbc2eed3d04fe20a5845a147e3a749"
},
"path_in_vcs": ""
}
+49
View File
@@ -0,0 +1,49 @@
# Change Log
All user visible changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/), as described
for Rust libraries in [RFC #1105](https://github.com/rust-lang/rfcs/blob/master/text/1105-api-evolution.md)
## 0.2.2
- Drop the `proc-macro-error2` dependency in favour of emitting diagnostics via
`syn::Error` / `compile_error!`. This removes the transitive unmaintained-crate
advisory (https://rustsec.org/advisories/RUSTSEC-2026-0173) and the upcoming
`extern crate proc_macro` re-export future-incompatibility. Error messages are
unchanged.
## 0.2.1
- Use `proc-macro-error2` to address https://rustsec.org/advisories/RUSTSEC-2024-0370
## 0.1.7
- Update dependencies.
## 0.1.6
- Also generate `try_from_attributes` which can be used to parse optional attributes.
## 0.1.5
- Use correct keywords used in Cargo.toml
## 0.1.4
- Fix potential panic caused by unwrapping a `None`. The panic could happen while computing the span for an error message if not compiling on nightly.
## 0.1.3
- Make version requirements for dependencies less strict.
## 0.1.2
Make docs.rs rebuild.
## 0.1.1
Add readme.
## 0.1.0
Initial release.
+251
View File
@@ -0,0 +1,251 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 4
[[package]]
name = "equivalent"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f"
[[package]]
name = "glob"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0cc23270f6e1808e30a928bdc84dea0b9b4136a8bc82338574f23baf47bbd280"
[[package]]
name = "hashbrown"
version = "0.17.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a"
[[package]]
name = "heck"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8"
[[package]]
name = "indexmap"
version = "2.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d466e9454f08e4a911e14806c24e16fba1b4c121d1ea474396f396069cf949d9"
dependencies = [
"equivalent",
"hashbrown",
]
[[package]]
name = "itoa"
version = "1.0.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682"
[[package]]
name = "memchr"
version = "2.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98"
[[package]]
name = "proc-macro2"
version = "1.0.106"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934"
dependencies = [
"unicode-ident",
]
[[package]]
name = "quote"
version = "1.0.46"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dfbc457d0c7a0759a614551b11a6409e5951f6c7537be1f1b7682b9ae9230368"
dependencies = [
"proc-macro2",
]
[[package]]
name = "sea-bae"
version = "0.2.2"
dependencies = [
"heck",
"proc-macro2",
"quote",
"syn",
"trybuild",
]
[[package]]
name = "serde"
version = "1.0.228"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e"
dependencies = [
"serde_core",
]
[[package]]
name = "serde_core"
version = "1.0.228"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
version = "1.0.228"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "serde_json"
version = "1.0.150"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e8014e44b4736ed0538adeecded0fce2a272f22dc9578a7eb6b2d9993c74cfb9"
dependencies = [
"itoa",
"memchr",
"serde",
"serde_core",
"zmij",
]
[[package]]
name = "serde_spanned"
version = "1.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6662b5879511e06e8999a8a235d848113e942c9124f211511b16466ee2995f26"
dependencies = [
"serde_core",
]
[[package]]
name = "syn"
version = "2.0.119"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "872831b642d1a07999a962a351ed35b955ea2cfc8f3862091e2a240a84f17297"
dependencies = [
"proc-macro2",
"quote",
"unicode-ident",
]
[[package]]
name = "target-triple"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c3a6bfce3d99adfa72d24750a61f782f3036a81e7f86d8841ee1326deaebd171"
[[package]]
name = "termcolor"
version = "1.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755"
dependencies = [
"winapi-util",
]
[[package]]
name = "toml"
version = "1.1.3+spec-1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "53c96ecdfa941c8fc4fcaed14f99ada8ebed502eef533015095a07e3301d4c3c"
dependencies = [
"indexmap",
"serde_core",
"serde_spanned",
"toml_datetime",
"toml_parser",
"toml_writer",
"winnow",
]
[[package]]
name = "toml_datetime"
version = "1.1.1+spec-1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3165f65f62e28e0115a00b2ebdd37eb6f3b641855f9d636d3cd4103767159ad7"
dependencies = [
"serde_core",
]
[[package]]
name = "toml_parser"
version = "1.1.2+spec-1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a2abe9b86193656635d2411dc43050282ca48aa31c2451210f4202550afb7526"
dependencies = [
"winnow",
]
[[package]]
name = "toml_writer"
version = "1.1.2+spec-1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7d56353a2a665ad0f41a421187180aab746c8c325620617ad883a99a1cbe66d2"
[[package]]
name = "trybuild"
version = "1.0.118"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "06649c6f63d86604ba0c8950d5a1829fc9a17afd70fc6629f481d75b6a624c78"
dependencies = [
"glob",
"serde",
"serde_derive",
"serde_json",
"target-triple",
"termcolor",
"toml",
]
[[package]]
name = "unicode-ident"
version = "1.0.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75"
[[package]]
name = "winapi-util"
version = "0.1.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22"
dependencies = [
"windows-sys",
]
[[package]]
name = "windows-link"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5"
[[package]]
name = "windows-sys"
version = "0.61.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc"
dependencies = [
"windows-link",
]
[[package]]
name = "winnow"
version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "23b97319f7b8343df12cc98938e5c3eb436064524c8d2b4e30a1d3a36eecdf81"
[[package]]
name = "zmij"
version = "1.0.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "29666d0abbfad1e3dc4dcf6144730dd3a3ab225bbbdac83319345b1b44ccfc1b"
+59
View File
@@ -0,0 +1,59 @@
# 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 = "sea-bae"
version = "0.2.2"
authors = ["David Pedersen <david.pdrsn@gmail.com>"]
build = false
autolib = false
autobins = false
autoexamples = false
autotests = false
autobenches = false
description = "A Rust proc-macro attribute parser"
homepage = "https://github.com/SeaQL/sea-bae"
documentation = "https://docs.rs/sea-bae"
readme = "README.md"
keywords = [
"macro",
"derive",
"attributes",
"proc",
]
categories = ["development-tools::procedural-macro-helpers"]
license = "MIT"
repository = "https://github.com/SeaQL/sea-bae.git"
[lib]
name = "sea_bae"
path = "src/lib.rs"
proc-macro = true
[dependencies.heck]
version = "0.4"
[dependencies.proc-macro2]
version = "1"
[dependencies.quote]
version = "1"
[dependencies.syn]
version = "2"
features = [
"full",
"extra-traits",
]
[dev-dependencies.trybuild]
version = "1"
+26
View File
@@ -0,0 +1,26 @@
[package]
authors = ["David Pedersen <david.pdrsn@gmail.com>"]
description = "A Rust proc-macro attribute parser"
documentation = "https://docs.rs/sea-bae"
edition = "2018"
homepage = "https://github.com/SeaQL/sea-bae"
keywords = ["macro", "derive", "attributes", "proc"]
categories = ["development-tools::procedural-macro-helpers"]
license = "MIT"
name = "sea-bae"
readme = "README.md"
repository = "https://github.com/SeaQL/sea-bae.git"
version = "0.2.2"
[dependencies]
syn = { version = "2", features = ["full", "extra-traits"] }
quote = "1"
proc-macro2 = "1"
heck = "0.4"
[dev_dependencies]
trybuild = "1"
[lib]
proc-macro = true
path = "src/lib.rs"
+7
View File
@@ -0,0 +1,7 @@
# `sea-bae`
`sea-bae` is a crate for proc macro authors, which simplifies parsing of attributes. It is forked from [davidpdrsn/bae](https://github.com/davidpdrsn/bae), which is inspired by [`darling`](https://crates.io/crates/darling) but has a simpler API.
This fork upgrades `syn` to `2.0` and `heck` to `0.4`, mainly for use in `sea-orm`.
See [the docs](https://docs.rs/sea-bae) for more info.
+1
View File
@@ -0,0 +1 @@
merge_imports = true
+379
View File
@@ -0,0 +1,379 @@
//! `sea-bae` is a crate for proc macro authors, which simplifies parsing of attributes. It is
//! heavily inspired by [`darling`](https://crates.io/crates/darling) but has a significantly
//! simpler API.
//!
//! ```rust
//! use sea_bae::FromAttributes;
//!
//! #[derive(
//! Debug,
//! Eq,
//! PartialEq,
//!
//! // This will add two functions:
//! // ```
//! // fn from_attributes(attrs: &[syn::Attribute]) -> Result<MyAttr, syn::Error>
//! // fn try_from_attributes(attrs: &[syn::Attribute]) -> Result<Option<MyAttr>, syn::Error>
//! // ```
//! //
//! // `try_from_attributes` returns `Ok(None)` if the attribute is missing, `Ok(Some(_))` if
//! // its there and is valid, `Err(_)` otherwise.
//! FromAttributes,
//! )]
//! pub struct MyAttr {
//! // Anything that implements `syn::parse::Parse` is supported.
//! mandatory_type: syn::Type,
//! mandatory_ident: syn::Ident,
//!
//! // Fields wrapped in `Option` are optional and default to `None` if
//! // not specified in the attribute.
//! optional_missing: Option<syn::Type>,
//! optional_given: Option<syn::Type>,
//!
//! // A "switch" is something that doesn't take arguments.
//! // All fields with type `Option<()>` are considered swiches.
//! // They default to `None`.
//! switch: Option<()>,
//! }
//!
//! // `MyAttr` is now equipped to parse attributes named `my_attr`. For example:
//! //
//! // #[my_attr(
//! // switch,
//! // mandatory_ident = foo,
//! // mandatory_type = SomeType,
//! // optional_given = OtherType,
//! // )]
//! // struct Foo {
//! // ...
//! // }
//!
//! // the input and output type would normally be `proc_macro::TokenStream` but those
//! // types cannot be used outside the compiler itself.
//! fn my_proc_macro(input: proc_macro2::TokenStream) -> proc_macro2::TokenStream {
//! let item_struct = syn::parse2::<syn::ItemStruct>(input).unwrap();
//!
//! let my_attr = MyAttr::from_attributes(&item_struct.attrs).unwrap();
//!
//! assert_eq!(
//! my_attr.mandatory_type,
//! syn::parse_str::<syn::Type>("SomeType").unwrap()
//! );
//!
//! assert_eq!(my_attr.optional_missing, None);
//!
//! assert_eq!(
//! my_attr.optional_given,
//! Some(syn::parse_str::<syn::Type>("OtherType").unwrap())
//! );
//!
//! assert_eq!(my_attr.mandatory_ident, syn::parse_str::<syn::Ident>("foo").unwrap());
//!
//! assert_eq!(my_attr.switch.is_some(), true);
//!
//! // ...
//! #
//! # quote::quote! {}
//! }
//! #
//! # fn main() {
//! # let code = quote::quote! {
//! # #[other_random_attr]
//! # #[my_attr(
//! # switch,
//! # mandatory_ident = foo,
//! # mandatory_type = SomeType,
//! # optional_given = OtherType,
//! # )]
//! # struct Foo;
//! # };
//! # my_proc_macro(code);
//! # }
//! ```
#![doc(html_root_url = "https://docs.rs/sea-bae/0.2.0")]
#![allow(clippy::let_and_return)]
#![deny(
unused_variables,
dead_code,
unused_must_use,
unused_imports,
missing_docs
)]
extern crate proc_macro;
use heck::ToSnakeCase;
use proc_macro2::TokenStream;
use quote::*;
use syn::{spanned::Spanned, *};
/// See root module docs for more info.
#[proc_macro_derive(FromAttributes, attributes())]
pub fn from_attributes(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
let item = parse_macro_input!(input as ItemStruct);
FromAttributes::new(item)
.expand()
.unwrap_or_else(syn::Error::into_compile_error)
.into()
}
#[derive(Debug)]
struct FromAttributes {
item: ItemStruct,
tokens: TokenStream,
}
impl FromAttributes {
fn new(item: ItemStruct) -> Self {
Self {
item,
tokens: TokenStream::new(),
}
}
fn expand(mut self) -> syn::Result<TokenStream> {
self.expand_from_attributes_method();
self.expand_parse_impl()?;
if std::env::var("BAE_DEBUG").is_ok() {
eprintln!("{}", self.tokens);
}
Ok(self.tokens)
}
fn struct_name(&self) -> &Ident {
&self.item.ident
}
fn attr_name(&self) -> LitStr {
let struct_name = self.struct_name();
let name = struct_name.to_string().to_snake_case();
LitStr::new(&name, struct_name.span())
}
fn expand_from_attributes_method(&mut self) {
let struct_name = self.struct_name();
let attr_name = self.attr_name();
let code = quote! {
impl #struct_name {
pub fn try_from_attributes(attrs: &[syn::Attribute]) -> syn::Result<Option<Self>> {
use syn::spanned::Spanned;
for attr in attrs {
if attr.path().is_ident(#attr_name) {
return Some(attr.parse_args::<Self>()).transpose()
}
}
Ok(None)
}
pub fn from_attributes(attrs: &[syn::Attribute]) -> syn::Result<Self> {
if let Some(attr) = Self::try_from_attributes(attrs)? {
Ok(attr)
} else {
Err(syn::Error::new(
proc_macro2::Span::call_site(),
&format!("missing attribute `#[{}]`", #attr_name),
))
}
}
}
};
self.tokens.extend(code);
}
fn expand_parse_impl(&mut self) -> syn::Result<()> {
let struct_name = self.struct_name();
let attr_name = self.attr_name();
let variable_declarations = self.item.fields.iter().map(|field| {
let name = &field.ident;
quote! { let mut #name = std::option::Option::None; }
});
let match_arms = self
.item
.fields
.iter()
.map(|field| {
let field_name = get_field_name(field)?;
let pattern = LitStr::new(&field_name.to_string(), field.span());
Ok(if field_is_switch(field)? {
quote! {
#pattern => {
#field_name = std::option::Option::Some(());
}
}
} else {
quote! {
#pattern => {
input.parse::<syn::Token![=]>()?;
#field_name = std::option::Option::Some(input.parse()?);
}
}
})
})
.collect::<syn::Result<Vec<_>>>()?;
let mut unwrap_mandatory_fields = Vec::new();
for field in &self.item.fields {
if field_is_optional(field)? {
continue;
}
let field_name = get_field_name(field)?;
let arg_name = LitStr::new(&field_name.to_string(), field.span());
unwrap_mandatory_fields.push(quote! {
let #field_name = if let std::option::Option::Some(#field_name) = #field_name {
#field_name
} else {
return syn::Result::Err(
input.error(
&format!("`#[{}]` is missing `{}` argument", #attr_name, #arg_name),
)
);
};
});
}
let set_fields = self
.item
.fields
.iter()
.map(|field| {
let field_name = get_field_name(field)?;
Ok(quote! { #field_name, })
})
.collect::<syn::Result<Vec<_>>>()?;
let mut supported_args = self
.item
.fields
.iter()
.map(|field| get_field_name(field).map(|field_name| format!("`{}`", field_name)))
.collect::<syn::Result<Vec<_>>>()?;
supported_args.sort_unstable();
let supported_args = supported_args.join(", ");
let code = quote! {
impl syn::parse::Parse for #struct_name {
#[allow(unreachable_code, unused_imports, unused_variables)]
fn parse(input: syn::parse::ParseStream) -> syn::Result<Self> {
#(#variable_declarations)*
while !input.is_empty() {
let bae_attr_ident = input.parse::<syn::Ident>()?;
match &*bae_attr_ident.to_string() {
#(#match_arms)*
other => {
return syn::Result::Err(
syn::Error::new(
bae_attr_ident.span(),
&format!(
"`#[{}]` got unknown `{}` argument. Supported arguments are {}",
#attr_name,
other,
#supported_args,
),
)
);
}
}
input.parse::<syn::Token![,]>().ok();
}
#(#unwrap_mandatory_fields)*
syn::Result::Ok(Self { #(#set_fields)* })
}
}
};
self.tokens.extend(code);
Ok(())
}
}
fn get_field_name(field: &Field) -> syn::Result<&Ident> {
field
.ident
.as_ref()
.ok_or_else(|| syn::Error::new(field.span(), "Field without a name"))
}
fn field_is_optional(field: &Field) -> syn::Result<bool> {
let type_path = if let Type::Path(type_path) = &field.ty {
type_path
} else {
return Ok(false);
};
let ident = &type_path
.path
.segments
.last()
.ok_or_else(|| syn::Error::new(field.span(), "Empty type path"))?
.ident;
Ok(ident == "Option")
}
fn field_is_switch(field: &Field) -> syn::Result<bool> {
let unit_type = syn::parse_str::<Type>("()").unwrap();
Ok(inner_type(&field.ty)? == Some(&unit_type))
}
fn inner_type(ty: &Type) -> syn::Result<Option<&Type>> {
let type_path = if let Type::Path(type_path) = ty {
type_path
} else {
return Ok(None);
};
let ty_args = &type_path
.path
.segments
.last()
.ok_or_else(|| syn::Error::new(ty.span(), "Empty type path"))?
.arguments;
let ty_args = if let PathArguments::AngleBracketed(ty_args) = ty_args {
ty_args
} else {
return Ok(None);
};
let generic_arg = ty_args
.args
.last()
.ok_or_else(|| syn::Error::new(ty_args.span(), "Empty generic argument"))?;
let ty = if let GenericArgument::Type(ty) = generic_arg {
ty
} else {
return Ok(None);
};
Ok(Some(ty))
}
#[cfg(test)]
mod test {
#[allow(unused_imports)]
use super::*;
#[test]
fn test_ui() {
let t = trybuild::TestCases::new();
t.pass("tests/compile_pass/*.rs");
t.compile_fail("tests/compile_fail/*.rs");
}
}