Add BuiltinBounds to closure type: parse and handle subtyping,

but do not integrate with kindck etc (requires a snapshot first)
This commit is contained in:
Niko Matsakis 2013-05-10 15:57:27 -04:00
parent 53196bb364
commit 035c01af93
19 changed files with 261 additions and 61 deletions

View file

@ -0,0 +1,8 @@
trait Foo {}
fn take(f: &fn:Foo()) {
//~^ ERROR only the builtin traits can be used as closure or object bounds
}
fn main() {}

View file

@ -0,0 +1,34 @@
fn take_any(_: &fn()) {
}
fn take_copyable(_: &fn:Copy()) {
}
fn take_copyable_owned(_: &fn:Copy+Owned()) {
}
fn give_any(f: &fn()) {
take_any(f);
take_copyable(f); //~ ERROR expected bounds `Copy` but found no bounds
take_copyable_owned(f); //~ ERROR expected bounds `Copy+Owned` but found no bounds
}
fn give_copyable(f: &fn:Copy()) {
take_any(f);
take_copyable(f);
take_copyable_owned(f); //~ ERROR expected bounds `Copy+Owned` but found bounds `Copy`
}
fn give_owned(f: &fn:Owned()) {
take_any(f);
take_copyable(f); //~ ERROR expected bounds `Copy` but found bounds `Owned`
take_copyable_owned(f); //~ ERROR expected bounds `Copy+Owned` but found bounds `Owned`
}
fn give_copyable_owned(f: &fn:Copy+Owned()) {
take_any(f);
take_copyable(f);
take_copyable_owned(f);
}
fn main() {}