diff options
author | Brian Olsen <brian@maven-group.org> | 2024-08-28T13·45+0200 |
---|---|---|
committer | clbot <clbot@tvl.fyi> | 2024-08-28T14·43+0000 |
commit | a5fcfd80a16d985bcef7011ad94eab86cc0b4a72 (patch) | |
tree | 00d6f3fcea7d4da814eb31dce1bc3a2cef7850dc /tvix/nix-compat-derive/src/lib.rs | |
parent | 743407e7abf9cf56274c8c9bcb1edb10d8f943ed (diff) |
fix(tvix/nix-compat-derive): Get rid of external feature flag r/8602
The external feature flag was there because I couldn't find a way to refer to crate and nix-compat with the same name so that the generated code could be the same. In essence `use nix_compat::nix_daemon::de::NixDeserialize` is an error when used inside nix_compat crate. So my best fix was the external feature flag until I found the solution used here which also removes the flag completely. Change-Id: Ia3e89c6c350c3fb22ca87f974a39c21542aae152 Reviewed-on: https://cl.tvl.fyi/c/depot/+/12376 Tested-by: BuildkiteCI Reviewed-by: flokli <flokli@flokli.de> Autosubmit: Brian Olsen <me@griff.name>
Diffstat (limited to 'tvix/nix-compat-derive/src/lib.rs')
-rw-r--r-- | tvix/nix-compat-derive/src/lib.rs | 45 |
1 files changed, 0 insertions, 45 deletions
diff --git a/tvix/nix-compat-derive/src/lib.rs b/tvix/nix-compat-derive/src/lib.rs index 59ed9a4f170c..e3faed02ebab 100644 --- a/tvix/nix-compat-derive/src/lib.rs +++ b/tvix/nix-compat-derive/src/lib.rs @@ -261,17 +261,6 @@ use syn::{parse_quote, DeriveInput}; mod de; mod internal; -#[cfg(not(feature = "external"))] -#[proc_macro_derive(NixDeserialize, attributes(nix))] -pub fn derive_nix_deserialize(item: TokenStream) -> TokenStream { - let mut input = syn::parse_macro_input!(item as DeriveInput); - let nnixrs: syn::Path = parse_quote!(crate); - de::expand_nix_deserialize(nnixrs, &mut input) - .unwrap_or_else(syn::Error::into_compile_error) - .into() -} - -#[cfg(feature = "external")] #[proc_macro_derive(NixDeserialize, attributes(nix))] pub fn derive_nix_deserialize(item: TokenStream) -> TokenStream { let mut input = syn::parse_macro_input!(item as DeriveInput); @@ -304,40 +293,6 @@ pub fn derive_nix_deserialize(item: TokenStream) -> TokenStream { /// /// nix_deserialize_remote!(#[nix(from="u64")] MyU64); /// ``` -#[cfg(not(feature = "external"))] -#[proc_macro] -pub fn nix_deserialize_remote(item: TokenStream) -> TokenStream { - let input = syn::parse_macro_input!(item as RemoteInput); - let crate_path = parse_quote!(crate); - de::expand_nix_deserialize_remote(crate_path, &input) - .unwrap_or_else(syn::Error::into_compile_error) - .into() -} - -/// Macro to implement `NixDeserialize` on a type. -/// Sometimes you can't use the deriver to implement `NixDeserialize` -/// (like when dealing with types in Rust standard library) but don't want -/// to implement it yourself. So this macro can be used for those situations -/// where you would derive using `#[nix(from_str)]`, -/// `#[nix(from = "FromType")]` or `#[nix(try_from = "FromType")]` if you -/// could. -/// -/// #### Example -/// -/// ```rust -/// # use nix_compat_derive::nix_deserialize_remote; -/// # -/// struct MyU64(u64); -/// -/// impl From<u64> for MyU64 { -/// fn from(value: u64) -> Self { -/// Self(value) -/// } -/// } -/// -/// nix_deserialize_remote!(#[nix(from="u64")] MyU64); -/// ``` -#[cfg(feature = "external")] #[proc_macro] pub fn nix_deserialize_remote(item: TokenStream) -> TokenStream { let input = syn::parse_macro_input!(item as RemoteInput); |