-
-
Notifications
You must be signed in to change notification settings - Fork 196
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #821 from SeaQL/sea-query-derive
Continue #769
- Loading branch information
Showing
30 changed files
with
482 additions
and
178 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
use sea_query_attr::enum_def; | ||
|
||
#[enum_def] | ||
enum Hello { | ||
Name, | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
error: #[enum_def] can only be used on structs | ||
--> tests/compile-fail/enum.rs:4:1 | ||
| | ||
4 | enum Hello { | ||
| ^^^^ | ||
|
||
warning: use of deprecated macro `enum_def`: use #[enum_def] attr defined in `sea-query-derive` crate | ||
--> tests/compile-fail/enum.rs:3:3 | ||
| | ||
3 | #[enum_def] | ||
| ^^^^^^^^ | ||
| | ||
= note: `#[warn(deprecated)]` on by default |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
use sea_query_attr::enum_def; | ||
|
||
#[enum_def] | ||
struct Hello(String); | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
error: #[enum_def] can only be used on structs | ||
--> tests/compile-fail/tuple_struct.rs:4:1 | ||
| | ||
4 | struct Hello(String); | ||
| ^^^^^^ | ||
|
||
warning: use of deprecated macro `enum_def`: use #[enum_def] attr defined in `sea-query-derive` crate | ||
--> tests/compile-fail/tuple_struct.rs:3:3 | ||
| | ||
3 | #[enum_def] | ||
| ^^^^^^^^ | ||
| | ||
= note: `#[warn(deprecated)]` on by default |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
use sea_query_attr::enum_def; | ||
|
||
#[enum_def(unknown_field)] | ||
pub struct Hello { | ||
pub name: String, | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
error: Unknown field: `unknown_field` | ||
--> tests/compile-fail/unknown_field.rs:3:12 | ||
| | ||
3 | #[enum_def(unknown_field)] | ||
| ^^^^^^^^^^^^^ | ||
|
||
warning: use of deprecated macro `enum_def`: use #[enum_def] attr defined in `sea-query-derive` crate | ||
--> tests/compile-fail/unknown_field.rs:3:3 | ||
| | ||
3 | #[enum_def(unknown_field)] | ||
| ^^^^^^^^ | ||
| | ||
= note: `#[warn(deprecated)]` on by default |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
sea-query-derive/src/error.rs → sea-query-derive/src/iden/error.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
pub(crate) mod attr; | ||
pub(crate) mod error; | ||
pub(crate) mod path; | ||
pub(crate) mod write_arm; | ||
|
||
use proc_macro2::TokenStream; | ||
use quote::quote; | ||
use syn::Ident; | ||
|
||
use self::write_arm::WriteArm; | ||
|
||
pub(crate) struct DeriveIden; | ||
|
||
impl WriteArm for DeriveIden { | ||
fn variant(variant: TokenStream, name: TokenStream) -> TokenStream { | ||
quote! { Self::#variant => write!(s, "{}", #name).unwrap() } | ||
} | ||
|
||
fn flattened(variant: TokenStream, name: &Ident) -> TokenStream { | ||
quote! { Self::#variant => #name.unquoted(s) } | ||
} | ||
} | ||
|
||
pub(crate) struct DeriveIdenStatic; | ||
|
||
impl WriteArm for DeriveIdenStatic { | ||
fn variant(variant: TokenStream, name: TokenStream) -> TokenStream { | ||
quote! { Self::#variant => #name } | ||
} | ||
|
||
fn flattened(variant: TokenStream, name: &Ident) -> TokenStream { | ||
quote! { Self::#variant => #name.as_str() } | ||
} | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.