-
Notifications
You must be signed in to change notification settings - Fork 13k
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
return of #39347: feature(proc_macro) breaks attributes on custom derive #44925
Comments
This just got a whole lot more confusing (to me at least). I just discovered that I can successfully use serde's So for example, evesteras's serde example in #39347 compiles fine, but LukasKalbertodt's Diesel example does not. This is within the same project, so rustc/cargo/enabled features, etc. are exactly the same. I'm not familiar enough with the whole |
I looked into this a little more. When using Diesel, it is common for specific structs to derive multiple Diesel-related traits (e.g., This could be fixed by "namespacing"the attributes (e.g., |
I have also his this issue |
Are there any workarounds? |
What I am doing to work around this is setting my project up as a workspace. I have all of my project in one main crate (in which I am using the proc_macro feature), except for my database stuff (since in my case Diesel is the only thing hitting this issue), which I am putting in a |
@kardeiz thanks for your help! I'll try to do the same :) |
This is done so that we can use proc_macros in the main crate, for Maud templating. Due to a rustc bug (rust-lang/rust#44925), #![feature(proc_macros)] and custom derive attributes don't play nice together, so switching on proc_macros breaks Diesel derives. Thankfully, just splitting the Diesel code out into its own crate and depending on it works fine, since crates are a feature boundary.
This is done so that we can use proc_macros in the main crate, for Maud templating. Due to a rustc bug (rust-lang/rust#44925), #![feature(proc_macros)] and custom derive attributes don't play nice together, so switching on proc_macros breaks Diesel derives. Thankfully, just splitting the Diesel code out into its own crate and depending on it works fine, since crates are a feature boundary.
This is still an issue on the most recent nightlies |
I cannot reproduce this issue today, and it's been over a year since the last comment. I'm going to give this a close, but let me know if I'm missing something! |
Recent versions of Rust nightly seem to have the exact same issue as initially reported in #39347 (albeit with a slightly different error message: e.g.,
error: cannot find attribute macro
belongs_toin this scope
).See the recent comment on #39347 by LukasKalbertodt for more details.
I know nothing about Rust's internals, but it seems like the issue is overzealous checking by
proc_macro
in https://github.com/rust-lang/rust/blob/master/src/librustc_resolve/macros.rs#L587.The text was updated successfully, but these errors were encountered: