ast: support attributes for `ast.SumType` (#13010)
parent
4d166e3b55
commit
9cbfa882e6
|
@ -1092,6 +1092,7 @@ pub:
|
|||
comments []Comment
|
||||
typ Type
|
||||
generic_types []Type
|
||||
attrs []Attr // attributes of type declaration
|
||||
pub mut:
|
||||
variants []TypeNode
|
||||
}
|
||||
|
|
|
@ -1293,6 +1293,7 @@ pub fn (mut f Fmt) fn_type_decl(node ast.FnTypeDecl) {
|
|||
}
|
||||
|
||||
pub fn (mut f Fmt) sum_type_decl(node ast.SumTypeDecl) {
|
||||
f.attrs(node.attrs)
|
||||
start_pos := f.out.len
|
||||
if node.is_pub {
|
||||
f.write('pub ')
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
[derive: 'DeserBincode,SerBincode']
|
||||
type OneOf = ItemA | ItemB
|
||||
|
||||
[derive: 'DeserBincode,SerBincode']
|
||||
struct ItemA {
|
||||
a string
|
||||
}
|
||||
|
||||
[derive: 'DeserBincode,SerBincode']
|
||||
struct ItemB {
|
||||
b int
|
||||
bb u64
|
||||
bbb string
|
||||
}
|
|
@ -3465,6 +3465,7 @@ fn (mut p Parser) type_decl() ast.TypeDecl {
|
|||
is_pub: is_pub
|
||||
variants: sum_variants
|
||||
generic_types: generic_types
|
||||
attrs: p.attrs
|
||||
pos: decl_pos
|
||||
comments: comments
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue