File tree 5 files changed +86
-0
lines changed
chalk-solve/src/clauses/builtin_traits 5 files changed +86
-0
lines changed Original file line number Diff line number Diff line change @@ -36,6 +36,7 @@ Some common examples of auto traits are `Send` and `Sync`.
36
36
| str | 📚 | 📚 | ⚬ | ⚬ | ⚬ | ⚬ | ⚬ | ⚬ | ❌ |
37
37
| never type | 📚 | 📚 | ✅ | ⚬ | ⚬ | ⚬ | ⚬ | ⚬ | ❌ |
38
38
| trait objects | ⚬ | ⚬ | ⚬ | ✅ | ⚬ | ⚬ | ⚬ | ⚬ | ⚬ |
39
+ | functions defs | ✅ | ✅ | ✅ | ⚬ | ⚬ | ❌ | ⚬ | ⚬ | ❌ |
39
40
| functions ptrs | ✅ | ✅ | ✅ | ⚬ | ⚬ | ❌ | ⚬ | ⚬ | ❌ |
40
41
| raw ptrs | 📚 | 📚 | ✅ | ⚬ | ⚬ | ⚬ | ⚬ | ⚬ | ❌ |
41
42
| immutable refs | 📚 | 📚 | ✅ | ⚬ | ⚬ | ⚬ | ⚬ | ⚬ | ❌ |
Original file line number Diff line number Diff line change @@ -51,6 +51,9 @@ pub fn add_copy_program_clauses<I: Interner>(
51
51
iter:: once ( substitution. at ( interner, 0 ) . assert_ty_ref ( interner) . clone ( ) ) ,
52
52
) ;
53
53
}
54
+ TypeName :: FnDef ( _) => {
55
+ builder. push_fact ( trait_ref. clone ( ) ) ;
56
+ }
54
57
_ => return ,
55
58
} ,
56
59
TyData :: Function ( _) => builder. push_fact ( trait_ref. clone ( ) ) ,
Original file line number Diff line number Diff line change @@ -76,6 +76,7 @@ pub fn add_sized_program_clauses<I: Interner>(
76
76
}
77
77
TypeName :: Array
78
78
| TypeName :: Never
79
+ | TypeName :: FnDef ( _)
79
80
| TypeName :: Scalar ( _)
80
81
| TypeName :: Raw ( _)
81
82
| TypeName :: Ref ( _) => builder. push_fact ( trait_ref. clone ( ) ) ,
Original file line number Diff line number Diff line change
1
+ use super :: * ;
2
+
3
+ #[ test]
4
+ fn fn_def_is_well_formed ( ) {
5
+ test ! {
6
+ program {
7
+ fn foo( ) { }
8
+ }
9
+ goal {
10
+ WellFormed ( foo)
11
+ } yields {
12
+ "Unique"
13
+ }
14
+ }
15
+ }
16
+
17
+ #[ test]
18
+ fn fn_def_is_sized ( ) {
19
+ test ! {
20
+ program {
21
+ #[ lang( sized) ]
22
+ trait Sized { }
23
+
24
+ fn foo( ) { }
25
+ }
26
+ goal {
27
+ foo: Sized
28
+ } yields {
29
+ "Unique"
30
+ }
31
+ }
32
+ }
33
+
34
+ #[ test]
35
+ fn fn_def_is_copy ( ) {
36
+ test ! {
37
+ program {
38
+ #[ lang( sized) ]
39
+ trait Copy { }
40
+
41
+ fn foo( ) { }
42
+ }
43
+ goal {
44
+ foo: Copy
45
+ } yields {
46
+ "Unique"
47
+ }
48
+ }
49
+ }
50
+
51
+ #[ test]
52
+ fn fn_def_is_clone ( ) {
53
+ test ! {
54
+ program {
55
+ #[ lang( sized) ]
56
+ trait Clone { }
57
+
58
+ fn foo( ) { }
59
+ }
60
+ goal {
61
+ foo: Clone
62
+ } yields {
63
+ "Unique"
64
+ }
65
+ }
66
+ }
Original file line number Diff line number Diff line change @@ -11,3 +11,18 @@ fn never_is_well_formed() {
11
11
}
12
12
}
13
13
}
14
+
15
+ #[ test]
16
+ fn never_is_sized ( ) {
17
+ test ! {
18
+ program {
19
+ #[ lang( sized) ]
20
+ trait Sized { }
21
+ }
22
+ goal {
23
+ !: Sized
24
+ } yields {
25
+ "Unique"
26
+ }
27
+ }
28
+ }
You can’t perform that action at this time.
0 commit comments