File tree Expand file tree Collapse file tree 5 files changed +86
-0
lines changed
chalk-solve/src/clauses/builtin_traits Expand file tree Collapse file tree 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`.
3636| str | 📚 | 📚 | ⚬ | ⚬ | ⚬ | ⚬ | ⚬ | ⚬ | ❌ |
3737| never type | 📚 | 📚 | ✅ | ⚬ | ⚬ | ⚬ | ⚬ | ⚬ | ❌ |
3838| trait objects | ⚬ | ⚬ | ⚬ | ✅ | ⚬ | ⚬ | ⚬ | ⚬ | ⚬ |
39+ | functions defs | ✅ | ✅ | ✅ | ⚬ | ⚬ | ❌ | ⚬ | ⚬ | ❌ |
3940| functions ptrs | ✅ | ✅ | ✅ | ⚬ | ⚬ | ❌ | ⚬ | ⚬ | ❌ |
4041| raw ptrs | 📚 | 📚 | ✅ | ⚬ | ⚬ | ⚬ | ⚬ | ⚬ | ❌ |
4142| immutable refs | 📚 | 📚 | ✅ | ⚬ | ⚬ | ⚬ | ⚬ | ⚬ | ❌ |
Original file line number Diff line number Diff line change @@ -51,6 +51,9 @@ pub fn add_copy_program_clauses<I: Interner>(
5151 iter:: once ( substitution. at ( interner, 0 ) . assert_ty_ref ( interner) . clone ( ) ) ,
5252 ) ;
5353 }
54+ TypeName :: FnDef ( _) => {
55+ builder. push_fact ( trait_ref. clone ( ) ) ;
56+ }
5457 _ => return ,
5558 } ,
5659 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>(
7676 }
7777 TypeName :: Array
7878 | TypeName :: Never
79+ | TypeName :: FnDef ( _)
7980 | TypeName :: Scalar ( _)
8081 | TypeName :: Raw ( _)
8182 | 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() {
1111 }
1212 }
1313}
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