Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 3 commits into from
Jun 16, 2023

Conversation

CobaltCause
Copy link
Contributor

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.

It isn't needed for Rust versions outside of [1.31, 1.45] and `frunk` is
on `edition = "2021"` anyway.
Only affected by 1 breaking change, which was just a rename!
Copy link
Owner

@lloydmeta lloydmeta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM @ExpHP did you want to take a look as well since you commented in #213?

I'm curious also if we can just remove proc-macros-impl (and move its things into proc-macros) at this point 🤔

@ExpHP
Copy link
Collaborator

ExpHP commented Jun 15, 2023

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

@CobaltCause
Copy link
Contributor Author

CobaltCause commented Jun 15, 2023

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:

//! ```

Let me know if I need to add it back.

@ExpHP
Copy link
Collaborator

ExpHP commented Jun 15, 2023 via email

@CobaltCause
Copy link
Contributor Author

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
Copy link
Collaborator

ExpHP commented Jun 15, 2023

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
Copy link
Collaborator

ExpHP commented Jun 15, 2023

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

Diff for main..f7314cb accounting for file move
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 <lloydmeta@gmail.com>"]
-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
Copy link
Collaborator

ExpHP commented Jun 15, 2023

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
Copy link
Contributor Author

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 lloydmeta merged commit 3d15dd9 into lloydmeta:master Jun 16, 2023
@lloydmeta
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Drop proc-macro-hack, upgrade syn to 2
3 participants