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:
parent
53196bb364
commit
035c01af93
19 changed files with 261 additions and 61 deletions
8
src/test/compile-fail/closure-bounds-not-builtin.rs
Normal file
8
src/test/compile-fail/closure-bounds-not-builtin.rs
Normal 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() {}
|
||||
34
src/test/compile-fail/closure-bounds-subtype.rs
Normal file
34
src/test/compile-fail/closure-bounds-subtype.rs
Normal 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() {}
|
||||
Loading…
Add table
Add a link
Reference in a new issue