allow passing by non-copying value

closes #733
This commit is contained in:
Andrew Kelley
2018-06-13 22:40:38 -04:00
parent a7d59086b4
commit 59b3dc8907
4 changed files with 32 additions and 54 deletions

View File

@@ -2573,15 +2573,6 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
break :x tc;
});
cases.add(
"pass non-copyable type by value to function",
\\const Point = struct { x: i32, y: i32, };
\\fn foo(p: Point) void { }
\\export fn entry() usize { return @sizeOf(@typeOf(foo)); }
,
".tmp_source.zig:2:11: error: type 'Point' is not copyable; cannot pass by value",
);
cases.add(
"implicit cast from array to mutable slice",
\\var global_array: [10]i32 = undefined;
@@ -4066,20 +4057,6 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
".tmp_source.zig:3:5: note: field 'A' has type 'i32'",
);
cases.add(
"self-referencing function pointer field",
\\const S = struct {
\\ f: fn(_: S) void,
\\};
\\fn f(_: S) void {
\\}
\\export fn entry() void {
\\ var _ = S { .f = f };
\\}
,
".tmp_source.zig:4:9: error: type 'S' is not copyable; cannot pass by value",
);
cases.add(
"taking offset of void field in struct",
\\const Empty = struct {