File tree 2 files changed +56
-0
lines changed
tests/codegen/ergonomic-clones
2 files changed +56
-0
lines changed Original file line number Diff line number Diff line change @@ -57,4 +57,5 @@ ignore = [
57
57
58
58
# Rustfmt doesn't support use closures yet
59
59
" tests/mir-opt/ergonomic-clones/closure.rs" ,
60
+ " tests/codegen/ergonomic-clones/closure.rs" ,
60
61
]
Original file line number Diff line number Diff line change
1
+ //@ compile-flags: -C no-prepopulate-passes -Copt-level=0 -Zmir-opt-level=0
2
+
3
+ #![ crate_type = "lib" ]
4
+
5
+ #![ feature( ergonomic_clones) ]
6
+ #![ allow( incomplete_features) ]
7
+
8
+ use std:: clone:: UseCloned ;
9
+
10
+ pub fn ergonomic_clone_closure_move ( ) -> String {
11
+ let s = String :: from ( "hi" ) ;
12
+
13
+ // CHECK-NOT: ; call core::clone::impls::<impl core::clone::Clone for String>::clone
14
+ let cl = use || s;
15
+ cl ( )
16
+ }
17
+
18
+ #[ derive( Clone ) ]
19
+ struct Foo ;
20
+
21
+ impl UseCloned for Foo { }
22
+
23
+ pub fn ergonomic_clone_closure_use_cloned ( ) -> Foo {
24
+ let f = Foo ;
25
+
26
+ // CHECK: ; call <closure::Foo as core::clone::Clone>::clone
27
+ let f1 = use || f;
28
+
29
+ // CHECK: ; call <closure::Foo as core::clone::Clone>::clone
30
+ let f2 = use || f;
31
+
32
+ f
33
+ }
34
+
35
+ pub fn ergonomic_clone_closure_copy ( ) -> i32 {
36
+ let i = 1 ;
37
+
38
+ // CHECK-NOT: ; call core::clone::impls::<impl core::clone::Clone for i32>::clone
39
+ let i1 = use || i;
40
+
41
+ // CHECK-NOT: ; call core::clone::impls::<impl core::clone::Clone for i32>::clone
42
+ let i2 = use || i;
43
+
44
+ i
45
+ }
46
+
47
+ pub fn ergonomic_clone_closure_use_cloned_generics < T : UseCloned > ( f : T ) -> T {
48
+ // CHECK-NOT: ; call core::clone::impls::<impl core::clone::Clone for i32>::clone
49
+ let f1 = use || f;
50
+
51
+ // CHECK-NOT: ; call core::clone::impls::<impl core::clone::Clone for i32>::clone
52
+ let f2 = use || f;
53
+
54
+ f
55
+ }
You can’t perform that action at this time.
0 commit comments