Skip to content

Commit 62c1ea2

Browse files
authored
Zig lint improvements (#7683)
* don't require comments on init+deinit * ignore re-exports * typo * predicate-quantifier does not exist Signed-off-by: Anton-4 <[email protected]>
1 parent f20b9b5 commit 62c1ea2

File tree

13 files changed

+13
-29
lines changed

13 files changed

+13
-29
lines changed

.github/workflows/ci_manager.yml

+2-3
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,18 @@ jobs:
2727
- 'build.zig'
2828
- 'build.zig.zon'
2929
- '.github/workflows/ci_zig.yml'
30-
- 'ci/zig-lints.sh'
30+
- 'ci/zig_lints.sh'
3131
- uses: dorny/paths-filter@v3
3232
id: other_filter
3333
with:
34-
predicate-quantifier: 'every'
3534
filters: |
3635
other_than_zig:
3736
- '**/*'
3837
- '!src/**'
3938
- '!build.zig'
4039
- '!build.zig.zon'
4140
- '!.github/workflows/ci_zig.yml'
42-
- '!ci/zig-lints.sh'
41+
- '!ci/zig_lints.sh'
4342
4443
call-zig-workflow:
4544
needs: check-changes

ci/zig_lints.sh

+6-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,12 @@ while read -r file; do
1212
errors=$(awk '
1313
/^pub / {
1414
if (prev !~ /^\/\/\//) {
15-
print FILENAME ":" FNR ": pub declaration without doc comment `///`"
15+
# Skip doc comment requirements for init, deinit, and @import
16+
if ($0 !~ /pub.*fn init\(/ &&
17+
$0 !~ /pub.*fn deinit/ &&
18+
$0 !~ /pub.*@import/) {
19+
print FILENAME ":" FNR ": pub declaration without doc comment `///`"
20+
}
1621
}
1722
}
1823
{ prev = $0 }

src/base.zig

+1-7
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,14 @@ const std = @import("std");
44
const parse = @import("check/parse.zig");
55
const module_work = @import("base/module_work.zig");
66

7-
/// re-export the S-expression helpers
87
pub const sexpr = @import("base/sexpr.zig");
9-
/// re-export Ident
108
pub const Ident = @import("base/Ident.zig");
11-
/// re-export Region
129
pub const Region = @import("base/Region.zig");
13-
/// re-export Package
1410
pub const Package = @import("base/Package.zig");
15-
/// re-export ModuleEnv
1611
pub const ModuleEnv = @import("base/ModuleEnv.zig");
17-
/// re-export ModuleImport
1812
pub const ModuleImport = @import("base/ModuleImport.zig");
19-
/// re-export StringLiteral
2013
pub const StringLiteral = @import("base/StringLiteral.zig");
14+
2115
/// re-export ModuleWork
2216
pub const ModuleWork = module_work.ModuleWork;
2317
/// re-export ModuleWorkIdx

src/build/lift_functions/IR.zig

-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ typed_patterns: Pattern.Typed.List,
2121
typed_idents: TypedIdent.List,
2222
when_branches: WhenBranch.List,
2323

24-
/// todo
2524
pub fn init(env: *base.ModuleEnv) Self {
2625
return Self{
2726
.env = env,

src/build/lower_statements/IR.zig

-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ stmts: Stmt.List,
1818
idents_with_layouts: IdentWithLayout.List,
1919
list_literal_elems: ListLiteralElem.List,
2020

21-
/// todo
2221
pub fn init(env: *base.ModuleEnv) Self {
2322
return Self{
2423
.env = env,
@@ -32,7 +31,6 @@ pub fn init(env: *base.ModuleEnv) Self {
3231
};
3332
}
3433

35-
/// todo
3634
pub fn deinit(self: *Self) void {
3735
self.procedures.deinit(self.env.gpa);
3836
self.constants.deinit(self.env.gpa);

src/build/reference_count/IR.zig

-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ stmts: Stmt.List,
1818
idents_with_layouts: IdentWithLayout.List,
1919
list_literal_elems: ListLiteralElem.List,
2020

21-
/// todo
2221
pub fn init(env: *base.ModuleEnv) Self {
2322
return Self{
2423
.env = env,
@@ -32,7 +31,6 @@ pub fn init(env: *base.ModuleEnv) Self {
3231
};
3332
}
3433

35-
/// todo
3634
pub fn deinit(self: *Self) void {
3735
self.procedures.deinit(self.env.gpa);
3836
self.constants.deinit(self.env.gpa);

src/build/solve_functions.zig

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@ pub const FunctionSet = struct {
2525
pub const IR = struct {
2626
env: *base.ModuleEnv,
2727
function_sets: FunctionSet.List,
28-
/// todo
28+
2929
pub fn init(env: *base.ModuleEnv) IR {
3030
return IR{
3131
.env = env,
3232
.function_sets = .{},
3333
};
3434
}
35-
/// todo
35+
3636
pub fn deinit(self: *IR) void {
3737
self.function_sets.deinit(self.env.gpa);
3838
}

src/build/specialize_functions/IR.zig

-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ typed_patterns: Pattern.Typed.List,
2121
typed_idents: TypedIdent.List,
2222
when_branches: WhenBranch.List,
2323

24-
/// todo
2524
pub fn init(env: *base.ModuleEnv) Self {
2625
return Self{
2726
.env = env,
@@ -37,7 +36,6 @@ pub fn init(env: *base.ModuleEnv) Self {
3736
};
3837
}
3938

40-
/// todo
4139
pub fn deinit(self: *Self) void {
4240
self.exposed_values.deinit(self.env.gpa);
4341
self.exposed_functions.deinit(self.env.gpa);

src/build/specialize_types/IR.zig

-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ typed_patterns: Pattern.Typed.List,
2121
typed_idents: TypedIdent.List,
2222
when_branches: WhenBranch.List,
2323

24-
/// todo
2524
pub fn init(env: *base.ModuleEnv) Self {
2625
return Self{
2726
.env = env,
@@ -37,7 +36,6 @@ pub fn init(env: *base.ModuleEnv) Self {
3736
};
3837
}
3938

40-
/// todo
4139
pub fn deinit(self: *Self) void {
4240
self.exposed_values.deinit(self.env.gpa);
4341
self.exposed_functions.deinit(self.env.gpa);

src/check/parse/Parser.zig

-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ pub fn init(tokens: TokenizedBuffer) Parser {
3535
};
3636
}
3737

38-
/// deninit the parser memory
3938
pub fn deinit(parser: *Parser) void {
4039
parser.scratch_nodes.deinit(parser.gpa);
4140
parser.diagnostics.deinit(parser.gpa);

src/check/resolve_imports/IR.zig

-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ pub fn init(env: *base.ModuleEnv) Self {
4141
};
4242
}
4343

44-
/// deinitialise the IR's memory
4544
pub fn deinit(self: *Self) void {
4645
self.regions.deinit(self.env.gpa);
4746
self.exprs.deinit(self.env.gpa);

src/collections.zig

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
/// Utilities for managing collections.
22
pub const utils = @import("collections/utils.zig");
33

4-
/// re-export the SafeList
54
pub const SafeList = @import("collections/safe_list.zig").SafeList;
6-
/// re-export the SafeMultiList
5+
76
pub const SafeMultiList = @import("collections/safe_list.zig").SafeMultiList;
8-
/// re-export the SmallStringInterner
7+
98
pub const SmallStringInterner = @import("collections/SmallStringInterner.zig");

src/types.zig

-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
/// re-export the number primitive types
21
pub const num = @import("types/num.zig");
32

4-
/// re-export the Type primitive
53
pub const Type = @import("types/type.zig").Type;
64

75
// todo -- we probably don't need this anymmore.. remove in follow-up PR

0 commit comments

Comments
 (0)