Skip to content

Commit

Permalink
fix code broken from previous commit
Browse files Browse the repository at this point in the history
  • Loading branch information
g-w1 committed Jun 21, 2021
1 parent 69510f7 commit a30b3e2
Show file tree
Hide file tree
Showing 162 changed files with 720 additions and 148 deletions.
2 changes: 1 addition & 1 deletion lib/std/Progress.zig
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ fn refreshWithHeldLock(self: *Progress) void {
end += 1;
}

_ = file.write(self.output_buffer[0..end]) catch |e| {
_ = file.write(self.output_buffer[0..end]) catch {
// Stop trying to write to this file once it errors.
self.terminal = null;
};
Expand Down
3 changes: 2 additions & 1 deletion lib/std/SemanticVersion.zig
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ pub fn format(
options: std.fmt.FormatOptions,
out_stream: anytype,
) !void {
_ = options;
if (fmt.len != 0) @compileError("Unknown format string: '" ++ fmt ++ "'");
try std.fmt.format(out_stream, "{d}.{d}.{d}", .{ self.major, self.minor, self.patch });
if (self.pre) |pre| try std.fmt.format(out_stream, "-{s}", .{pre});
Expand Down Expand Up @@ -259,7 +260,7 @@ test "SemanticVersion format" {

// Invalid version string that may overflow.
const big_invalid = "99999999999999999999999.999999999999999999.99999999999999999----RC-SNAPSHOT.12.09.1--------------------------------..12";
if (parse(big_invalid)) |ver| std.debug.panic("expected error, found {}", .{ver}) else |err| {}
if (parse(big_invalid)) |ver| std.debug.panic("expected error, found {}", .{ver}) else |_| {}
}

test "SemanticVersion precedence" {
Expand Down
10 changes: 8 additions & 2 deletions lib/std/Thread/Condition.zig
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,18 @@ else

pub const SingleThreadedCondition = struct {
pub fn wait(cond: *SingleThreadedCondition, mutex: *Mutex) void {
_ = cond;
_ = mutex;
unreachable; // deadlock detected
}

pub fn signal(cond: *SingleThreadedCondition) void {}
pub fn signal(cond: *SingleThreadedCondition) void {
_ = cond;
}

pub fn broadcast(cond: *SingleThreadedCondition) void {}
pub fn broadcast(cond: *SingleThreadedCondition) void {
_ = cond;
}
};

pub const WindowsCondition = struct {
Expand Down
7 changes: 6 additions & 1 deletion lib/std/Thread/StaticResetEvent.zig
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ pub const DebugEvent = struct {
}

pub fn timedWait(ev: *DebugEvent, timeout: u64) TimedWaitResult {
_ = timeout;
switch (ev.state) {
.unset => return .timed_out,
.set => return .event_set,
Expand Down Expand Up @@ -174,7 +175,10 @@ pub const AtomicEvent = struct {
};

pub const SpinFutex = struct {
fn wake(waiters: *u32, wake_count: u32) void {}
fn wake(waiters: *u32, wake_count: u32) void {
_ = waiters;
_ = wake_count;
}

fn wait(waiters: *u32, timeout: ?u64) !void {
var timer: time.Timer = undefined;
Expand All @@ -193,6 +197,7 @@ pub const AtomicEvent = struct {

pub const LinuxFutex = struct {
fn wake(waiters: *u32, wake_count: u32) void {
_ = wake_count;
const waiting = std.math.maxInt(i32); // wake_count
const ptr = @ptrCast(*const i32, waiters);
const rc = linux.futex_wake(ptr, linux.FUTEX_WAKE | linux.FUTEX_PRIVATE_FLAG, waiting);
Expand Down
13 changes: 11 additions & 2 deletions lib/std/array_hash_map.zig
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,11 @@ pub fn StringArrayHashMapUnmanaged(comptime V: type) type {

pub const StringContext = struct {
pub fn hash(self: @This(), s: []const u8) u32 {
_ = self;
return hashString(s);
}
pub fn eql(self: @This(), a: []const u8, b: []const u8) bool {
_ = self;
return eqlString(a, b);
}
};
Expand Down Expand Up @@ -1335,6 +1337,7 @@ pub fn ArrayHashMapUnmanaged(
}

fn removeSlot(self: *Self, removed_slot: usize, header: *IndexHeader, comptime I: type, indexes: []Index(I)) void {
_ = self;
const start_index = removed_slot +% 1;
const end_index = start_index +% indexes.len;

Expand Down Expand Up @@ -1626,6 +1629,7 @@ pub fn ArrayHashMapUnmanaged(
}
}
fn dumpIndex(self: Self, header: *IndexHeader, comptime I: type) void {
_ = self;
const p = std.debug.print;
p(" index len=0x{x} type={}\n", .{ header.length(), header.capacityIndexType() });
const indexes = header.indexes(I);
Expand Down Expand Up @@ -1918,7 +1922,7 @@ test "iterator hash map" {
try testing.expect(count == 3);
try testing.expect(it.next() == null);

for (buffer) |v, i| {
for (buffer) |_, i| {
try testing.expect(buffer[@intCast(usize, keys[i])] == values[i]);
}

Expand All @@ -1930,7 +1934,7 @@ test "iterator hash map" {
if (count >= 2) break;
}

for (buffer[0..2]) |v, i| {
for (buffer[0..2]) |_, i| {
try testing.expect(buffer[@intCast(usize, keys[i])] == values[i]);
}

Expand Down Expand Up @@ -2154,6 +2158,7 @@ test "compile everything" {
pub fn getHashPtrAddrFn(comptime K: type, comptime Context: type) (fn (Context, K) u32) {
return struct {
fn hash(ctx: Context, key: K) u32 {
_ = ctx;
return getAutoHashFn(usize, void)({}, @ptrToInt(key));
}
}.hash;
Expand All @@ -2162,6 +2167,7 @@ pub fn getHashPtrAddrFn(comptime K: type, comptime Context: type) (fn (Context,
pub fn getTrivialEqlFn(comptime K: type, comptime Context: type) (fn (Context, K, K) bool) {
return struct {
fn eql(ctx: Context, a: K, b: K) bool {
_ = ctx;
return a == b;
}
}.eql;
Expand All @@ -2177,6 +2183,7 @@ pub fn AutoContext(comptime K: type) type {
pub fn getAutoHashFn(comptime K: type, comptime Context: type) (fn (Context, K) u32) {
return struct {
fn hash(ctx: Context, key: K) u32 {
_ = ctx;
if (comptime trait.hasUniqueRepresentation(K)) {
return @truncate(u32, Wyhash.hash(0, std.mem.asBytes(&key)));
} else {
Expand All @@ -2191,6 +2198,7 @@ pub fn getAutoHashFn(comptime K: type, comptime Context: type) (fn (Context, K)
pub fn getAutoEqlFn(comptime K: type, comptime Context: type) (fn (Context, K, K) bool) {
return struct {
fn eql(ctx: Context, a: K, b: K) bool {
_ = ctx;
return meta.eql(a, b);
}
}.eql;
Expand All @@ -2217,6 +2225,7 @@ pub fn autoEqlIsCheap(comptime K: type) bool {
pub fn getAutoHashStratFn(comptime K: type, comptime Context: type, comptime strategy: std.hash.Strategy) (fn (Context, K) u32) {
return struct {
fn hash(ctx: Context, key: K) u32 {
_ = ctx;
var hasher = Wyhash.init(0);
std.hash.autoHashStrat(&hasher, key, strategy);
return @truncate(u32, hasher.final());
Expand Down
2 changes: 2 additions & 0 deletions lib/std/atomic/Atomic.zig
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ test "Atomic.loadUnchecked" {

test "Atomic.storeUnchecked" {
inline for (atomicIntTypes()) |Int| {
_ = Int;
var x = Atomic(usize).init(5);
x.storeUnchecked(10);
try testing.expectEqual(x.loadUnchecked(), 10);
Expand All @@ -250,6 +251,7 @@ test "Atomic.load" {
test "Atomic.store" {
inline for (atomicIntTypes()) |Int| {
inline for (.{ .Unordered, .Monotonic, .Release, .SeqCst }) |ordering| {
_ = Int;
var x = Atomic(usize).init(5);
x.store(10, ordering);
try testing.expectEqual(x.load(.SeqCst), 10);
Expand Down
6 changes: 4 additions & 2 deletions lib/std/bit_set.zig
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ pub fn IntegerBitSet(comptime size: u16) type {

/// Returns the number of bits in this bit set
pub inline fn capacity(self: Self) usize {
_ = self;
return bit_length;
}

Expand Down Expand Up @@ -311,6 +312,7 @@ pub fn ArrayBitSet(comptime MaskIntType: type, comptime size: usize) type {

/// Returns the number of bits in this bit set
pub inline fn capacity(self: Self) usize {
_ = self;
return bit_length;
}

Expand Down Expand Up @@ -373,7 +375,7 @@ pub fn ArrayBitSet(comptime MaskIntType: type, comptime size: usize) type {

/// Flips every bit in the bit set.
pub fn toggleAll(self: *Self) void {
for (self.masks) |*mask, i| {
for (self.masks) |*mask| {
mask.* = ~mask.*;
}

Expand Down Expand Up @@ -642,7 +644,7 @@ pub const DynamicBitSetUnmanaged = struct {
if (bit_length == 0) return;

const num_masks = numMasks(self.bit_length);
for (self.masks[0..num_masks]) |*mask, i| {
for (self.masks[0..num_masks]) |*mask| {
mask.* = ~mask.*;
}

Expand Down
7 changes: 5 additions & 2 deletions lib/std/build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,7 @@ pub const Builder = struct {
}

pub fn version(self: *const Builder, major: u32, minor: u32, patch: u32) LibExeObjStep.SharedLibKind {
_ = self;
return .{
.versioned = .{
.major = major,
Expand Down Expand Up @@ -543,7 +544,7 @@ pub const Builder = struct {
return null;
},
.scalar => |s| {
const n = std.fmt.parseFloat(T, s) catch |err| {
const n = std.fmt.parseFloat(T, s) catch {
warn("Expected -D{s} to be a float of type {s}.\n\n", .{ name, @typeName(T) });
self.markInvalidUserInput();
return null;
Expand Down Expand Up @@ -3129,7 +3130,9 @@ pub const Step = struct {
self.dependencies.append(other) catch unreachable;
}

fn makeNoOp(self: *Step) anyerror!void {}
fn makeNoOp(self: *Step) anyerror!void {
_ = self;
}

pub fn cast(step: *Step, comptime T: type) ?*T {
if (step.id == T.base_id) {
Expand Down
2 changes: 2 additions & 0 deletions lib/std/build/InstallRawStep.zig
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ const BinaryElfOutput = struct {
}

fn segmentSortCompare(context: void, left: *BinaryElfSegment, right: *BinaryElfSegment) bool {
_ = context;
if (left.physicalAddress < right.physicalAddress) {
return true;
}
Expand All @@ -149,6 +150,7 @@ const BinaryElfOutput = struct {
}

fn sectionSortCompare(context: void, left: *BinaryElfSection, right: *BinaryElfSection) bool {
_ = context;
return left.binaryOffset < right.binaryOffset;
}
};
Expand Down
3 changes: 3 additions & 0 deletions lib/std/builtin.zig
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ pub const StackTrace = struct {
options: std.fmt.FormatOptions,
writer: anytype,
) !void {
_ = fmt;
_ = options;
var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator);
defer arena.deinit();
const debug_info = std.debug.getSelfDebugInfo() catch |err| {
Expand Down Expand Up @@ -521,6 +523,7 @@ pub const Version = struct {
options: std.fmt.FormatOptions,
out_stream: anytype,
) !void {
_ = options;
if (fmt.len == 0) {
if (self.patch == 0) {
if (self.minor == 0) {
Expand Down
1 change: 1 addition & 0 deletions lib/std/comptime_string_map.zig
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ pub fn ComptimeStringMap(comptime V: type, comptime kvs: anytype) type {
var sorted_kvs: [kvs.len]KV = undefined;
const lenAsc = (struct {
fn lenAsc(context: void, a: KV, b: KV) bool {
_ = context;
return a.key.len < b.key.len;
}
}).lenAsc;
Expand Down
2 changes: 1 addition & 1 deletion lib/std/crypto/25519/ed25519.zig
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ test "ed25519 test vectors" {
.expected = error.IdentityElement, // 11 - small-order A
},
};
for (entries) |entry, i| {
for (entries) |entry| {
var msg: [entry.msg_hex.len / 2]u8 = undefined;
_ = try fmt.hexToBytes(&msg, entry.msg_hex);
var public_key: [32]u8 = undefined;
Expand Down
1 change: 1 addition & 0 deletions lib/std/crypto/blake3.zig
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,7 @@ pub const Blake3 = struct {
/// Construct a new `Blake3` for the key derivation function. The context
/// string should be hardcoded, globally unique, and application-specific.
pub fn initKdf(context: []const u8, options: KdfOptions) Blake3 {
_ = options;
var context_hasher = Blake3.init_internal(IV, DERIVE_KEY_CONTEXT);
context_hasher.update(context);
var context_key: [KEY_LEN]u8 = undefined;
Expand Down
1 change: 1 addition & 0 deletions lib/std/crypto/gimli.zig
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ pub const Hash = struct {
const Self = @This();

pub fn init(options: Options) Self {
_ = options;
return Self{
.state = State{ .data = [_]u32{0} ** (State.BLOCKBYTES / 4) },
.buf_off = 0,
Expand Down
1 change: 1 addition & 0 deletions lib/std/crypto/md5.zig
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ pub const Md5 = struct {
total_len: u64,

pub fn init(options: Options) Self {
_ = options;
return Self{
.s = [_]u32{
0x67452301,
Expand Down
1 change: 1 addition & 0 deletions lib/std/crypto/pcurves/p256/scalar.zig
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ pub fn add(a: CompressedScalar, b: CompressedScalar, endian: builtin.Endian) Non

/// Return -s (mod L)
pub fn neg(s: CompressedScalar, endian: builtin.Endian) NonCanonicalError!CompressedScalar {
_ = s;
return (try Scalar.fromBytes(a, endian)).neg().toBytes(endian);
}

Expand Down
1 change: 1 addition & 0 deletions lib/std/crypto/sha1.zig
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ pub const Sha1 = struct {
total_len: u64 = 0,

pub fn init(options: Options) Self {
_ = options;
return Self{
.s = [_]u32{
0x67452301,
Expand Down
2 changes: 2 additions & 0 deletions lib/std/crypto/sha2.zig
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ fn Sha2x32(comptime params: Sha2Params32) type {
total_len: u64 = 0,

pub fn init(options: Options) Self {
_ = options;
return Self{
.s = [_]u32{
params.iv0,
Expand Down Expand Up @@ -462,6 +463,7 @@ fn Sha2x64(comptime params: Sha2Params64) type {
total_len: u128 = 0,

pub fn init(options: Options) Self {
_ = options;
return Self{
.s = [_]u64{
params.iv0,
Expand Down
1 change: 1 addition & 0 deletions lib/std/crypto/sha3.zig
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ fn Keccak(comptime bits: usize, comptime delim: u8) type {
rate: usize,

pub fn init(options: Options) Self {
_ = options;
return Self{ .s = [_]u8{0} ** 200, .offset = 0, .rate = 200 - (bits / 4) };
}

Expand Down
2 changes: 1 addition & 1 deletion lib/std/crypto/tlcsprng.zig
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ fn tlsCsprngFill(_: *const std.rand.Random, buffer: []u8) void {
os.MAP_PRIVATE | os.MAP_ANONYMOUS,
-1,
0,
) catch |err| {
) catch {
// Could not allocate memory for the local state, fall back to
// the OS syscall.
return fillWithOsEntropy(buffer);
Expand Down
5 changes: 5 additions & 0 deletions lib/std/debug.zig
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ pub fn writeStackTrace(
debug_info: *DebugInfo,
tty_config: TTY.Config,
) !void {
_ = allocator;
if (builtin.strip_debug_info) return error.MissingDebugInfo;
var frame_index: usize = 0;
var frames_left: usize = std.math.min(stack_trace.index, stack_trace.instruction_addresses.len);
Expand Down Expand Up @@ -903,6 +904,7 @@ const MachoSymbol = struct {
}

fn addressLessThan(context: void, lhs: MachoSymbol, rhs: MachoSymbol) bool {
_ = context;
return lhs.address() < rhs.address();
}
};
Expand Down Expand Up @@ -1107,6 +1109,7 @@ pub const DebugInfo = struct {

if (os.dl_iterate_phdr(&ctx, anyerror, struct {
fn callback(info: *os.dl_phdr_info, size: usize, context: *CtxTy) !void {
_ = size;
// The base address is too high
if (context.address < info.dlpi_addr)
return;
Expand Down Expand Up @@ -1162,6 +1165,8 @@ pub const DebugInfo = struct {
}

fn lookupModuleHaiku(self: *DebugInfo, address: usize) !*ModuleDebugInfo {
_ = self;
_ = address;
@panic("TODO implement lookup module for Haiku");
}
};
Expand Down
Loading

0 comments on commit a30b3e2

Please sign in to comment.