lloydmeta / frunk

Funktional generic type-level programming in Rust: HList, Coproduct, Generic, LabelledGeneric, Validated, Monoid and friends.
https://beachape.com/frunk/
MIT License
1.29k stars 58 forks source link

Drop `proc-macro-hack`, upgrade `syn` to 2 #214

Closed CobaltCause closed 1 year ago

CobaltCause commented 1 year ago

Fixes #213.

I also noticed

$ cargo upgrade --incompatible
# snip
$ git diff
diff --git a/laws/Cargo.toml b/laws/Cargo.toml
index e6ee421..c12a2bb 100644
--- a/laws/Cargo.toml
+++ b/laws/Cargo.toml
@@ -18,4 +18,4 @@ default-features = false
 version = "0.4.1"

 [dependencies]
-quickcheck = "0.6.1"
+quickcheck = "1.0.3"

but unfortunately the effects of this seem to show up in the public API.

ExpHP commented 1 year ago

Yes, I actually expected to see the proc-macros and proc-macros-impl crates be consolidated here.

CobaltCause commented 1 year ago

Done, although I just did it as "stupidly" as possible which caused some tests to go away. But I think what got deleted is duplicated here anyway:

https://github.com/lloydmeta/frunk/blob/ebcb73024c870935112fffb0d41415c4568ef3f7/core/src/path.rs#L42

Let me know if I need to add it back.

ExpHP commented 1 year ago

Can you use git mv for a cleaner diff? I suspect that the two files that were detected as deleted would be more accurately described as moved.

Please correct me if I'm wrong.

(If not familiar, you can do this in an interactive rebase (git rebase -i master). When it gets to that commit, git reset the deleted files to un-record the deletions, copy the files from impl back to proc-macros in your working tree, git rm the copies in proc-macros and git mv the copies in impl to proc-macros.)

On Thu, Jun 15, 2023, 2:26 PM Charles Hall @.***> wrote:

Done, although I just did it as "stupidly" as possible which caused some tests to go away. But I think what got deleted is duplicated here anyway:

https://github.com/lloydmeta/frunk/blob/ebcb73024c870935112fffb0d41415c4568ef3f7/core/src/path.rs#L42

— Reply to this email directly, view it on GitHub https://github.com/lloydmeta/frunk/pull/214#issuecomment-1593538824, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAKYRUF2I7N2G7EUNRZOIO3XLNHU7ANCNFSM6AAAAAAZG7TXIQ . You are receiving this because you were mentioned.Message ID: @.***>

CobaltCause commented 1 year ago

Hmm, git mv doesn't seem to make a difference in how git shows the diff. I think there'd have to be separate delete, move, and (maybe) edit commits for git to realize they were mostly just renamed, but not sure.

ExpHP commented 1 year ago

Okay, the way it is is fine then. I'll take a closer look in a sec.

think there'd have to be separate delete, move, and (maybe) edit commits for git to realize they were mostly just renamed, but not sure.

You definitely don't need separate move and edit commits as long as a decent portion of the file is unchanged (if it changes little enough you don't even need git mv for it to detect the move), but you might be right about the delete.

ExpHP commented 1 year ago

Okay, here's a more accurate diff of the files.

Diff for main..f7314cb9ab1 accounting for file move ```diff diff --git a/Cargo.toml b/Cargo.toml index 617209a..8deba14 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -58,7 +58,6 @@ codegen-units = 1 # https://users.rust-lang.org/t/odd-benchmark-results-compiler members = [ "proc-macro-helpers", "core", - "proc-macros-impl", "proc-macros", "derives", "laws" diff --git a/derives/Cargo.toml b/derives/Cargo.toml index 775b3ad..ccd1a38 100644 --- a/derives/Cargo.toml +++ b/derives/Cargo.toml @@ -16,7 +16,7 @@ travis-ci = { repository = "lloydmeta/frunk" } proc-macro = true [dependencies] -syn = "1" +syn = "2" quote = "1" [dependencies.frunk_proc_macro_helpers] diff --git a/proc-macro-helpers/Cargo.toml b/proc-macro-helpers/Cargo.toml index f9e4295..a2ea16c 100644 --- a/proc-macro-helpers/Cargo.toml +++ b/proc-macro-helpers/Cargo.toml @@ -13,7 +13,7 @@ keywords = ["Frunk", "macros", "internal"] travis-ci = { repository = "lloydmeta/frunk" } [dependencies] -syn = "1" +syn = "2" quote = "1" proc-macro2 = "1" diff --git a/proc-macro-helpers/src/lib.rs b/proc-macro-helpers/src/lib.rs index 0e8124b..94fbac3 100644 --- a/proc-macro-helpers/src/lib.rs +++ b/proc-macro-helpers/src/lib.rs @@ -20,8 +20,8 @@ use proc_macro2::{Span, TokenStream as TokenStream2}; use quote::ToTokens; use syn::spanned::Spanned; use syn::{ - DeriveInput, Expr, Field, Fields, GenericParam, Generics, Ident, Lifetime, LifetimeDef, Member, - Variant, + DeriveInput, Expr, Field, Fields, GenericParam, Generics, Ident, Lifetime, LifetimeParam, + Member, Variant, }; /// These are assumed to exist as enums in frunk_core::labelled @@ -325,7 +325,7 @@ pub fn ref_generics(generics: &Generics) -> Generics { // instantiate a lifetime and lifetime def to add let ref_lifetime = Lifetime::new("'_frunk_ref_", Span::call_site()); - let ref_lifetime_def = LifetimeDef::new(ref_lifetime.clone()); + let ref_lifetime_def = LifetimeParam::new(ref_lifetime.clone()); // Constrain the generic lifetimes present in the concrete type to the reference lifetime // of our implementation of LabelledGeneric for the reference case (& and &mut) diff --git a/proc-macros/Cargo.toml b/proc-macros/Cargo.toml index 91b85bd..4f4770f 100644 --- a/proc-macros/Cargo.toml +++ b/proc-macros/Cargo.toml @@ -1,21 +1,20 @@ [package] -name = "frunk_proc_macros_impl" +name = "frunk_proc_macros" edition = "2021" version = "0.1.1" authors = ["Lloyd "] -description = "Proc macros inernal implementations for Frunk" +description = "Proc macros for Frunk" license = "MIT" -documentation = "https://docs.rs/frunk_proc_macros_internal" +documentation = "https://docs.rs/frunk_proc_macros" repository = "https://github.com/lloydmeta/frunk" -keywords = ["Frunk", "macros", "internal"] +keywords = ["Frunk", "macros"] [badges] travis-ci = { repository = "lloydmeta/frunk" } [dependencies] -syn = "1" +syn = "2" quote = "1" -proc-macro-hack = "0.5" [lib] proc-macro = true @@ -30,3 +29,8 @@ version = "0.4.1" path = "../proc-macro-helpers" default-features = false version = "0.1.1" + +[dev-dependencies.frunk] +path = "../." +default-features = false +version = "0.4.1" diff --git a/proc-macros/src/lib.rs b/proc-macros/src/lib.rs index a724c7d..8a5d9ab 100644 --- a/proc-macros/src/lib.rs +++ b/proc-macros/src/lib.rs @@ -10,19 +10,17 @@ extern crate frunk_core; extern crate frunk_proc_macro_helpers; extern crate proc_macro; -extern crate proc_macro_hack; extern crate quote; extern crate syn; use frunk_proc_macro_helpers::*; use proc_macro::TokenStream; -use proc_macro_hack::proc_macro_hack; use quote::quote; use syn::{parse_macro_input, Expr}; /// Build a generic path that can be used for traversals -#[proc_macro_hack] +#[proc_macro] pub fn path(input: TokenStream) -> TokenStream { let expr = parse_macro_input!(input as Expr); let path_type = build_path_type(expr); ```
ExpHP commented 1 year ago

All looks good to me, only question is whether proc-macros/Cargo.toml should still have [dev-dependencies.frunk] since I think it no longer makes use of it. Or a small test using it could be shoehorned in. I don't have a strong feeling either way.

CobaltCause commented 1 year ago

I think it no longer makes use of it

I just tested and this is true, I've just removed it in a force-push.

lloydmeta commented 1 year ago

It's a bit late here, so I'll cut a release some time this weekend. Thanks!