Preserve doc attributes on struct fields
diff --git a/syntax/impls.rs b/syntax/impls.rs
index c7e1a2c..624a64d 100644
--- a/syntax/impls.rs
+++ b/syntax/impls.rs
@@ -297,11 +297,13 @@
impl PartialEq for Var {
fn eq(&self, other: &Var) -> bool {
let Var {
+ doc: _,
visibility: _,
ident,
ty,
} = self;
let Var {
+ doc: _,
visibility: _,
ident: ident2,
ty: ty2,
@@ -313,6 +315,7 @@
impl Hash for Var {
fn hash<H: Hasher>(&self, state: &mut H) {
let Var {
+ doc: _,
visibility: _,
ident,
ty,
diff --git a/syntax/mod.rs b/syntax/mod.rs
index f6bdf72..092f403 100644
--- a/syntax/mod.rs
+++ b/syntax/mod.rs
@@ -150,6 +150,7 @@
}
pub struct Var {
+ pub doc: Doc,
pub visibility: Token![pub],
pub ident: Ident,
pub ty: Type,
diff --git a/syntax/parse.rs b/syntax/parse.rs
index 4bfabcd..3d970d8 100644
--- a/syntax/parse.rs
+++ b/syntax/parse.rs
@@ -97,6 +97,15 @@
let mut fields = Vec::new();
for field in named_fields.named {
let ident = field.ident.unwrap();
+ let mut doc = Doc::new();
+ attrs::parse(
+ cx,
+ &field.attrs,
+ attrs::Parser {
+ doc: Some(&mut doc),
+ ..Default::default()
+ },
+ );
let ty = match parse_type(&field.ty) {
Ok(ty) => ty,
Err(err) => {
@@ -111,6 +120,7 @@
Visibility::Inherited => ident.span(),
});
fields.push(Var {
+ doc,
visibility,
ident,
ty,
@@ -527,8 +537,10 @@
};
let ty = parse_type(&arg.ty)?;
if ident != "self" {
+ let doc = Doc::new();
let visibility = Token);
args.push_value(Var {
+ doc,
visibility,
ident,
ty,
@@ -1098,8 +1110,10 @@
Some(ident) => ident.0.clone(),
None => format_ident!("arg{}", i),
};
+ let doc = Doc::new();
let visibility = Token);
Ok(Var {
+ doc,
visibility,
ident,
ty,