Merge remote-tracking branch 'origin/master' into stage2-whole-file-astgen

Conflicts:
 * lib/std/os/linux.zig
 * lib/std/os/windows/bits.zig
 * src/Module.zig
 * src/Sema.zig
 * test/stage2/test.zig

Mainly I wanted Jakub's new macOS code for respecting stack size, since
we now depend on it for debug builds able to pass one of the test cases
for recursive comptime function calls with `@setEvalBranchQuota`.

The conflicts were all trivial.
This commit is contained in:
Andrew Kelley
2021-05-12 16:41:20 -07:00
72 changed files with 5431 additions and 1398 deletions

View File

@@ -18,11 +18,11 @@ const builtin = std.builtin;
const hash_map = @This();
pub fn AutoArrayHashMap(comptime K: type, comptime V: type) type {
return ArrayHashMap(K, V, getAutoHashFn(K), getAutoEqlFn(K), autoEqlIsCheap(K));
return ArrayHashMap(K, V, getAutoHashFn(K), getAutoEqlFn(K), !autoEqlIsCheap(K));
}
pub fn AutoArrayHashMapUnmanaged(comptime K: type, comptime V: type) type {
return ArrayHashMapUnmanaged(K, V, getAutoHashFn(K), getAutoEqlFn(K), autoEqlIsCheap(K));
return ArrayHashMapUnmanaged(K, V, getAutoHashFn(K), getAutoEqlFn(K), !autoEqlIsCheap(K));
}
/// Builtin hashmap for strings as keys.
@@ -1318,7 +1318,7 @@ test "reIndex" {
try al.append(std.testing.allocator, .{
.key = i,
.value = i * 10,
.hash = hash(i),
.hash = {},
});
}
@@ -1345,7 +1345,7 @@ test "fromOwnedArrayList" {
try al.append(std.testing.allocator, .{
.key = i,
.value = i * 10,
.hash = hash(i),
.hash = {},
});
}
@@ -1362,6 +1362,18 @@ test "fromOwnedArrayList" {
}
}
test "auto store_hash" {
const HasCheapEql = AutoArrayHashMap(i32, i32);
const HasExpensiveEql = AutoArrayHashMap([32]i32, i32);
try testing.expect(meta.fieldInfo(HasCheapEql.Entry, .hash).field_type == void);
try testing.expect(meta.fieldInfo(HasExpensiveEql.Entry, .hash).field_type != void);
const HasCheapEqlUn = AutoArrayHashMapUnmanaged(i32, i32);
const HasExpensiveEqlUn = AutoArrayHashMapUnmanaged([32]i32, i32);
try testing.expect(meta.fieldInfo(HasCheapEqlUn.Entry, .hash).field_type == void);
try testing.expect(meta.fieldInfo(HasExpensiveEqlUn.Entry, .hash).field_type != void);
}
pub fn getHashPtrAddrFn(comptime K: type) (fn (K) u32) {
return struct {
fn hash(key: K) u32 {