Skip to content

Commit ddb6685

Browse files
authored
fmt: fix and simplify align of struct fields (#21995)
1 parent 576a0ab commit ddb6685

File tree

139 files changed

+553
-519
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

139 files changed

+553
-519
lines changed

.github/workflows/v_apps_and_modules_compile_ci.yml

+12-12
Original file line numberDiff line numberDiff line change
@@ -155,18 +155,18 @@ jobs:
155155
echo "Build v-analyzer release"
156156
v build.vsh release
157157
158-
- name: Format vlang/v-analyzer
159-
if: ${{ !cancelled() && steps.build.outcome == 'success' }}
160-
run: |
161-
cd /tmp/v-analyzer
162-
set +e
163-
v fmt -c .
164-
exit_code=$?
165-
if [[ $exit_code -ne 0 && $exit_code -ne 5 ]]; then
166-
# Don't fail if there are only internal errors (exit code 5).
167-
v fmt -diff .
168-
exit 1
169-
fi
158+
# - name: Format vlang/v-analyzer
159+
# if: ${{ !cancelled() && steps.build.outcome == 'success' }}
160+
# run: |
161+
# cd /tmp/v-analyzer
162+
# set +e
163+
# v fmt -c .
164+
# exit_code=$?
165+
# if [[ $exit_code -ne 0 && $exit_code -ne 5 ]]; then
166+
# # Don't fail if there are only internal errors (exit code 5).
167+
# v fmt -diff .
168+
# exit 1
169+
# fi
170170

171171
- name: Build vlang/go2v
172172
if: ${{ !cancelled() && steps.build.outcome == 'success' && matrix.os != 'macos-14' }}

cmd/tools/modules/testing/common.v

+2-2
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,9 @@ pub mut:
8787
show_stats bool
8888
show_asserts bool
8989
progress_mode bool
90-
root_relative bool // used by CI runs, so that the output is stable everywhere
90+
root_relative bool // used by CI runs, so that the output is stable everywhere
9191
nmessages chan LogMessage // many publishers, single consumer/printer
92-
nmessage_idx int // currently printed message index
92+
nmessage_idx int // currently printed message index
9393
failed_cmds shared []string
9494
reporter Reporter = Reporter(NormalReporter{})
9595
hash string // used as part of the name of the temporary directory created for tests, to ease cleanup

cmd/tools/modules/vgit/vgit.v

+2-2
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,8 @@ pub fn clone_or_pull(remote_git_url string, local_worktree_path string) {
121121

122122
pub struct VGitContext {
123123
pub:
124-
cc string = 'cc' // what compiler to use
125-
workdir string = '/tmp' // the base working folder
124+
cc string = 'cc' // what compiler to use
125+
workdir string = '/tmp' // the base working folder
126126
commit_v string = 'master' // the commit-ish that needs to be prepared
127127
path_v string // where is the local working copy v repo
128128
path_vc string // where is the local working copy vc repo

cmd/tools/oldv.v

+5-5
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@ mut:
3535
path_vc string // the full path to the vc folder inside workdir.
3636
cmd_to_run string // the command that you want to run *in* the oldv repo
3737
cc string = 'cc' // the C compiler to use for bootstrapping.
38-
cleanup bool // should the tool run a cleanup first
39-
use_cache bool // use local cached copies for --vrepo and --vcrepo in
40-
fresh_tcc bool // do use `make fresh_tcc`
41-
is_bisect bool // bisect mode; usage: `cmd/tools/oldv -b -c './v run bug.v'`
42-
show_vccommit bool // show the V and VC commits, corresponding to the V commit-ish, that can be used to build V
38+
cleanup bool // should the tool run a cleanup first
39+
use_cache bool // use local cached copies for --vrepo and --vcrepo in
40+
fresh_tcc bool // do use `make fresh_tcc`
41+
is_bisect bool // bisect mode; usage: `cmd/tools/oldv -b -c './v run bug.v'`
42+
show_vccommit bool // show the V and VC commits, corresponding to the V commit-ish, that can be used to build V
4343
}
4444

4545
fn (mut c Context) compile_oldv_if_needed() {

cmd/tools/vcover/main.v

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ mut:
2626
meta map[string]MetaData // aggregated meta data, read from all .json files
2727
all_lines_per_file map[string][]int // aggregated by load_meta
2828
//
29-
counters map[string]u64 // incremented by process_target, based on each .csv file
29+
counters map[string]u64 // incremented by process_target, based on each .csv file
3030
lines_per_file map[string]map[int]int // incremented by process_target, based on each .csv file
3131
processed_points u64
3232
}

cmd/tools/vpm/vcs.v

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ enum VCS {
1010
}
1111

1212
struct VCSInfo {
13-
dir string @[required]
13+
dir string @[required]
1414
args struct {
1515
install string @[required]
1616
version string @[required] // flag to specify a version, added to install.

cmd/tools/vrepl.v

+13-13
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,20 @@ mut:
2323
folder string // the folder in which the repl will write its temporary source files
2424
last_output string // the last repl output
2525
//
26-
modules []string // all the import modules
26+
modules []string // all the import modules
2727
alias map[string]string // all the alias used in the import
28-
includes []string // all the #include statements
29-
functions []string // all the user function declarations
30-
functions_name []string // all the user function names
31-
structs []string // all the struct definitions
32-
enums []string // all the enum definitions
33-
consts []string // all the const definitions
34-
types []string // all the type definitions
35-
interfaces []string // all the interface definitions
36-
lines []string // all the other lines/statements
37-
temp_lines []string // all the temporary expressions/printlns
38-
vstartup_lines []string // lines in the `VSTARTUP` file
39-
eval_func_lines []string // same line of the `VSTARTUP` file, but used to test fn type
28+
includes []string // all the #include statements
29+
functions []string // all the user function declarations
30+
functions_name []string // all the user function names
31+
structs []string // all the struct definitions
32+
enums []string // all the enum definitions
33+
consts []string // all the const definitions
34+
types []string // all the type definitions
35+
interfaces []string // all the interface definitions
36+
lines []string // all the other lines/statements
37+
temp_lines []string // all the temporary expressions/printlns
38+
vstartup_lines []string // lines in the `VSTARTUP` file
39+
eval_func_lines []string // same line of the `VSTARTUP` file, but used to test fn type
4040
}
4141

4242
const is_stdin_a_pipe = os.is_atty(0) == 0

cmd/tools/vtest-all.v

+4-4
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,10 @@ mut:
7474
errmsg string
7575
rmfile string
7676
runcmd RunCommandKind = .system
77-
expect string = expect_nothing
78-
starts_with string = starts_with_nothing
79-
ends_with string = ends_with_nothing
80-
contains string = contains_nothing
77+
expect string = expect_nothing
78+
starts_with string = starts_with_nothing
79+
ends_with string = ends_with_nothing
80+
contains string = contains_nothing
8181
output string
8282
before_cb FnCheck = unsafe { nil }
8383
after_cb FnCheck = unsafe { nil }

cmd/tools/vvet/errors.v

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ pub mut:
2828
kind ErrorKind @[required]
2929
pub:
3030
// General message
31-
message string @[required]
31+
message string @[required]
3232
details string // Details about how to resolve or fix the situation
3333
file_path string // file where the error have origin
3434
pos token.Pos // position in the file

doc/docs.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -5136,7 +5136,7 @@ import db.sqlite
51365136
// sets a custom table name. Default is struct name (case-sensitive)
51375137
@[table: 'customers']
51385138
struct Customer {
5139-
id int @[primary; sql: serial] // a field named `id` of integer type must be the first field
5139+
id int @[primary; sql: serial] // a field named `id` of integer type must be the first field
51405140
name string
51415141
nr_orders int
51425142
country ?string
@@ -7895,4 +7895,4 @@ Assignment Operators
78957895
&= |= ^=
78967896
>>= <<= >>>=
78977897
&&= ||=
7898-
```
7898+
```

examples/brainvuck.v

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ const show_state = os.getenv('VERBOSE') != ''
1111

1212
struct BFState {
1313
mut:
14-
pc u16 // program counter (PC) register
15-
address u16 // a 16-bit address register, serving as an index to the memory below
16-
program string // the BF program
14+
pc u16 // program counter (PC) register
15+
address u16 // a 16-bit address register, serving as an index to the memory below
16+
program string // the BF program
1717
memory []u8 = []u8{len: 65536} // we have 2^16 bytes of memory
1818
targets map[int]int // a mapping for the program address of a `[` to its corresponding `]`, and from a `]` to its corresponding opening `[`.
1919
}

examples/clock/clock.v

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ struct App {
4242
mut:
4343
gg &gg.Context = unsafe { nil }
4444
draw_flag bool = true
45-
dpi_scale f32 = 1.0
45+
dpi_scale f32 = 1.0
4646
}
4747

4848
fn on_frame(mut app App) {

examples/database/orm.v

+4-4
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ const pg_db = os.getenv_opt('PGDATABASE') or { 'test' }
3333

3434
@[table: 'modules']
3535
struct Module {
36-
id int @[primary; sql: serial]
36+
id int @[primary; sql: serial]
3737
name string
38-
nr_downloads int @[sql: u64]
38+
nr_downloads int @[sql: u64]
3939
creator User
4040
}
4141

@@ -48,13 +48,13 @@ struct User {
4848
}
4949

5050
struct Parent {
51-
id int @[primary; sql: serial]
51+
id int @[primary; sql: serial]
5252
name string
5353
children []Child @[fkey: 'parent_id']
5454
}
5555

5656
struct Child {
57-
id int @[primary; sql: serial]
57+
id int @[primary; sql: serial]
5858
parent_id int
5959
name string
6060
}

examples/flag/animated_help_text.v

+5-5
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ import term.ui as tui
22
import flag
33

44
struct DocTest {
5-
show_version bool @[short: v; xdoc: 'Show version and exit']
6-
debug_level int @[long: debug; short: d; xdoc: 'Debug level']
7-
level f32 @[only: l; xdoc: 'Do not show this']
5+
show_version bool @[short: v; xdoc: 'Show version and exit']
6+
debug_level int @[long: debug; short: d; xdoc: 'Debug level']
7+
level f32 @[only: l; xdoc: 'Do not show this']
88
example string
99
square bool
10-
multi int @[only: m; repeats]
11-
wroom []int @[short: w]
10+
multi int @[only: m; repeats]
11+
wroom []int @[short: w]
1212
the_limit string
1313
}
1414

examples/flag/flag_layout_editor.v

+5-5
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ import flag
44
@[name: 'flag_layout_editor']
55
@[version: '1.0']
66
struct DocTest {
7-
show_version bool @[short: v; xdoc: 'Show version and exit']
8-
debug_level int @[long: debug; short: d; xdoc: 'Debug level']
9-
level f32 @[only: l; xdoc: 'Do not show this']
7+
show_version bool @[short: v; xdoc: 'Show version and exit']
8+
debug_level int @[long: debug; short: d; xdoc: 'Debug level']
9+
level f32 @[only: l; xdoc: 'Do not show this']
1010
example string
1111
square bool
12-
multi int @[only: m; repeats]
13-
wroom []int @[short: w]
12+
multi int @[only: m; repeats]
13+
wroom []int @[short: w]
1414
the_limit string
1515
}
1616

examples/gg/bezier.v

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const points = [f32(200.0), 200.0, 200.0, 100.0, 400.0, 100.0, 400.0, 300.0]
88
struct App {
99
mut:
1010
gg &gg.Context = unsafe { nil }
11-
steps int = 30
11+
steps int = 30
1212
}
1313

1414
fn main() {

examples/js_dom_draw_benchmark_chart/chart/main.v

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import v.util.version
1111
@[table: 'benchmark']
1212
struct Task {
1313
mut:
14-
id u32 @[primary; serial; sql: serial]
14+
id u32 @[primary; serial; sql: serial]
1515
title string
1616
status string
1717
}

examples/js_dom_draw_benchmark_chart/v_vweb_orm/src/main.v

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ struct App {
1111
@[table: 'benchmark']
1212
struct Task {
1313
mut:
14-
id u32 @[primary; serial; sql: serial]
14+
id u32 @[primary; serial; sql: serial]
1515
title string
1616
status string
1717
}

examples/sokol/06_obj_viewer/modules/obj/struct.v

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ pub mut:
5353
mat_map map[string]int // mapping material name to its material index
5454
texture map[string]gfx.Image // GPU loaded texture map
5555
sampler map[string]gfx.Sampler // GPU loaded sampler
56-
material_file string // .mtl file name for the .obj
56+
material_file string // .mtl file name for the .obj
5757

5858
rend_data []Render_data // render data used for the rendering
5959

examples/sokol/sounds/melody.v

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import sokol.audio
33

44
struct AppState {
55
mut:
6-
frame_0 int // offset of the current audio frames, relative to the start of the music
7-
frames [2048]f32 // a copy of the last rendered audio frames
6+
frame_0 int // offset of the current audio frames, relative to the start of the music
7+
frames [2048]f32 // a copy of the last rendered audio frames
88
gg &gg.Context = unsafe { nil } // used for drawing
99
}
1010

examples/term.ui/term_drawing.v

+2-2
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@ mut:
9898
secondary_color_idx int = 28
9999
bg_color ui.Color = ui.Color{0, 0, 0}
100100
drawing [][]ui.Color = [][]ui.Color{len: h, init: []ui.Color{len: w}}
101-
size int = 1
102-
should_redraw bool = true
101+
size int = 1
102+
should_redraw bool = true
103103
is_dragging bool
104104
}
105105

examples/term.ui/vyper.v

+1-1
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ mut:
245245
}
246246
captured bool
247247
color termui.Color = grey
248-
app &App = unsafe { nil }
248+
app &App = unsafe { nil }
249249
}
250250

251251
// randomize spawn the rat in a new spot within the playable field

examples/viewer/view.v

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ mut:
9090
show_help_flag bool
9191
// zip container
9292
zip &szip.Zip = unsafe { nil } // pointer to the szip structure
93-
zip_index int = -1 // index of the zip container item
93+
zip_index int = -1 // index of the zip container item
9494
// memory buffer
9595
mem_buf voidptr // buffer used to load items from files/containers
9696
mem_buf_size int // size of the buffer

examples/vweb_fullstack/src/product_entities.v

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ module main
22

33
@[table: 'products']
44
struct Product {
5-
id int @[primary; sql: serial]
5+
id int @[primary; sql: serial]
66
user_id int
77
name string @[sql_type: 'TEXT']
88
created_at string @[default: 'CURRENT_TIMESTAMP']

examples/vweb_fullstack/src/user_entities.v

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ module main
33
@[table: 'users']
44
pub struct User {
55
mut:
6-
id int @[primary; sql: serial]
7-
username string @[sql_type: 'TEXT'; unique]
8-
password string @[sql_type: 'TEXT']
6+
id int @[primary; sql: serial]
7+
username string @[sql_type: 'TEXT'; unique]
8+
password string @[sql_type: 'TEXT']
99
active bool
1010
products []Product @[fkey: 'user_id']
1111
}

examples/xvweb/todo/main.v

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ struct Todo {
1313
pub mut:
1414
// `id` is the primary field. The attribute `sql: serial` acts like AUTO INCREMENT in sql.
1515
// You can use this attribute if you want a unique id for each row.
16-
id int @[primary; sql: serial]
16+
id int @[primary; sql: serial]
1717
name string
1818
completed bool
1919
created time.Time

tutorials/building_a_simple_web_blog_with_vweb/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ Create a new file `article.v`:
234234
module main
235235
236236
struct Article {
237-
id int @[primary; sql: serial]
237+
id int @[primary; sql: serial]
238238
title string
239239
text string
240240
}

tutorials/building_a_simple_web_blog_with_vweb/code/blog/article.v

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module main
22

33
struct Article {
4-
id int @[primary; sql: serial]
4+
id int @[primary; sql: serial]
55
title string
66
text string
77
}

vlib/builtin/prealloc.c.v

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ struct VMemoryBlock {
2222
mut:
2323
id int
2424
cap isize
25-
start &u8 = 0
25+
start &u8 = 0
2626
previous &VMemoryBlock = 0
2727
remaining isize
2828
current &u8 = 0

vlib/cli/command.v

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ pub mut:
2121
pre_execute FnCommandCallback = unsafe { nil }
2222
execute FnCommandCallback = unsafe { nil }
2323
post_execute FnCommandCallback = unsafe { nil }
24-
disable_help bool @[deprecated: 'use defaults.help instead'; deprecated_after: '2024-06-31']
25-
disable_man bool @[deprecated: 'use defaults.man instead'; deprecated_after: '2024-06-31']
26-
disable_version bool @[deprecated: 'use defaults.version instead'; deprecated_after: '2024-06-31']
24+
disable_help bool @[deprecated: 'use defaults.help instead'; deprecated_after: '2024-06-31']
25+
disable_man bool @[deprecated: 'use defaults.man instead'; deprecated_after: '2024-06-31']
26+
disable_version bool @[deprecated: 'use defaults.version instead'; deprecated_after: '2024-06-31']
2727
disable_flags bool
2828
sort_flags bool
2929
sort_commands bool

0 commit comments

Comments
 (0)