master
 1comptime {
 2    const in: []const comptime_int = &.{0};
 3    const out: []const type = @ptrCast(in);
 4    _ = out;
 5}
 6
 7const One = u8;
 8const Two = [2]u8;
 9const Three = [3]u8;
10const Four = [4]u8;
11const Five = [5]u8;
12
13// []One -> []Two (small to big, divides neatly)
14comptime {
15    const in: []const One = &.{ 1, 0, 0 };
16    const out: []const Two = @ptrCast(in);
17    _ = out;
18}
19comptime {
20    const in: *const [3]One = &.{ 1, 0, 0 };
21    const out: []const Two = @ptrCast(in);
22    _ = out;
23}
24
25// []Four -> []Five (small to big, does not divide)
26comptime {
27    const in: []const Four = &.{.{ 0, 0, 0, 0 }};
28    const out: []const Five = @ptrCast(in);
29    _ = out;
30}
31comptime {
32    const in: *const [1]Four = &.{.{ 0, 0, 0, 0 }};
33    const out: []const Five = @ptrCast(in);
34    _ = out;
35}
36
37// []Three -> []Two (big to small, does not divide)
38comptime {
39    const in: []const Three = &.{.{ 0, 0, 0 }};
40    const out: []const Two = @ptrCast(in);
41    _ = out;
42}
43comptime {
44    const in: *const [1]Three = &.{.{ 0, 0, 0 }};
45    const out: []const Two = @ptrCast(in);
46    _ = out;
47}
48
49// error
50//
51// :3:31: error: cannot infer length of comptime-only '[]const type' from incompatible '[]const comptime_int'
52// :16:30: error: slice length '3' does not divide exactly into destination elements
53// :21:30: error: type '[3]u8' does not divide exactly into destination elements
54// :28:31: error: slice length '1' does not divide exactly into destination elements
55// :33:31: error: type '[1][4]u8' does not divide exactly into destination elements
56// :40:30: error: slice length '1' does not divide exactly into destination elements
57// :45:30: error: type '[1][3]u8' does not divide exactly into destination elements