-
Notifications
You must be signed in to change notification settings - Fork 3
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
Fix appending attributes instead of inserting them #3
Conversation
This fixes a warning (`legacy_derive_helpers`) about outer struct attributes being used before being declared. This warning is slated to become a hard error in the future.
Sorry for the force pushes, forgot to use the correct key+email+username combo |
mwe: src/main.rs use serde::{Serialize, Deserialize};
structstruck::strike!{
#[strikethrough[derive(Serialize, Deserialize)]]
struct Outer {
field:
#[serde(transparent)]
struct Transparent {
inner: struct Inner {
name: String,
}
}
}
}
fn main() {
println!("Hello, world!");
} |
Thanks for the PR. Can I ask you to make sure that it passes |
no problem, will do |
update `strikethrough_derive` test to validade this behaviour
Ive messed around for a bit trying to make this work, and this seems to be a ok compromise. It inserts non derive attributes after existing ones and inserts derive attributes before the existing attributes. I'm not sure this is the most optimal way to do it though, as it creates 2 vectors each time. |
This crate already allocates all over the place, no need to worry about a few more allocations. I do worry about the order though. Anyway. Would it help you if I did a release with this quickly? (e.g. because you want to publish a crate that depends on this one to crates.io) |
yes, please! Thanks a lot. |
This fixes a warning (
legacy_derive_helpers
) about outer struct attributes being used before being declared. This warning is slated to become a hard error in the future.Trying to use outer struct attributes with
strikethrough
work, but seems like it may fail in the future.Trying to compile a minimal example shows:
Indicating probably that it adds the
#[derive(Attr)]
after the outer attributes.Tracking issue: rust-lang/rust#79202