Skip to content

Commit 4d8b6df

Browse files
committed
Handle functions for the builtin Sized trait
1 parent 5c890e7 commit 4d8b6df

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

chalk-solve/src/clauses/builtin_traits/sized.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ pub fn add_sized_program_clauses<I: Interner>(
7777
}
7878
_ => return,
7979
},
80+
TyData::Function(_) => builder.push_fact(trait_ref.clone()),
8081
// TODO(areredify)
8182
// when #368 lands, extend this to handle everything accordingly
8283
_ => return,

tests/test/functions.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
use super::*;
2+
3+
#[test]
4+
fn functions_are_sized() {
5+
test! {
6+
program {
7+
#[lang(sized)]
8+
trait Sized { }
9+
10+
trait Copy {}
11+
}
12+
13+
goal {
14+
fn(()): Sized
15+
} yields {
16+
"Unique; substitution [], lifetime constraints []"
17+
}
18+
19+
goal {
20+
fn(dyn Copy): Sized
21+
} yields {
22+
"Unique; substitution [], lifetime constraints []"
23+
}
24+
}
25+
}

tests/test/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,7 @@ mod coherence_goals;
309309
mod coinduction;
310310
mod cycle;
311311
mod existential_types;
312+
mod functions;
312313
mod implied_bounds;
313314
mod impls;
314315
mod misc;

0 commit comments

Comments
 (0)