Skip to content

Commit

Permalink
model-derive: add derive attributes at start of list
Browse files Browse the repository at this point in the history
Rust 1.52 added a legacy_derive_helpers warning (soon to be an error) that
yells if you use an attribute macro before the derive macro that introduces it.
We should always put derive macros at the start of the list to avoid this.

Reference: rust-lang/rust#79202
  • Loading branch information
tjkirch committed May 13, 2021
1 parent de765ec commit eba7dc5
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion sources/models/model-derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,10 @@ impl VisitMut for ModelHelper {
} else {
parse_quote!(#[derive(Debug, PartialEq, Serialize, Deserialize)])
};
node.attrs.push(attr);
// Rust 1.52 added a legacy_derive_helpers warning (soon to be an error) that yells if
// you use an attribute macro before the derive macro that introduces it. We should
// always put derive macros at the start of the list to avoid this.
node.attrs.insert(0, attr);
}

// Let the default implementation do its thing, recursively.
Expand Down

0 comments on commit eba7dc5

Please sign in to comment.