Repository: TedDriggs/darling (rust)

Issue:
`forward_attrs` is ignored by `#[derive(FromAttributes)]`
# Reproduction
```rust
use darling::FromAttributes;

#[derive(darling::FromAttributes)]
#[darling(attributes(builder, forward_attrs))]
struct Params {
    default: Option<syn::Expr>,
    attrs: Vec<syn::Attributes>,
}
```

The code generated by `darling` doesn't compile in this case because it doesn't initialize the `attrs` field.

Pull request description:
Properly forward attrs in FromAttributes
Fixes #295

Patch:
diff --git a/core/src/codegen/from_attributes_impl.rs b/core/src/codegen/from_attributes_impl.rs
index 0dc1f25..1e40c26 100644
--- a/core/src/codegen/from_attributes_impl.rs
+++ b/core/src/codegen/from_attributes_impl.rs
@@ -38,6 +38,7 @@ impl ToTokens for FromAttributesImpl<'_> {
             }
         }
 
+        let passed_attrs = self.forward_attrs.as_initializer();
         let inits = self.base.initializers();
         let default = self.base.fallback_decl();
 
@@ -61,6 +62,7 @@ impl ToTokens for FromAttributesImpl<'_> {
                     #default
 
                     ::darling::export::Ok(#ty_ident {
+                        #passed_attrs
                         #inits
                     }) #post_transform
                 }
diff --git a/core/src/options/from_attributes.rs b/core/src/options/from_attributes.rs
index dc11b29..d642291 100644
--- a/core/src/options/from_attributes.rs
+++ b/core/src/options/from_attributes.rs
@@ -62,7 +62,7 @@ impl<'a> From<&'a FromAttributesOptions> for FromAttributesImpl<'a> {
         FromAttributesImpl {
             base: (&v.base.container).into(),
             attr_names: &v.base.attr_names,
-            forward_attrs: Default::default(),
+            forward_attrs: v.base.as_forward_attrs(),
         }
     }
 }


Test patch:
diff --git a/tests/forward_attrs_to_from_attributes.rs b/tests/forward_attrs_to_from_attributes.rs
new file mode 100644
index 0000000..292cd21
--- /dev/null
+++ b/tests/forward_attrs_to_from_attributes.rs
@@ -0,0 +1,22 @@
+use darling::FromAttributes;
+use syn::parse_quote;
+
+#[derive(Default, darling::FromAttributes)]
+#[darling(attributes(builder), forward_attrs)]
+struct Params {
+    default: Option<syn::Expr>,
+    attrs: Vec<syn::Attribute>,
+}
+
+#[test]
+fn forward_attrs_with_field() {
+    let input: syn::DeriveInput = parse_quote! {
+        #[doc = "Hello"]
+        #[builder(default = 15)]
+        struct Example;
+    };
+
+    let parsed = Params::from_attributes(&input.attrs).unwrap();
+    assert!(parsed.default.is_some());
+    assert_eq!(parsed.attrs.len(), 1);
+}