Skip to content

Commit 282164c

Browse files
committed
Add a test that was missing when I added code that turned off the borrow to destructure transform for no implicit copy.
1 parent d0164dd commit 282164c

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
// RUN: %target-sil-opt -verify -enable-experimental-move-only -enable-experimental-feature MoveOnlyClasses -enable-sil-verify-all -sil-move-only-borrow-to-destructure %s
2+
3+
sil_stage raw
4+
5+
import Builtin
6+
7+
//////////////////
8+
// Declarations //
9+
//////////////////
10+
11+
class Klass {}
12+
13+
struct AggStruct {
14+
var lhs: Klass
15+
var rhs: Klass
16+
}
17+
18+
sil @classConsume : $@convention(thin) (@owned Klass) -> ()
19+
20+
// We shouldn't emit any errors here since while AggStruct is no implicit copy,
21+
// its fields are not, so we can copy them.
22+
sil [ossa] @aggStructConsumeField : $@convention(thin) (@guaranteed AggStruct) -> () {
23+
bb0(%0 : @guaranteed $AggStruct):
24+
debug_value %0 : $AggStruct, let, name "x", argno 1
25+
%2 = copy_value %0 : $AggStruct
26+
%3 = begin_borrow [lexical] %2 : $AggStruct
27+
%4 = copy_value %3 : $AggStruct
28+
%5 = copyable_to_moveonlywrapper [owned] %4 : $AggStruct
29+
%6 = mark_must_check [no_implicit_copy] %5 : $@moveOnly AggStruct
30+
debug_value %6 : $@moveOnly AggStruct, let, name "x2"
31+
%8 = begin_borrow %6 : $@moveOnly AggStruct
32+
%9 = struct_extract %8 : $@moveOnly AggStruct, #AggStruct.lhs
33+
%10 = copy_value %9 : $@moveOnly Klass
34+
%11 = function_ref @classConsume : $@convention(thin) (@owned Klass) -> ()
35+
%12 = moveonlywrapper_to_copyable [owned] %10 : $@moveOnly Klass
36+
%13 = apply %11(%12) : $@convention(thin) (@owned Klass) -> ()
37+
end_borrow %8 : $@moveOnly AggStruct
38+
br bb1
39+
40+
bb1:
41+
cond_br undef, bb2, bb3
42+
43+
bb2:
44+
%52 = begin_borrow %6 : $@moveOnly AggStruct
45+
%53 = struct_extract %52 : $@moveOnly AggStruct, #AggStruct.lhs
46+
%54 = copy_value %53 : $@moveOnly Klass
47+
%55 = function_ref @classConsume : $@convention(thin) (@owned Klass) -> ()
48+
%56 = moveonlywrapper_to_copyable [owned] %54 : $@moveOnly Klass
49+
%57 = apply %55(%56) : $@convention(thin) (@owned Klass) -> ()
50+
end_borrow %52 : $@moveOnly AggStruct
51+
br bb1
52+
53+
bb3:
54+
destroy_value %6 : $@moveOnly AggStruct
55+
end_borrow %3 : $AggStruct
56+
destroy_value %2 : $AggStruct
57+
%64 = tuple ()
58+
return %64 : $()
59+
}

0 commit comments

Comments
 (0)