diff options
| author | Matthew Lugg <mlugg@mlugg.co.uk> | 2023-11-19 16:19:06 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-11-19 16:19:06 +0000 |
| commit | 6b1a823b2b30d9318c9877dbdbd3d02fa939fba0 (patch) | |
| tree | 6e5afdad2397ac7224119811583d19107b6e517a /src/resinator/comments.zig | |
| parent | 325e0f5f0e8a9ce2540ec3ec5b7cbbecac15257a (diff) | |
| parent | 9cf6c1ad11bb5f0247ff3458cba5f3bd156d1fb9 (diff) | |
| download | zig-6b1a823b2b30d9318c9877dbdbd3d02fa939fba0.tar.gz zig-6b1a823b2b30d9318c9877dbdbd3d02fa939fba0.zip | |
Merge pull request #18017 from mlugg/var-never-mutated
compiler: add error for unnecessary use of 'var'
Diffstat (limited to 'src/resinator/comments.zig')
| -rw-r--r-- | src/resinator/comments.zig | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/resinator/comments.zig b/src/resinator/comments.zig index cfb27ae341..a631b8bb93 100644 --- a/src/resinator/comments.zig +++ b/src/resinator/comments.zig @@ -206,9 +206,9 @@ inline fn handleMultilineCarriageReturn( } pub fn removeCommentsAlloc(allocator: Allocator, source: []const u8, source_mappings: ?*SourceMappings) ![]u8 { - var buf = try allocator.alloc(u8, source.len); + const buf = try allocator.alloc(u8, source.len); errdefer allocator.free(buf); - var result = removeComments(source, buf, source_mappings); + const result = removeComments(source, buf, source_mappings); return allocator.realloc(buf, result.len); } @@ -326,7 +326,7 @@ test "remove comments with mappings" { try mappings.set(allocator, 3, .{ .start_line = 3, .end_line = 3, .filename_offset = 0 }); defer mappings.deinit(allocator); - var result = removeComments(&mut_source, &mut_source, &mappings); + const result = removeComments(&mut_source, &mut_source, &mappings); try std.testing.expectEqualStrings("blahblah", result); try std.testing.expectEqual(@as(usize, 1), mappings.mapping.items.len); @@ -335,6 +335,6 @@ test "remove comments with mappings" { test "in place" { var mut_source = "blah /* comment */ blah".*; - var result = removeComments(&mut_source, &mut_source, null); + const result = removeComments(&mut_source, &mut_source, null); try std.testing.expectEqualStrings("blah blah", result); } |
