relax std.auto_hash requirements regarding vectors

Previously, auto hash tests required vectors of different types to not
hash to the same value. Now, this is allowed.
This commit is contained in:
Andrew Kelley 2019-09-18 16:34:36 -04:00
parent 2038f4d45a
commit ef0f3ba905
No known key found for this signature in database
GPG Key ID: 7C5F548F728501A9

View File

@ -116,7 +116,7 @@ pub fn hash(hasher: var, key: var, comptime strat: HashStrategy) void {
// Otherwise, hash every element.
// TODO remove the copy to an array once field access is done.
const array: [info.len]info.child = key;
comptime var i: u32 = 0;
comptime var i = 0;
inline while (i < info.len) : (i += 1) {
hash(hasher, array[i], strat);
}
@ -357,10 +357,13 @@ test "testHash union" {
test "testHash vector" {
const a: @Vector(4, u32) = [_]u32{ 1, 2, 3, 4 };
const b: @Vector(4, u32) = [_]u32{ 1, 2, 3, 5 };
const c: @Vector(4, u31) = [_]u31{ 1, 2, 3, 4 };
testing.expect(testHash(a) == testHash(a));
testing.expect(testHash(a) != testHash(b));
testing.expect(testHash(a) != testHash(c));
const c: @Vector(4, u31) = [_]u31{ 1, 2, 3, 4 };
const d: @Vector(4, u31) = [_]u31{ 1, 2, 3, 5 };
testing.expect(testHash(c) == testHash(c));
testing.expect(testHash(c) != testHash(d));
}
test "testHash error union" {