From d0275a95e931567e6428af06fe5630859a4ab47f Mon Sep 17 00:00:00 2001 From: Jacob Young Date: Tue, 19 Mar 2024 12:46:38 +0100 Subject: [PATCH] Update uses of `@fieldParentPtr` to use RLS --- compile_errors/fieldParentPtr-bad_field_name.zig | 4 ++-- ...ieldParentPtr-comptime_field_ptr_not_based_on_struct.zig | 2 +- .../fieldParentPtr-comptime_wrong_field_index.zig | 4 ++-- .../fieldParentPtr-field_pointer_is_not_pointer.zig | 6 +++--- compile_errors/fieldParentPtr-non_pointer.zig | 6 +++--- compile_errors/fieldParentPtr_on_comptime_field.zig | 4 ++-- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/compile_errors/fieldParentPtr-bad_field_name.zig b/compile_errors/fieldParentPtr-bad_field_name.zig index 10a2bf384d56..c897db4abb9e 100644 --- a/compile_errors/fieldParentPtr-bad_field_name.zig +++ b/compile_errors/fieldParentPtr-bad_field_name.zig @@ -2,12 +2,12 @@ const Foo = extern struct { derp: i32, }; export fn foo(a: *i32) *Foo { - return @fieldParentPtr(*Foo, "a", a); + return @fieldParentPtr("a", a); } // error // backend=stage2 // target=native // -// :5:34: error: no field named 'a' in struct 'tmp.Foo' +// :5:28: error: no field named 'a' in struct 'tmp.Foo' // :1:20: note: struct declared here diff --git a/compile_errors/fieldParentPtr-comptime_field_ptr_not_based_on_struct.zig b/compile_errors/fieldParentPtr-comptime_field_ptr_not_based_on_struct.zig index 751dc6681ecc..7eeb62b14631 100644 --- a/compile_errors/fieldParentPtr-comptime_field_ptr_not_based_on_struct.zig +++ b/compile_errors/fieldParentPtr-comptime_field_ptr_not_based_on_struct.zig @@ -9,7 +9,7 @@ const foo = Foo{ comptime { const field_ptr: *i32 = @ptrFromInt(0x1234); - const another_foo_ptr = @fieldParentPtr(*const Foo, "b", field_ptr); + const another_foo_ptr: *const Foo = @fieldParentPtr("b", field_ptr); _ = another_foo_ptr; } diff --git a/compile_errors/fieldParentPtr-comptime_wrong_field_index.zig b/compile_errors/fieldParentPtr-comptime_wrong_field_index.zig index 3f459c66eeea..4ee347494100 100644 --- a/compile_errors/fieldParentPtr-comptime_wrong_field_index.zig +++ b/compile_errors/fieldParentPtr-comptime_wrong_field_index.zig @@ -8,7 +8,7 @@ const foo = Foo{ }; comptime { - const another_foo_ptr = @fieldParentPtr(*const Foo, "b", &foo.a); + const another_foo_ptr: *const Foo = @fieldParentPtr("b", &foo.a); _ = another_foo_ptr; } @@ -16,5 +16,5 @@ comptime { // backend=stage2 // target=native // -// :11:29: error: field 'b' has index '1' but pointer value is index '0' of struct 'tmp.Foo' +// :11:41: error: field 'b' has index '1' but pointer value is index '0' of struct 'tmp.Foo' // :1:13: note: struct declared here diff --git a/compile_errors/fieldParentPtr-field_pointer_is_not_pointer.zig b/compile_errors/fieldParentPtr-field_pointer_is_not_pointer.zig index b2a7768611a3..832269268a51 100644 --- a/compile_errors/fieldParentPtr-field_pointer_is_not_pointer.zig +++ b/compile_errors/fieldParentPtr-field_pointer_is_not_pointer.zig @@ -1,12 +1,12 @@ const Foo = extern struct { a: i32, }; -export fn foo(a: i32) *Foo { - return @fieldParentPtr(*const Foo, "a", a); +export fn foo(a: i32) *const Foo { + return @fieldParentPtr("a", a); } // error // backend=stage2 // target=native // -// :5:45: error: expected pointer type, found 'i32' +// :5:33: error: expected pointer type, found 'i32' diff --git a/compile_errors/fieldParentPtr-non_pointer.zig b/compile_errors/fieldParentPtr-non_pointer.zig index 27d8ad9c2040..31f15783d8ea 100644 --- a/compile_errors/fieldParentPtr-non_pointer.zig +++ b/compile_errors/fieldParentPtr-non_pointer.zig @@ -1,10 +1,10 @@ const Foo = i32; -export fn foo(a: *i32) *Foo { - return @fieldParentPtr(Foo, "a", a); +export fn foo(a: *i32) Foo { + return @fieldParentPtr("a", a); } // error // backend=llvm // target=native // -// :3:28: error: expected pointer type, found 'i32' +// :3:12: error: expected pointer type, found 'i32' diff --git a/compile_errors/fieldParentPtr_on_comptime_field.zig b/compile_errors/fieldParentPtr_on_comptime_field.zig index 1b26bfcff9d8..ff18791c4972 100644 --- a/compile_errors/fieldParentPtr_on_comptime_field.zig +++ b/compile_errors/fieldParentPtr_on_comptime_field.zig @@ -5,7 +5,7 @@ pub export fn entry1() void { @offsetOf(T, "a"); } pub export fn entry2() void { - @fieldParentPtr(*T, "a", undefined); + @as(*T, @fieldParentPtr("a", undefined)); } // error @@ -13,4 +13,4 @@ pub export fn entry2() void { // target=native // // :5:5: error: no offset available for comptime field -// :8:25: error: cannot get @fieldParentPtr of a comptime field +// :8:29: error: cannot get @fieldParentPtr of a comptime field