diff options
| author | Eric Holk <eric.holk@gmail.com> | 2012-05-22 14:10:32 -0700 |
|---|---|---|
| committer | Eric Holk <eric.holk@gmail.com> | 2012-05-22 14:10:32 -0700 |
| commit | 0b2f2cabbe3fbe6e18cbf0f8a174b7d4789fc938 (patch) | |
| tree | ce84fbb044a908ff5c98fd1fa0e6990159126177 /src/rustc/middle | |
| parent | f213c1f3a817ba2c0a43c0b27215146b7a279f65 (diff) | |
| download | rust-0b2f2cabbe3fbe6e18cbf0f8a174b7d4789fc938.tar.gz rust-0b2f2cabbe3fbe6e18cbf0f8a174b7d4789fc938.zip | |
Send is no longer a subkind of copy. This allows for sendable, but non-copyable resources. Closes #2420.
Diffstat (limited to 'src/rustc/middle')
| -rw-r--r-- | src/rustc/middle/kind.rs | 10 | ||||
| -rw-r--r-- | src/rustc/middle/ty.rs | 12 |
2 files changed, 14 insertions, 8 deletions
diff --git a/src/rustc/middle/kind.rs b/src/rustc/middle/kind.rs index e7c318b7da5..effa593109c 100644 --- a/src/rustc/middle/kind.rs +++ b/src/rustc/middle/kind.rs @@ -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, ()>; diff --git a/src/rustc/middle/ty.rs b/src/rustc/middle/ty.rs index 998dc9d5951..52cee2fd07b 100644 --- a/src/rustc/middle/ty.rs +++ b/src/rustc/middle/ty.rs @@ -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)) } |
