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

Future incompatibility with Rust RFC 3373: Avoid non-local definitions in functions #16

Open
Urgau opened this issue Feb 4, 2024 · 0 comments

Comments

@Urgau
Copy link

Urgau commented Feb 4, 2024

Rust RFC 3373: Avoid non-local definitions in functions was accepted and it's implementation at rust-lang/rust#120393 found that this crate would be affected by it.

To be more precise users of this crate would be affected by it, in the form of a warn-by-default lint: non_local_definitions. This is because the derive macros from this crate use impl in a local context, const _DERIVE_Endpoint_FOR_???:

let const_name = format!("_DERIVE_Endpoint_FOR_{}", id);
let const_ident = Ident::new(const_name.as_str(), Span::call_site());
quote! {
const #const_ident: () = {

Fortunately I believe a simple fix exist for this crate, by using a const-anon instead of named one (since const-anon are specialized to be "transparent" to their parent):

-    let const_name = format!("_DERIVE_Endpoint_FOR_{}", id);
-    let const_ident = Ident::new(const_name.as_str(), Span::call_site());
     quote! {
-        const #const_ident: () = {
+        const _: () = {

I would suggest applying some form of the patch above as well as releasing a patch version of this crate, as to have a fix available for users before or just after the PR is merged.

cc @jmgilman

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

No branches or pull requests

1 participant