提交 a277081e 编写于 作者: B Brian Anderson

Rename Owned trait to Durable

上级 cd120736
......@@ -167,7 +167,7 @@ pub mod util;
/* Reexported core operators */
pub use kinds::{Const, Copy, Send, Owned};
pub use kinds::{Const, Copy, Send, Durable};
pub use ops::{Drop};
pub use ops::{Add, Sub, Mul, Div, Modulo, Neg};
pub use ops::{BitAnd, BitOr, BitXor};
......
......@@ -30,9 +30,7 @@
* Const - types that are deeply immutable. Const types are used for
freezable data structures.
* Owned - types that do not contain borrowed pointers. Note that this
meaning of 'owned' conflicts with 'owned pointers'. The two notions
of ownership are different.
* Durable - types that do not contain borrowed pointers.
`Copy` types include both implicitly copyable types that the compiler
will copy automatically and non-implicitly copyable types that require
......@@ -56,7 +54,16 @@ pub trait Const {
// Empty.
}
#[cfg(stage0)]
#[lang="owned"]
pub trait Owned {
pub trait Durable {
// Empty.
}
#[cfg(stage1)]
#[cfg(stage2)]
#[cfg(stage3)]
#[lang="durable"]
pub trait Durable {
// Empty.
}
......@@ -47,13 +47,13 @@
*
* These two cases aside, the interface is safe.
*/
pub type LocalDataKey<T: Owned> = &fn(v: @T);
pub type LocalDataKey<T: Durable> = &fn(v: @T);
/**
* Remove a task-local data value from the table, returning the
* reference that was originally created to insert it.
*/
pub unsafe fn local_data_pop<T: Owned>(
pub unsafe fn local_data_pop<T: Durable>(
key: LocalDataKey<T>) -> Option<@T> {
local_pop(rt::rust_get_task(), key)
......@@ -62,7 +62,7 @@ pub unsafe fn local_data_pop<T: Owned>(
* Retrieve a task-local data value. It will also be kept alive in the
* table until explicitly removed.
*/
pub unsafe fn local_data_get<T: Owned>(
pub unsafe fn local_data_get<T: Durable>(
key: LocalDataKey<T>) -> Option<@T> {
local_get(rt::rust_get_task(), key)
......@@ -71,7 +71,7 @@ pub unsafe fn local_data_get<T: Owned>(
* Store a value in task-local data. If this key already has a value,
* that value is overwritten (and its destructor is run).
*/
pub unsafe fn local_data_set<T: Owned>(
pub unsafe fn local_data_set<T: Durable>(
key: LocalDataKey<T>, data: @T) {
local_set(rt::rust_get_task(), key, data)
......@@ -80,7 +80,7 @@ pub unsafe fn local_data_set<T: Owned>(
* Modify a task-local data value. If the function returns 'None', the
* data is removed (and its reference dropped).
*/
pub unsafe fn local_data_modify<T: Owned>(
pub unsafe fn local_data_modify<T: Durable>(
key: LocalDataKey<T>,
modify_fn: fn(Option<@T>) -> Option<@T>) {
......
......@@ -19,7 +19,7 @@
type rust_task = libc::c_void;
pub trait LocalData { }
impl<T: Owned> @T: LocalData { }
impl<T: Durable> @T: LocalData { }
impl LocalData: Eq {
pure fn eq(&self, other: &@LocalData) -> bool unsafe {
......@@ -67,7 +67,7 @@ unsafe fn get_task_local_map(task: *rust_task) -> TaskLocalMap {
}
}
unsafe fn key_to_key_value<T: Owned>(
unsafe fn key_to_key_value<T: Durable>(
key: LocalDataKey<T>) -> *libc::c_void {
// Keys are closures, which are (fnptr,envptr) pairs. Use fnptr.
......@@ -77,7 +77,7 @@ unsafe fn key_to_key_value<T: Owned>(
}
// If returning Some(..), returns with @T with the map's reference. Careful!
unsafe fn local_data_lookup<T: Owned>(
unsafe fn local_data_lookup<T: Durable>(
map: TaskLocalMap, key: LocalDataKey<T>)
-> Option<(uint, *libc::c_void)> {
......@@ -95,7 +95,7 @@ unsafe fn local_data_lookup<T: Owned>(
}
}
unsafe fn local_get_helper<T: Owned>(
unsafe fn local_get_helper<T: Durable>(
task: *rust_task, key: LocalDataKey<T>,
do_pop: bool) -> Option<@T> {
......@@ -117,21 +117,21 @@ unsafe fn local_get_helper<T: Owned>(
}
pub unsafe fn local_pop<T: Owned>(
pub unsafe fn local_pop<T: Durable>(
task: *rust_task,
key: LocalDataKey<T>) -> Option<@T> {
local_get_helper(task, key, true)
}
pub unsafe fn local_get<T: Owned>(
pub unsafe fn local_get<T: Durable>(
task: *rust_task,
key: LocalDataKey<T>) -> Option<@T> {
local_get_helper(task, key, false)
}
pub unsafe fn local_set<T: Owned>(
pub unsafe fn local_set<T: Durable>(
task: *rust_task, key: LocalDataKey<T>, data: @T) {
let map = get_task_local_map(task);
......@@ -163,7 +163,7 @@ pub unsafe fn local_set<T: Owned>(
}
}
pub unsafe fn local_modify<T: Owned>(
pub unsafe fn local_modify<T: Durable>(
task: *rust_task, key: LocalDataKey<T>,
modify_fn: fn(Option<@T>) -> Option<@T>) {
......
......@@ -487,7 +487,7 @@ fn parse_bounds(st: @pstate, conv: conv_did) -> @~[ty::param_bound] {
'S' => ty::bound_send,
'C' => ty::bound_copy,
'K' => ty::bound_const,
'O' => ty::bound_owned,
'O' => ty::bound_durable,
'I' => ty::bound_trait(parse_ty(st, conv)),
'.' => break,
_ => fail ~"parse_bounds: bad bounds"
......
......@@ -395,7 +395,7 @@ fn enc_bounds(w: io::Writer, cx: @ctxt, bs: @~[ty::param_bound]) {
ty::bound_send => w.write_char('S'),
ty::bound_copy => w.write_char('C'),
ty::bound_const => w.write_char('K'),
ty::bound_owned => w.write_char('O'),
ty::bound_durable => w.write_char('O'),
ty::bound_trait(tp) => {
w.write_char('I');
enc_ty(w, cx, tp);
......
......@@ -64,8 +64,8 @@ fn kind_to_str(k: Kind) -> ~str {
if ty::kind_can_be_sent(k) {
kinds.push(~"send");
} else if ty::kind_is_owned(k) {
kinds.push(~"owned");
} else if ty::kind_is_durable(k) {
kinds.push(~"durable");
}
str::connect(kinds, ~" ")
......@@ -136,7 +136,7 @@ fn check_for_uniq(cx: ctx, id: node_id, fv: Option<@freevar_entry>,
fn check_for_box(cx: ctx, id: node_id, fv: Option<@freevar_entry>,
is_move: bool, var_t: ty::t, sp: span) {
// all captured data must be owned
if !check_owned(cx.tcx, var_t, sp) { return; }
if !check_durable(cx.tcx, var_t, sp) { return; }
// copied in data must be copyable, but moved in data can be anything
let is_implicit = fv.is_some();
......@@ -555,12 +555,12 @@ fn check_send(cx: ctx, ty: ty::t, sp: span) -> bool {
}
// note: also used from middle::typeck::regionck!
fn check_owned(tcx: ty::ctxt, ty: ty::t, sp: span) -> bool {
if !ty::kind_is_owned(ty::type_kind(tcx, ty)) {
fn check_durable(tcx: ty::ctxt, ty: ty::t, sp: span) -> bool {
if !ty::kind_is_durable(ty::type_kind(tcx, ty)) {
match ty::get(ty).sty {
ty::ty_param(*) => {
tcx.sess.span_err(sp, ~"value may contain borrowed \
pointers; use `owned` bound");
pointers; use `durable` bound");
}
_ => {
tcx.sess.span_err(sp, ~"value may contain borrowed \
......@@ -632,7 +632,7 @@ fn check_cast_for_escaping_regions(
if target_params.contains(&source_param) {
/* case (2) */
} else {
check_owned(cx.tcx, ty, source.span); /* case (3) */
check_durable(cx.tcx, ty, source.span); /* case (3) */
}
}
_ => {}
......
......@@ -36,7 +36,7 @@ struct LanguageItems {
mut const_trait: Option<def_id>,
mut copy_trait: Option<def_id>,
mut send_trait: Option<def_id>,
mut owned_trait: Option<def_id>,
mut durable_trait: Option<def_id>,
mut drop_trait: Option<def_id>,
......@@ -69,7 +69,7 @@ fn make() -> LanguageItems {
const_trait: None,
copy_trait: None,
send_trait: None,
owned_trait: None,
durable_trait: None,
drop_trait: None,
......@@ -106,7 +106,7 @@ fn LanguageItemCollector(crate: @crate, session: Session,
item_refs.insert(~"const", &mut items.const_trait);
item_refs.insert(~"copy", &mut items.copy_trait);
item_refs.insert(~"send", &mut items.send_trait);
item_refs.insert(~"owned", &mut items.owned_trait);
item_refs.insert(~"durable", &mut items.durable_trait);
item_refs.insert(~"drop", &mut items.drop_trait);
......
......@@ -140,7 +140,7 @@
export kind_can_be_copied, kind_can_be_sent, kind_can_be_implicitly_copied;
export type_implicitly_moves;
export kind_is_safe_for_default_mode;
export kind_is_owned;
export kind_is_durable;
export meta_kind, kind_lteq, type_kind;
export operators;
export type_err, terr_vstore_kind;
......@@ -176,7 +176,7 @@
export walk_ty, maybe_walk_ty;
export occurs_check;
export param_ty;
export param_bound, param_bounds, bound_copy, bound_owned;
export param_bound, param_bounds, bound_copy, bound_durable;
export param_bounds_to_str, param_bound_to_str;
export bound_send, bound_trait;
export param_bounds_to_kind;
......@@ -702,7 +702,7 @@ enum type_err {
enum param_bound {
bound_copy,
bound_owned,
bound_durable,
bound_send,
bound_const,
bound_trait(t),
......@@ -769,7 +769,7 @@ impl param_bound : to_bytes::IterBytes {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
match *self {
bound_copy => 0u8.iter_bytes(lsb0, f),
bound_owned => 1u8.iter_bytes(lsb0, f),
bound_durable => 1u8.iter_bytes(lsb0, f),
bound_send => 2u8.iter_bytes(lsb0, f),
bound_const => 3u8.iter_bytes(lsb0, f),
bound_trait(ref t) =>
......@@ -873,11 +873,11 @@ fn param_bounds_to_kind(bounds: param_bounds) -> Kind {
bound_copy => {
kind = raise_kind(kind, kind_implicitly_copyable());
}
bound_owned => {
kind = raise_kind(kind, kind_owned());
bound_durable => {
kind = raise_kind(kind, kind_durable());
}
bound_send => {
kind = raise_kind(kind, kind_send_only() | kind_owned());
kind = raise_kind(kind, kind_send_only() | kind_durable());
}
bound_const => {
kind = raise_kind(kind, kind_const());
......@@ -1549,7 +1549,7 @@ fn substs_to_str(cx: ctxt, substs: &substs) -> ~str {
fn param_bound_to_str(cx: ctxt, pb: &param_bound) -> ~str {
match *pb {
bound_copy => ~"copy",
bound_owned => ~"owned",
bound_durable => ~"durable",
bound_send => ~"send",
bound_const => ~"const",
bound_trait(t) => ty_to_str(cx, t)
......@@ -1908,11 +1908,11 @@ enum Kind { kind_(u32) }
/// can be copied (implicitly or explicitly)
const KIND_MASK_COPY : u32 = 0b000000000000000000000000001_u32;
/// can be sent: no shared box, borrowed ptr (must imply OWNED)
/// can be sent: no shared box, borrowed ptr (must imply DURABLE)
const KIND_MASK_SEND : u32 = 0b000000000000000000000000010_u32;
/// is owned (no borrowed ptrs)
const KIND_MASK_OWNED : u32 = 0b000000000000000000000000100_u32;
/// is durable (no borrowed ptrs)
const KIND_MASK_DURABLE : u32 = 0b000000000000000000000000100_u32;
/// is deeply immutable
const KIND_MASK_CONST : u32 = 0b000000000000000000000001000_u32;
......@@ -1963,8 +1963,8 @@ fn kind_const() -> Kind {
kind_(KIND_MASK_CONST)
}
fn kind_owned() -> Kind {
kind_(KIND_MASK_OWNED)
fn kind_durable() -> Kind {
kind_(KIND_MASK_DURABLE)
}
fn kind_top() -> Kind {
......@@ -1983,8 +1983,8 @@ fn remove_send(k: Kind) -> Kind {
k - kind_(KIND_MASK_SEND)
}
fn remove_owned_send(k: Kind) -> Kind {
k - kind_(KIND_MASK_OWNED) - kind_(KIND_MASK_SEND)
fn remove_durable_send(k: Kind) -> Kind {
k - kind_(KIND_MASK_DURABLE) - kind_(KIND_MASK_SEND)
}
fn remove_copyable(k: Kind) -> Kind {
......@@ -2034,23 +2034,23 @@ impl Kind : ops::Sub<Kind,Kind> {
*k & KIND_MASK_SEND == KIND_MASK_SEND
}
pure fn kind_is_owned(k: Kind) -> bool {
*k & KIND_MASK_OWNED == KIND_MASK_OWNED
pure fn kind_is_durable(k: Kind) -> bool {
*k & KIND_MASK_DURABLE == KIND_MASK_DURABLE
}
fn meta_kind(p: FnMeta) -> Kind {
match p.proto { // XXX consider the kind bounds!
ast::ProtoBare => {
kind_safe_for_default_mode_send() | kind_const() | kind_owned()
kind_safe_for_default_mode_send() | kind_const() | kind_durable()
}
ast::ProtoBorrowed => {
kind_noncopyable() | kind_(KIND_MASK_DEFAULT_MODE)
}
ast::ProtoBox => {
kind_safe_for_default_mode() | kind_owned()
kind_safe_for_default_mode() | kind_durable()
}
ast::ProtoUniq => {
kind_send_copy() | kind_owned()
kind_send_copy() | kind_durable()
}
}
}
......@@ -2113,15 +2113,15 @@ fn type_kind(cx: ctxt, ty: t) -> Kind {
// Scalar and unique types are sendable, constant, and owned
ty_nil | ty_bot | ty_bool | ty_int(_) | ty_uint(_) | ty_float(_) |
ty_ptr(_) => {
kind_safe_for_default_mode_send() | kind_const() | kind_owned()
kind_safe_for_default_mode_send() | kind_const() | kind_durable()
}
// Implicit copyability of strs is configurable
ty_estr(vstore_uniq) => {
if cx.vecs_implicitly_copyable {
kind_implicitly_sendable() | kind_const() | kind_owned()
kind_implicitly_sendable() | kind_const() | kind_durable()
} else {
kind_send_copy() | kind_const() | kind_owned()
kind_send_copy() | kind_const() | kind_durable()
}
}
......@@ -2135,7 +2135,7 @@ fn type_kind(cx: ctxt, ty: t) -> Kind {
}
// Trait instances are (for now) like shared boxes, basically
ty_trait(_, _, _) => kind_safe_for_default_mode() | kind_owned(),
ty_trait(_, _, _) => kind_safe_for_default_mode() | kind_durable(),
// Static region pointers are copyable and sendable, but not owned
ty_rptr(re_static, mt) =>
......@@ -2167,8 +2167,8 @@ fn type_kind(cx: ctxt, ty: t) -> Kind {
kind_safe_for_default_mode() | mutable_type_kind(cx, tm)
}
ty_evec(tm, vstore_slice(_)) => {
remove_owned_send(kind_safe_for_default_mode() |
mutable_type_kind(cx, tm))
remove_durable_send(kind_safe_for_default_mode() |
mutable_type_kind(cx, tm))
}
ty_evec(tm, vstore_fixed(_)) => {
mutable_type_kind(cx, tm)
......@@ -2176,7 +2176,7 @@ fn type_kind(cx: ctxt, ty: t) -> Kind {
// All estrs are copyable; uniques and interiors are sendable.
ty_estr(vstore_box) => {
kind_safe_for_default_mode() | kind_const() | kind_owned()
kind_safe_for_default_mode() | kind_const() | kind_durable()
}
ty_estr(vstore_slice(re_static)) => {
kind_safe_for_default_mode() | kind_send_copy() | kind_const()
......@@ -2185,7 +2185,7 @@ fn type_kind(cx: ctxt, ty: t) -> Kind {
kind_safe_for_default_mode() | kind_const()
}
ty_estr(vstore_fixed(_)) => {
kind_safe_for_default_mode_send() | kind_const() | kind_owned()
kind_safe_for_default_mode_send() | kind_const() | kind_durable()
}
// Records lower to the lowest of their members.
......@@ -2226,7 +2226,7 @@ fn type_kind(cx: ctxt, ty: t) -> Kind {
let mut lowest = kind_top();
let variants = enum_variants(cx, did);
if vec::len(*variants) == 0u {
lowest = kind_send_only() | kind_owned();
lowest = kind_send_only() | kind_durable();
} else {
for vec::each(*variants) |variant| {
for variant.args.each |aty| {
......@@ -4237,7 +4237,7 @@ fn iter_bound_traits_and_supertraits(tcx: ctxt,
ty::bound_trait(bound_t) => bound_t,
ty::bound_copy | ty::bound_send |
ty::bound_const | ty::bound_owned => {
ty::bound_const | ty::bound_durable => {
loop; // skip non-trait bounds
}
};
......@@ -4647,9 +4647,9 @@ impl param_bound : cmp::Eq {
_ => false
}
}
bound_owned => {
bound_durable => {
match (*other) {
bound_owned => true,
bound_durable => true,
_ => false
}
}
......
......@@ -80,7 +80,7 @@ fn get_region_reporting_err(tcx: ty::ctxt,
}
}
fn ast_region_to_region<AC: ast_conv, RS: region_scope Copy Owned>(
fn ast_region_to_region<AC: ast_conv, RS: region_scope Copy Durable>(
self: AC, rscope: RS, span: span, a_r: @ast::region) -> ty::Region {
let res = match a_r.node {
......@@ -93,7 +93,7 @@ fn ast_region_to_region<AC: ast_conv, RS: region_scope Copy Owned>(
get_region_reporting_err(self.tcx(), span, res)
}
fn ast_path_to_substs_and_ty<AC: ast_conv, RS: region_scope Copy Owned>(
fn ast_path_to_substs_and_ty<AC: ast_conv, RS: region_scope Copy Durable>(
self: AC, rscope: RS, did: ast::def_id,
path: @ast::path) -> ty_param_substs_and_ty {
......@@ -142,7 +142,7 @@ fn ast_path_to_substs_and_ty<AC: ast_conv, RS: region_scope Copy Owned>(
{substs: substs, ty: ty::subst(tcx, &substs, decl_ty)}
}
pub fn ast_path_to_ty<AC: ast_conv, RS: region_scope Copy Owned>(
pub fn ast_path_to_ty<AC: ast_conv, RS: region_scope Copy Durable>(
self: AC,
rscope: RS,
did: ast::def_id,
......@@ -165,10 +165,10 @@ pub fn ast_path_to_ty<AC: ast_conv, RS: region_scope Copy Owned>(
// Parses the programmer's textual representation of a type into our
// internal notion of a type. `getter` is a function that returns the type
// corresponding to a definition ID:
fn ast_ty_to_ty<AC: ast_conv, RS: region_scope Copy Owned>(
fn ast_ty_to_ty<AC: ast_conv, RS: region_scope Copy Durable>(
self: AC, rscope: RS, &&ast_ty: @ast::Ty) -> ty::t {
fn ast_mt_to_mt<AC: ast_conv, RS: region_scope Copy Owned>(
fn ast_mt_to_mt<AC: ast_conv, RS: region_scope Copy Durable>(
self: AC, rscope: RS, mt: ast::mt) -> ty::mt {
return {ty: ast_ty_to_ty(self, rscope, mt.ty), mutbl: mt.mutbl};
......@@ -177,7 +177,7 @@ fn ast_mt_to_mt<AC: ast_conv, RS: region_scope Copy Owned>(
// Handle @, ~, and & being able to mean estrs and evecs.
// If a_seq_ty is a str or a vec, make it an estr/evec.
// Also handle function sigils and first-class trait types.
fn mk_pointer<AC: ast_conv, RS: region_scope Copy Owned>(
fn mk_pointer<AC: ast_conv, RS: region_scope Copy Durable>(
self: AC,
rscope: RS,
a_seq_ty: ast::mt,
......@@ -390,7 +390,7 @@ fn check_path_args(tcx: ty::ctxt,
return typ;
}
fn ty_of_arg<AC: ast_conv, RS: region_scope Copy Owned>(
fn ty_of_arg<AC: ast_conv, RS: region_scope Copy Durable>(
self: AC, rscope: RS, a: ast::arg,
expected_ty: Option<ty::arg>) -> ty::arg {
......@@ -439,7 +439,7 @@ fn ty_of_arg<AC: ast_conv, RS: region_scope Copy Owned>(
type expected_tys = Option<{inputs: ~[ty::arg],
output: ty::t}>;
fn ty_of_fn_decl<AC: ast_conv, RS: region_scope Copy Owned>(
fn ty_of_fn_decl<AC: ast_conv, RS: region_scope Copy Durable>(
self: AC, rscope: RS,
ast_proto: ast::Proto,
purity: ast::purity,
......
......@@ -343,7 +343,7 @@ fn push_inherent_candidates_from_param(&self,
ty::bound_trait(bound_t) => bound_t,
ty::bound_copy | ty::bound_send |
ty::bound_const | ty::bound_owned => {
ty::bound_const | ty::bound_durable => {
loop; // skip non-trait bounds
}
};
......
......@@ -28,7 +28,6 @@
*/
use middle::freevars::get_freevars;
use middle::kind::check_owned;
use middle::pat_util::pat_bindings;
use middle::ty::{encl_region, re_scope};
use middle::ty::{ty_fn_proto, vstore_box, vstore_fixed, vstore_slice};
......
......@@ -88,7 +88,7 @@ fn collect_item_types(ccx: @crate_ctxt, crate: @ast::crate) {
}
impl @crate_ctxt {
fn to_ty<RS: region_scope Copy Owned>(
fn to_ty<RS: region_scope Copy Durable>(
rs: RS, ast_ty: @ast::Ty) -> ty::t {
ast_ty_to_ty(self, rs, ast_ty)
......@@ -863,7 +863,7 @@ fn ty_of_foreign_item(ccx: @crate_ctxt, it: @ast::foreign_item)
// Translate the AST's notion of ty param bounds (which are just newtyped Tys)
// to ty's notion of ty param bounds, which can either be user-defined traits,
// or one of the four built-in traits (formerly known as kinds): Const, Copy,
// Owned, and Send.
// Durable, and Send.
fn compute_bounds(ccx: @crate_ctxt,
ast_bounds: @~[ast::ty_param_bound]) -> ty::param_bounds {
@do vec::flat_map(*ast_bounds) |b| {
......@@ -881,8 +881,8 @@ fn compute_bounds(ccx: @crate_ctxt,
else if d == li.const_trait {
~[ty::bound_const]
}
else if d == li.owned_trait {
~[ty::bound_owned]
else if d == li.durable_trait {
~[ty::bound_durable]
}
else {
// Must be a user-defined trait
......
......@@ -60,7 +60,7 @@ fn bound_self_region(rp: Option<ty::region_variance>) -> Option<ty::Region> {
}
enum anon_rscope = {anon: ty::Region, base: region_scope};
fn in_anon_rscope<RS: region_scope Copy Owned>(self: RS, r: ty::Region)
fn in_anon_rscope<RS: region_scope Copy Durable>(self: RS, r: ty::Region)
-> @anon_rscope {
@anon_rscope({anon: r, base: self as region_scope})
}
......@@ -80,7 +80,7 @@ struct binding_rscope {
base: region_scope,
mut anon_bindings: uint,
}
fn in_binding_rscope<RS: region_scope Copy Owned>(self: RS)
fn in_binding_rscope<RS: region_scope Copy Durable>(self: RS)
-> @binding_rscope {
let base = self as region_scope;
@binding_rscope { base: base, anon_bindings: 0 }
......
......@@ -11,7 +11,7 @@
use std::map::HashMap;
use middle::ty;
use middle::ty::{arg, canon_mode};
use middle::ty::{bound_copy, bound_const, bound_owned, bound_send,
use middle::ty::{bound_copy, bound_const, bound_durable, bound_send,
bound_trait};
use middle::ty::{bound_region, br_anon, br_named, br_self, br_cap_avoid};
use middle::ty::{ctxt, field, method};
......
......@@ -210,7 +210,7 @@ fn test_boxes() {
assert (deq.get(3) == d);
}
fn test_parameterized<T: Copy Eq Owned>(a: T, b: T, c: T, d: T) {
fn test_parameterized<T: Copy Eq Durable>(a: T, b: T, c: T, d: T) {
let deq: deque::Deque<T> = deque::create::<T>();
assert (deq.size() == 0u);
deq.add_front(a);
......
......@@ -34,7 +34,7 @@ fn main() {
let mut res = foo(x);
let mut v = ~[mut];
v = move ~[mut (move res)] + v; //~ ERROR instantiating a type parameter with an incompatible type (needs `copy`, got `owned`, missing `copy`)
v = move ~[mut (move res)] + v; //~ ERROR instantiating a type parameter with an incompatible type (needs `copy`, got `durable`, missing `copy`)
assert (v.len() == 2);
}
......
......@@ -32,10 +32,10 @@ fn to_foo<T:Copy>(t: T) {
fn to_foo_2<T:Copy>(t: T) -> foo {
// Not OK---T may contain borrowed ptrs and it is going to escape
// as part of the returned foo value
{f:t} as foo //~ ERROR value may contain borrowed pointers; use `owned` bound
{f:t} as foo //~ ERROR value may contain borrowed pointers; use `durable` bound
}
fn to_foo_3<T:Copy Owned>(t: T) -> foo {
fn to_foo_3<T:Copy Durable>(t: T) -> foo {
// OK---T may escape as part of the returned foo value, but it is
// owned and hence does not contain borrowed ptrs
{f:t} as foo
......
......@@ -11,10 +11,10 @@
trait foo { fn foo(); }
fn to_foo<T: Copy foo>(t: T) -> foo {
t as foo //~ ERROR value may contain borrowed pointers; use `owned` bound
t as foo //~ ERROR value may contain borrowed pointers; use `durable` bound
}
fn to_foo2<T: Copy foo Owned>(t: T) -> foo {
fn to_foo2<T: Copy foo Durable>(t: T) -> foo {
t as foo
}
......
......@@ -12,18 +12,18 @@ fn copy1<T: Copy>(t: T) -> fn@() -> T {
fn@() -> T { t } //~ ERROR value may contain borrowed pointers
}
fn copy2<T: Copy Owned>(t: T) -> fn@() -> T {
fn copy2<T: Copy Durable>(t: T) -> fn@() -> T {
fn@() -> T { t }
}
fn main() {
let x = &3;
copy2(&x); //~ ERROR missing `owned`
copy2(&x); //~ ERROR missing `durable`
copy2(@3);
copy2(@&x); //~ ERROR missing `owned`
copy2(@&x); //~ ERROR missing `durable`
copy2(fn@() {});
copy2(fn~() {}); //~ WARNING instantiating copy type parameter with a not implicitly copyable type
copy2(fn&() {}); //~ ERROR missing `copy owned`
copy2(fn&() {}); //~ ERROR missing `copy durable`
}
......@@ -12,7 +12,7 @@
a: A, b: B
};
fn f<A:Copy Owned>(a: A, b: u16) -> fn@() -> (A, u16) {
fn f<A:Copy Durable>(a: A, b: u16) -> fn@() -> (A, u16) {
fn@() -> (A, u16) { (a, b) }
}
......
......@@ -16,7 +16,7 @@
a: A, b: B
};
fn f<A:Copy Owned>(a: A, b: u16) -> fn@() -> (A, u16) {
fn f<A:Copy Durable>(a: A, b: u16) -> fn@() -> (A, u16) {
fn@() -> (A, u16) { (a, b) }
}
......
......@@ -11,11 +11,11 @@
// xfail-fast
#[legacy_modes];
fn fix_help<A: Owned, B: Send>(f: extern fn(fn@(A) -> B, A) -> B, x: A) -> B {
fn fix_help<A: Durable, B: Send>(f: extern fn(fn@(A) -> B, A) -> B, x: A) -> B {
return f({|a|fix_help(f, a)}, x);
}
fn fix<A: Owned, B: Send>(f: extern fn(fn@(A) -> B, A) -> B) -> fn@(A) -> B {
fn fix<A: Durable, B: Send>(f: extern fn(fn@(A) -> B, A) -> B) -> fn@(A) -> B {
return {|a|fix_help(f, a)};
}
......
......@@ -11,7 +11,7 @@
trait hax { }
impl <A> A: hax { }
fn perform_hax<T: Owned>(x: @T) -> hax {
fn perform_hax<T: Durable>(x: @T) -> hax {
x as hax
}
......
......@@ -11,7 +11,7 @@
trait hax { }
impl <A> A: hax { }
fn perform_hax<T: Owned>(x: @T) -> hax {
fn perform_hax<T: Durable>(x: @T) -> hax {
x as hax
}
......
......@@ -59,7 +59,7 @@ fn square_from_char(c: char) -> square {
}
}
fn read_board_grid<rdr: Owned io::Reader>(+in: rdr) -> ~[~[square]] {
fn read_board_grid<rdr: Durable io::Reader>(+in: rdr) -> ~[~[square]] {
let in = (move in) as io::Reader;
let mut grid = ~[];
for in.each_line |line| {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册