Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion hyperdb-api-derive/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ proc-macro = true
compile-time = ["dep:hyperdb-compile-check"]

[dependencies]
syn = { version = "2", features = ["full"] }
syn = { version = "3", features = ["full"] }
quote = "1"
proc-macro2 = "1"
# x-release-please-start-version
Expand Down
10 changes: 8 additions & 2 deletions hyperdb-api-derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,10 @@ fn expand_query_as(input: &TokenStream2) -> syn::Result<TokenStream2> {
/// Only needed when `compile-time` feature is enabled (used for registry lookup).
#[cfg(feature = "compile-time")]
fn last_type_ident(ty: &Type) -> Option<&syn::Ident> {
let Type::Path(syn::TypePath { path, qself: None }) = ty else {
let Type::Path(syn::TypePath {
path, qself: None, ..
}) = ty
else {
return None;
};
path.segments.last().map(|s| &s.ident)
Expand Down Expand Up @@ -397,7 +400,10 @@ fn field_source_for(field: &Field, default: &syn::Ident) -> syn::Result<FieldSou

/// Detects `Option<T>` (any path ending in `Option<T>`).
fn is_option_type(ty: &Type) -> bool {
let Type::Path(TypePath { path, qself: None }) = ty else {
let Type::Path(TypePath {
path, qself: None, ..
}) = ty
else {
return false;
};
let Some(last) = path.segments.last() else {
Expand Down
17 changes: 13 additions & 4 deletions hyperdb-api-derive/src/table_derive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,10 @@ fn rust_type_to_sql<'a>(field: &Field, ty: &'a Type) -> syn::Result<&'a str> {

/// If `ty` is `Option<T>`, return `(T, true)`. Otherwise return `(ty, false)`.
fn unwrap_option(ty: &Type) -> (&Type, bool) {
let Type::Path(TypePath { path, qself: None }) = ty else {
let Type::Path(TypePath {
path, qself: None, ..
}) = ty
else {
return (ty, false);
};
let Some(last) = path.segments.last() else {
Expand All @@ -323,7 +326,10 @@ fn unwrap_option(ty: &Type) -> (&Type, bool) {

/// Returns `true` if `ty` is exactly `Vec<u8>` (the only `Vec<_>` that maps to BYTES).
fn is_vec_u8(ty: &Type) -> bool {
let Type::Path(TypePath { path, qself: None }) = ty else {
let Type::Path(TypePath {
path, qself: None, ..
}) = ty
else {
return false;
};
let Some(last) = path.segments.last() else {
Expand All @@ -337,14 +343,17 @@ fn is_vec_u8(ty: &Type) -> bool {
};
matches!(
args.args.first(),
Some(GenericArgument::Type(Type::Path(TypePath { path, qself: None })))
Some(GenericArgument::Type(Type::Path(TypePath { path, qself: None, .. })))
if path.is_ident("u8")
)
}

/// Extract the last path segment ident from a type, if it's a simple `TypePath`.
fn last_path_ident(ty: &Type) -> Option<&syn::Ident> {
let Type::Path(TypePath { path, qself: None }) = ty else {
let Type::Path(TypePath {
path, qself: None, ..
}) = ty
else {
return None;
};
path.segments.last().map(|s| &s.ident)
Expand Down