use * for pointer type instead of &

See #770

To help automatically translate code, see the
zig-fmt-pointer-reform-2 branch.

This will convert all & into *. Due to the syntax
ambiguity (which is why we are making this change),
even address-of & will turn into *, so you'll have
to manually fix thes instances. You will be guaranteed
to get compile errors for them - expected 'type', found 'foo'
This commit is contained in:
Andrew Kelley
2018-05-31 10:56:59 -04:00
parent 717ac85a5a
commit fcbb7426fa
150 changed files with 2160 additions and 2141 deletions

View File

@@ -43,7 +43,7 @@ const VoidStructFieldsFoo = struct {
test "structs" {
var foo: StructFoo = undefined;
@memset(@ptrCast(&u8, &foo), 0, @sizeOf(StructFoo));
@memset(@ptrCast(*u8, &foo), 0, @sizeOf(StructFoo));
foo.a += 1;
foo.b = foo.a == 1;
testFoo(foo);
@@ -55,16 +55,16 @@ const StructFoo = struct {
b: bool,
c: f32,
};
fn testFoo(foo: &const StructFoo) void {
fn testFoo(foo: *const StructFoo) void {
assert(foo.b);
}
fn testMutation(foo: &StructFoo) void {
fn testMutation(foo: *StructFoo) void {
foo.c = 100;
}
const Node = struct {
val: Val,
next: &Node,
next: *Node,
};
const Val = struct {
@@ -112,7 +112,7 @@ fn aFunc() i32 {
return 13;
}
fn callStructField(foo: &const Foo) i32 {
fn callStructField(foo: *const Foo) i32 {
return foo.ptr();
}
@@ -124,7 +124,7 @@ test "store member function in variable" {
}
const MemberFnTestFoo = struct {
x: i32,
fn member(foo: &const MemberFnTestFoo) i32 {
fn member(foo: *const MemberFnTestFoo) i32 {
return foo.x;
}
};
@@ -141,7 +141,7 @@ test "member functions" {
}
const MemberFnRand = struct {
seed: u32,
pub fn getSeed(r: &const MemberFnRand) u32 {
pub fn getSeed(r: *const MemberFnRand) u32 {
return r.seed;
}
};
@@ -166,7 +166,7 @@ test "empty struct method call" {
assert(es.method() == 1234);
}
const EmptyStruct = struct {
fn method(es: &const EmptyStruct) i32 {
fn method(es: *const EmptyStruct) i32 {
return 1234;
}
};
@@ -228,15 +228,15 @@ test "bit field access" {
assert(data.b == 3);
}
fn getA(data: &const BitField1) u3 {
fn getA(data: *const BitField1) u3 {
return data.a;
}
fn getB(data: &const BitField1) u3 {
fn getB(data: *const BitField1) u3 {
return data.b;
}
fn getC(data: &const BitField1) u2 {
fn getC(data: *const BitField1) u2 {
return data.c;
}
@@ -396,8 +396,8 @@ const Bitfields = packed struct {
test "native bit field understands endianness" {
var all: u64 = 0x7765443322221111;
var bytes: [8]u8 = undefined;
@memcpy(&bytes[0], @ptrCast(&u8, &all), 8);
var bitfields = @ptrCast(&Bitfields, &bytes[0]).*;
@memcpy(&bytes[0], @ptrCast(*u8, &all), 8);
var bitfields = @ptrCast(*Bitfields, &bytes[0]).*;
assert(bitfields.f1 == 0x1111);
assert(bitfields.f2 == 0x2222);
@@ -415,7 +415,7 @@ test "align 1 field before self referential align 8 field as slice return type"
const Expr = union(enum) {
Literal: u8,
Question: &Expr,
Question: *Expr,
};
fn alloc(comptime T: type) []T {