Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
a277081e
R
Rust
项目概览
int
/
Rust
大约 1 年 前同步成功
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
Rust
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
a277081e
编写于
12月 11, 2012
作者:
B
Brian Anderson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Rename Owned trait to Durable
上级
cd120736
变更
26
隐藏空白更改
内联
并排
Showing
26 changed file
with
102 addition
and
96 deletion
+102
-96
src/libcore/core.rc
src/libcore/core.rc
+1
-1
src/libcore/kinds.rs
src/libcore/kinds.rs
+11
-4
src/libcore/task/local_data.rs
src/libcore/task/local_data.rs
+5
-5
src/libcore/task/local_data_priv.rs
src/libcore/task/local_data_priv.rs
+8
-8
src/librustc/metadata/tydecode.rs
src/librustc/metadata/tydecode.rs
+1
-1
src/librustc/metadata/tyencode.rs
src/librustc/metadata/tyencode.rs
+1
-1
src/librustc/middle/kind.rs
src/librustc/middle/kind.rs
+7
-7
src/librustc/middle/lang_items.rs
src/librustc/middle/lang_items.rs
+3
-3
src/librustc/middle/ty.rs
src/librustc/middle/ty.rs
+32
-32
src/librustc/middle/typeck/astconv.rs
src/librustc/middle/typeck/astconv.rs
+8
-8
src/librustc/middle/typeck/check/method.rs
src/librustc/middle/typeck/check/method.rs
+1
-1
src/librustc/middle/typeck/check/regionck.rs
src/librustc/middle/typeck/check/regionck.rs
+0
-1
src/librustc/middle/typeck/collect.rs
src/librustc/middle/typeck/collect.rs
+4
-4
src/librustc/middle/typeck/rscope.rs
src/librustc/middle/typeck/rscope.rs
+2
-2
src/librustc/util/ppaux.rs
src/librustc/util/ppaux.rs
+1
-1
src/libstd/deque.rs
src/libstd/deque.rs
+1
-1
src/test/compile-fail/issue-2548.rs
src/test/compile-fail/issue-2548.rs
+1
-1
src/test/compile-fail/kindck-owned-trait-scoped.rs
src/test/compile-fail/kindck-owned-trait-scoped.rs
+2
-2
src/test/compile-fail/kindck-owned-trait.rs
src/test/compile-fail/kindck-owned-trait.rs
+2
-2
src/test/compile-fail/kindck-owned.rs
src/test/compile-fail/kindck-owned.rs
+4
-4
src/test/run-pass/alignment-gep-tup-like-1.rs
src/test/run-pass/alignment-gep-tup-like-1.rs
+1
-1
src/test/run-pass/close-over-big-then-small-data.rs
src/test/run-pass/close-over-big-then-small-data.rs
+1
-1
src/test/run-pass/fixed-point-bind-unique.rs
src/test/run-pass/fixed-point-bind-unique.rs
+2
-2
src/test/run-pass/issue-2734.rs
src/test/run-pass/issue-2734.rs
+1
-1
src/test/run-pass/issue-2735.rs
src/test/run-pass/issue-2735.rs
+1
-1
src/test/run-pass/issue-2904.rs
src/test/run-pass/issue-2904.rs
+1
-1
未找到文件。
src/libcore/core.rc
浏览文件 @
a277081e
...
...
@@ -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};
...
...
src/libcore/kinds.rs
浏览文件 @
a277081e
...
...
@@ -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.
}
src/libcore/task/local_data.rs
浏览文件 @
a277081e
...
...
@@ -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
>
)
{
...
...
src/libcore/task/local_data_priv.rs
浏览文件 @
a277081e
...
...
@@ -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
>
)
{
...
...
src/librustc/metadata/tydecode.rs
浏览文件 @
a277081e
...
...
@@ -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"
...
...
src/librustc/metadata/tyencode.rs
浏览文件 @
a277081e
...
...
@@ -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
);
...
...
src/librustc/middle/kind.rs
浏览文件 @
a277081e
...
...
@@ -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) */
}
}
_
=>
{}
...
...
src/librustc/middle/lang_items.rs
浏览文件 @
a277081e
...
...
@@ -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
);
...
...
src/librustc/middle/ty.rs
浏览文件 @
a277081e
...
...
@@ -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
}
}
...
...
src/librustc/middle/typeck/astconv.rs
浏览文件 @
a277081e
...
...
@@ -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
,
...
...
src/librustc/middle/typeck/check/method.rs
浏览文件 @
a277081e
...
...
@@ -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
}
};
...
...
src/librustc/middle/typeck/check/regionck.rs
浏览文件 @
a277081e
...
...
@@ -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
};
...
...
src/librustc/middle/typeck/collect.rs
浏览文件 @
a277081e
...
...
@@ -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
...
...
src/librustc/middle/typeck/rscope.rs
浏览文件 @
a277081e
...
...
@@ -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
}
...
...
src/librustc/util/ppaux.rs
浏览文件 @
a277081e
...
...
@@ -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
};
...
...
src/libstd/deque.rs
浏览文件 @
a277081e
...
...
@@ -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
);
...
...
src/test/compile-fail/issue-2548.rs
浏览文件 @
a277081e
...
...
@@ -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
);
}
...
...
src/test/compile-fail/kindck-owned-trait-scoped.rs
浏览文件 @
a277081e
...
...
@@ -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
...
...
src/test/compile-fail/kindck-owned-trait.rs
浏览文件 @
a277081e
...
...
@@ -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
}
...
...
src/test/compile-fail/kindck-owned.rs
浏览文件 @
a277081e
...
...
@@ -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
`
}
src/test/run-pass/alignment-gep-tup-like-1.rs
浏览文件 @
a277081e
...
...
@@ -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
)
}
}
...
...
src/test/run-pass/close-over-big-then-small-data.rs
浏览文件 @
a277081e
...
...
@@ -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
)
}
}
...
...
src/test/run-pass/fixed-point-bind-unique.rs
浏览文件 @
a277081e
...
...
@@ -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
)};
}
...
...
src/test/run-pass/issue-2734.rs
浏览文件 @
a277081e
...
...
@@ -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
}
...
...
src/test/run-pass/issue-2735.rs
浏览文件 @
a277081e
...
...
@@ -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
}
...
...
src/test/run-pass/issue-2904.rs
浏览文件 @
a277081e
...
...
@@ -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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录