Send is no longer a subkind of copy. This allows for sendable, but non-copyable resources. Closes #2420.

This commit is contained in:
Eric Holk 2012-05-22 14:10:32 -07:00
parent f213c1f3a8
commit 0b2f2cabbe
10 changed files with 43 additions and 48 deletions

View file

@ -24,10 +24,12 @@ import freevars::freevar_entry;
// types.
fn kind_to_str(k: kind) -> str {
if k == kind_sendable() { "sendable" }
else if k == kind_copyable() { "copyable" }
else if k == kind_noncopyable() { "noncopyable" }
else { fail "unknown kind" }
alt (ty::kind_can_be_copied(k), ty::kind_can_be_sent(k)) {
(false, false) { "noncopyable" }
(false, true) { "sendable" }
(true, false) { "copyable" }
(true, true) { "copy-sendable" }
}
}
type rval_map = std::map::hashmap<node_id, ()>;

View file

@ -425,9 +425,9 @@ fn param_bounds_to_kind(bounds: param_bounds) -> kind {
for vec::each(*bounds) {|bound|
alt bound {
bound_copy {
if kind != kind_sendable() { kind = kind_copyable(); }
kind = lower_kind(kind, kind_copyable());
}
bound_send { kind = kind_sendable(); }
bound_send { kind = lower_kind(kind, kind_send_only()); }
_ {}
}
}
@ -1277,6 +1277,10 @@ fn kind_sendable() -> kind {
kind_(KIND_MASK_COPY | KIND_MASK_SEND)
}
fn kind_send_only() -> kind {
kind_(KIND_MASK_SEND)
}
// Using these query functons is preferable to direct comparison or matching
// against the kind constants, as we may modify the kind hierarchy in the
// future.
@ -1303,7 +1307,7 @@ fn kind_lteq(a: kind, b: kind) -> bool {
}
fn lower_kind(a: kind, b: kind) -> kind {
if kind_lteq(a, b) { a } else { b }
kind_(*a | *b)
}
#[test]
@ -1402,7 +1406,7 @@ fn type_kind(cx: ctxt, ty: t) -> kind {
}
lowest
}
ty_res(did, inner, tps) { kind_noncopyable() }
ty_res(did, inner, tps) { kind_send_only() }
ty_param(_, did) {
param_bounds_to_kind(cx.ty_param_bounds.get(did.node))
}