diff --git a/vlib/v/ast/ast.v b/vlib/v/ast/ast.v index 303a5963d3991f..3edb70abc5c18b 100644 --- a/vlib/v/ast/ast.v +++ b/vlib/v/ast/ast.v @@ -324,7 +324,6 @@ pub: comments []Comment i int has_default_expr bool - attrs_has_at bool // TODO: remove in next stage attrs []Attr is_pub bool default_val string diff --git a/vlib/v/fmt/struct.v b/vlib/v/fmt/struct.v index 07a510a8d3b119..2fd22943d03106 100644 --- a/vlib/v/fmt/struct.v +++ b/vlib/v/fmt/struct.v @@ -145,8 +145,9 @@ pub fn (mut f Fmt) struct_decl(node ast.StructDecl, is_anon bool) { f.mark_types_import_as_used(field.typ) attrs_len := inline_attrs_len(field.attrs) has_attrs := field.attrs.len > 0 + has_at := if has_attrs { field.attrs[0].has_at } else { false } // TODO: this will get removed in next stage - if has_attrs && !field.attrs_has_at { + if has_attrs && !has_at { f.write(strings.repeat(` `, field_align.max_type_len - field_types[i].len)) f.single_line_attrs(field.attrs, same_line: true) } @@ -168,8 +169,8 @@ pub fn (mut f Fmt) struct_decl(node ast.StructDecl, is_anon bool) { inc_indent = false } } - if has_attrs && field.attrs_has_at { - // TODO: calculate correct padding + if has_attrs && has_at { + f.write(strings.repeat(` `, field_align.max_type_len - field_types[i].len)) f.single_line_attrs(field.attrs, same_line: true) } // Handle comments after field type diff --git a/vlib/v/parser/struct.v b/vlib/v/parser/struct.v index 7064bce7220671..c730ea882f0827 100644 --- a/vlib/v/parser/struct.v +++ b/vlib/v/parser/struct.v @@ -295,9 +295,7 @@ fn (mut p Parser) struct_decl(is_anon bool) ast.StructDecl { has_default_expr = true comments << p.eat_comments() } - mut has_at := false // TODO: remove in next stage if p.tok.kind == .at { - has_at = true p.inside_struct_attr_decl = true // attrs are stored in `p.attrs` p.attributes() @@ -318,7 +316,6 @@ fn (mut p Parser) struct_decl(is_anon bool) ast.StructDecl { i: i default_expr: default_expr has_default_expr: has_default_expr - attrs_has_at: has_at attrs: p.attrs is_pub: is_embed || is_field_pub is_mut: is_embed || is_field_mut