-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Error if
attrs
field is declared and forward_attrs
is missing.
Previously, this would result in a cryptic error due to an expect(...) failure if neither `attributes` nor `forward_attrs` were declared. This change is technically breaking, as it was previously possible to declare this field without using `forward_attrs`; if `attributes` was used the `attrs` field would be initialized to an empty array. That behavior was more likely to mask issues than be useful, but it's possible someone declared the field in order to manually populate it later. Fixes #317
- Loading branch information
Showing
3 changed files
with
32 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
use darling::FromDeriveInput; | ||
use syn::{Attribute, Ident}; | ||
|
||
#[derive(FromDeriveInput)] | ||
struct HelloArgs { | ||
ident: Ident, | ||
attrs: Vec<Attribute>, | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
error: field will not be populated because `forward_attrs` is not set on the struct | ||
--> tests/compile-fail/attrs_without_forward_attrs.rs:7:5 | ||
| | ||
7 | attrs: Vec<Attribute>, | ||
| ^^^^^ |