Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
e20549ff
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,发现更多精彩内容 >>
提交
e20549ff
编写于
7月 10, 2013
作者:
P
Patrick Walton
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
librustc: Remove all uses of the `Copy` bound.
上级
99d44d24
变更
94
隐藏空白更改
内联
并排
Showing
94 changed file
with
213 addition
and
280 deletion
+213
-280
src/libextra/par.rs
src/libextra/par.rs
+2
-2
src/libextra/serialize.rs
src/libextra/serialize.rs
+1
-4
src/libextra/sort.rs
src/libextra/sort.rs
+7
-10
src/libextra/timer.rs
src/libextra/timer.rs
+2
-4
src/librust/rust.rs
src/librust/rust.rs
+5
-5
src/librustc/driver/driver.rs
src/librustc/driver/driver.rs
+3
-2
src/librustc/front/std_inject.rs
src/librustc/front/std_inject.rs
+1
-1
src/librustc/front/test.rs
src/librustc/front/test.rs
+1
-1
src/librustc/metadata/filesearch.rs
src/librustc/metadata/filesearch.rs
+1
-1
src/librustc/middle/astencode.rs
src/librustc/middle/astencode.rs
+2
-2
src/librustc/middle/lint.rs
src/librustc/middle/lint.rs
+1
-1
src/librustc/middle/trans/type_use.rs
src/librustc/middle/trans/type_use.rs
+1
-1
src/librustc/middle/ty.rs
src/librustc/middle/ty.rs
+1
-1
src/librustc/middle/typeck/check/mod.rs
src/librustc/middle/typeck/check/mod.rs
+4
-4
src/librustdoc/astsrv.rs
src/librustdoc/astsrv.rs
+2
-1
src/librustdoc/markdown_index_pass.rs
src/librustdoc/markdown_index_pass.rs
+2
-2
src/librustdoc/tystr_pass.rs
src/librustdoc/tystr_pass.rs
+2
-2
src/librustpkg/tests.rs
src/librustpkg/tests.rs
+1
-1
src/libstd/clone.rs
src/libstd/clone.rs
+3
-4
src/libstd/condition.rs
src/libstd/condition.rs
+9
-5
src/libstd/kinds.rs
src/libstd/kinds.rs
+1
-10
src/libstd/local_data.rs
src/libstd/local_data.rs
+1
-1
src/libstd/num/num.rs
src/libstd/num/num.rs
+1
-2
src/libstd/num/strconv.rs
src/libstd/num/strconv.rs
+3
-4
src/libstd/prelude.rs
src/libstd/prelude.rs
+1
-1
src/libstd/rand.rs
src/libstd/rand.rs
+6
-6
src/libstd/task/local_data_priv.rs
src/libstd/task/local_data_priv.rs
+4
-2
src/libstd/trie.rs
src/libstd/trie.rs
+2
-1
src/libstd/tuple.rs
src/libstd/tuple.rs
+3
-7
src/libsyntax/ast_util.rs
src/libsyntax/ast_util.rs
+3
-1
src/libsyntax/ext/base.rs
src/libsyntax/ext/base.rs
+1
-1
src/libsyntax/ext/expand.rs
src/libsyntax/ext/expand.rs
+2
-2
src/libsyntax/parse/parser.rs
src/libsyntax/parse/parser.rs
+30
-30
src/test/auxiliary/static-methods-crate.rs
src/test/auxiliary/static-methods-crate.rs
+1
-1
src/test/bench/shootout-k-nucleotide-pipes.rs
src/test/bench/shootout-k-nucleotide-pipes.rs
+5
-8
src/test/compile-fail/bad-method-typaram-kind.rs
src/test/compile-fail/bad-method-typaram-kind.rs
+3
-3
src/test/compile-fail/closure-bounds-cant-promote-superkind-in-struct.rs
...e-fail/closure-bounds-cant-promote-superkind-in-struct.rs
+2
-2
src/test/compile-fail/closure-bounds-copy-cant-capture-noncopyable.rs
...pile-fail/closure-bounds-copy-cant-capture-noncopyable.rs
+0
-26
src/test/compile-fail/closure-bounds-subtype.rs
src/test/compile-fail/closure-bounds-subtype.rs
+1
-23
src/test/compile-fail/fn-variance-2.rs
src/test/compile-fail/fn-variance-2.rs
+1
-1
src/test/compile-fail/fn-variance-3.rs
src/test/compile-fail/fn-variance-3.rs
+1
-1
src/test/compile-fail/issue-2548.rs
src/test/compile-fail/issue-2548.rs
+1
-1
src/test/compile-fail/issue-2611-4.rs
src/test/compile-fail/issue-2611-4.rs
+2
-2
src/test/compile-fail/issue-2611-5.rs
src/test/compile-fail/issue-2611-5.rs
+2
-2
src/test/compile-fail/kindck-owned-trait-contains.rs
src/test/compile-fail/kindck-owned-trait-contains.rs
+2
-2
src/test/compile-fail/kindck-owned-trait-scoped.rs
src/test/compile-fail/kindck-owned-trait-scoped.rs
+4
-4
src/test/compile-fail/kindck-owned-trait.rs
src/test/compile-fail/kindck-owned-trait.rs
+2
-2
src/test/compile-fail/trait-bounds-cant-coerce.rs
src/test/compile-fail/trait-bounds-cant-coerce.rs
+2
-2
src/test/run-pass/auto-instantiate.rs
src/test/run-pass/auto-instantiate.rs
+1
-1
src/test/run-pass/autobind.rs
src/test/run-pass/autobind.rs
+1
-1
src/test/run-pass/cond-macro-no-default.rs
src/test/run-pass/cond-macro-no-default.rs
+1
-1
src/test/run-pass/cond-macro.rs
src/test/run-pass/cond-macro.rs
+1
-1
src/test/run-pass/const-bound.rs
src/test/run-pass/const-bound.rs
+1
-1
src/test/run-pass/expr-block-generic-unique1.rs
src/test/run-pass/expr-block-generic-unique1.rs
+1
-1
src/test/run-pass/expr-fn.rs
src/test/run-pass/expr-fn.rs
+1
-1
src/test/run-pass/expr-match-generic-unique1.rs
src/test/run-pass/expr-match-generic-unique1.rs
+1
-1
src/test/run-pass/expr-match-generic-unique2.rs
src/test/run-pass/expr-match-generic-unique2.rs
+1
-1
src/test/run-pass/generic-alias-box.rs
src/test/run-pass/generic-alias-box.rs
+1
-1
src/test/run-pass/generic-alias-unique.rs
src/test/run-pass/generic-alias-unique.rs
+1
-1
src/test/run-pass/generic-box.rs
src/test/run-pass/generic-box.rs
+1
-1
src/test/run-pass/generic-drop-glue.rs
src/test/run-pass/generic-drop-glue.rs
+1
-1
src/test/run-pass/generic-exterior-box.rs
src/test/run-pass/generic-exterior-box.rs
+1
-1
src/test/run-pass/generic-exterior-unique.rs
src/test/run-pass/generic-exterior-unique.rs
+1
-1
src/test/run-pass/generic-fn-infer.rs
src/test/run-pass/generic-fn-infer.rs
+1
-1
src/test/run-pass/generic-fn-unique.rs
src/test/run-pass/generic-fn-unique.rs
+1
-1
src/test/run-pass/generic-fn.rs
src/test/run-pass/generic-fn.rs
+1
-1
src/test/run-pass/generic-tup.rs
src/test/run-pass/generic-tup.rs
+1
-1
src/test/run-pass/generic-unique.rs
src/test/run-pass/generic-unique.rs
+1
-1
src/test/run-pass/issue-2288.rs
src/test/run-pass/issue-2288.rs
+4
-4
src/test/run-pass/issue-2311-2.rs
src/test/run-pass/issue-2311-2.rs
+3
-3
src/test/run-pass/issue-2445-b.rs
src/test/run-pass/issue-2445-b.rs
+3
-3
src/test/run-pass/issue-2445.rs
src/test/run-pass/issue-2445.rs
+3
-3
src/test/run-pass/issue-2550.rs
src/test/run-pass/issue-2550.rs
+1
-1
src/test/run-pass/issue-2611-3.rs
src/test/run-pass/issue-2611-3.rs
+2
-2
src/test/run-pass/issue-3149.rs
src/test/run-pass/issue-3149.rs
+5
-6
src/test/run-pass/issue-333.rs
src/test/run-pass/issue-333.rs
+2
-2
src/test/run-pass/ivec-add.rs
src/test/run-pass/ivec-add.rs
+1
-1
src/test/run-pass/monad.rs
src/test/run-pass/monad.rs
+2
-2
src/test/run-pass/monomorphized-callees-with-ty-params-3314.rs
...est/run-pass/monomorphized-callees-with-ty-params-3314.rs
+1
-1
src/test/run-pass/non-boolean-pure-fns.rs
src/test/run-pass/non-boolean-pure-fns.rs
+4
-4
src/test/run-pass/ret-break-cont-in-block.rs
src/test/run-pass/ret-break-cont-in-block.rs
+1
-1
src/test/run-pass/ret-none.rs
src/test/run-pass/ret-none.rs
+1
-1
src/test/run-pass/static-impl.rs
src/test/run-pass/static-impl.rs
+2
-2
src/test/run-pass/tag-align-dyn-variants.rs
src/test/run-pass/tag-align-dyn-variants.rs
+1
-1
src/test/run-pass/trait-bounds-basic.rs
src/test/run-pass/trait-bounds-basic.rs
+1
-1
src/test/run-pass/trait-generic.rs
src/test/run-pass/trait-generic.rs
+2
-2
src/test/run-pass/trait-inheritance-overloading-xc-exe.rs
src/test/run-pass/trait-inheritance-overloading-xc-exe.rs
+1
-1
src/test/run-pass/trait-inheritance-overloading.rs
src/test/run-pass/trait-inheritance-overloading.rs
+1
-1
src/test/run-pass/type-param-constraints.rs
src/test/run-pass/type-param-constraints.rs
+1
-1
src/test/run-pass/uniq-cc-generic.rs
src/test/run-pass/uniq-cc-generic.rs
+1
-1
src/test/run-pass/unique-assign-generic.rs
src/test/run-pass/unique-assign-generic.rs
+1
-1
src/test/run-pass/unique-generic-assign.rs
src/test/run-pass/unique-generic-assign.rs
+1
-1
src/test/run-pass/unique-kinds.rs
src/test/run-pass/unique-kinds.rs
+2
-2
src/test/run-pass/vec-matching-fold.rs
src/test/run-pass/vec-matching-fold.rs
+8
-10
未找到文件。
src/libextra/par.rs
浏览文件 @
e20549ff
...
...
@@ -85,7 +85,7 @@ fn map_slices<A:Clone + Send,B:Clone + Send>(
}
/// A parallel version of map.
pub
fn
map
<
A
:
C
opy
+
Clone
+
Send
,
B
:
Copy
+
Clone
+
Send
>
(
pub
fn
map
<
A
:
C
lone
+
Send
,
B
:
Clone
+
Send
>
(
xs
:
&
[
A
],
fn_factory
:
&
fn
()
->
~
fn
(
&
A
)
->
B
)
->
~
[
B
]
{
vec
::
concat
(
map_slices
(
xs
,
||
{
let
f
=
fn_factory
();
...
...
@@ -96,7 +96,7 @@ pub fn map<A:Copy + Clone + Send,B:Copy + Clone + Send>(
}
/// A parallel version of mapi.
pub
fn
mapi
<
A
:
C
opy
+
Clone
+
Send
,
B
:
Copy
+
Clone
+
Send
>
(
pub
fn
mapi
<
A
:
C
lone
+
Send
,
B
:
Clone
+
Send
>
(
xs
:
&
[
A
],
fn_factory
:
&
fn
()
->
~
fn
(
uint
,
&
A
)
->
B
)
->
~
[
B
]
{
let
slices
=
map_slices
(
xs
,
||
{
...
...
src/libextra/serialize.rs
浏览文件 @
e20549ff
...
...
@@ -650,10 +650,7 @@ fn decode(d: &mut D) -> (T0, T1, T2, T3, T4) {
}
}
impl
<
S
:
Encoder
,
T
:
Encodable
<
S
>
+
Copy
>
Encodable
<
S
>
for
DList
<
T
>
{
impl
<
S
:
Encoder
,
T
:
Encodable
<
S
>>
Encodable
<
S
>
for
@
mut
DList
<
T
>
{
fn
encode
(
&
self
,
s
:
&
mut
S
)
{
do
s
.emit_seq
(
self
.len
())
|
s
|
{
let
mut
i
=
0
;
...
...
src/libextra/sort.rs
浏览文件 @
e20549ff
...
...
@@ -24,12 +24,12 @@
* Has worst case O(n log n) performance, best case O(n), but
* is not space efficient. This is a stable sort.
*/
pub
fn
merge_sort
<
T
:
C
opy
+
C
lone
>
(
v
:
&
[
T
],
le
:
Le
<
T
>
)
->
~
[
T
]
{
pub
fn
merge_sort
<
T
:
Clone
>
(
v
:
&
[
T
],
le
:
Le
<
T
>
)
->
~
[
T
]
{
type
Slice
=
(
uint
,
uint
);
return
merge_sort_
(
v
,
(
0u
,
v
.len
()),
le
);
fn
merge_sort_
<
T
:
C
opy
+
C
lone
>
(
v
:
&
[
T
],
slice
:
Slice
,
le
:
Le
<
T
>
)
->
~
[
T
]
{
fn
merge_sort_
<
T
:
Clone
>
(
v
:
&
[
T
],
slice
:
Slice
,
le
:
Le
<
T
>
)
->
~
[
T
]
{
let
begin
=
slice
.first
();
let
end
=
slice
.second
();
...
...
@@ -44,7 +44,7 @@ fn merge_sort_<T:Copy + Clone>(v: &[T], slice: Slice, le: Le<T>) -> ~[T] {
merge_sort_
(
v
,
b
,
|
x
,
y
|
le
(
x
,
y
)));
}
fn
merge
<
T
:
C
opy
+
C
lone
>
(
le
:
Le
<
T
>
,
a
:
&
[
T
],
b
:
&
[
T
])
->
~
[
T
]
{
fn
merge
<
T
:
Clone
>
(
le
:
Le
<
T
>
,
a
:
&
[
T
],
b
:
&
[
T
])
->
~
[
T
]
{
let
mut
rs
=
vec
::
with_capacity
(
a
.len
()
+
b
.len
());
let
a_len
=
a
.len
();
let
mut
a_ix
=
0
;
...
...
@@ -183,7 +183,7 @@ impl<'self, T:Clone + Ord + Eq> Sort for &'self mut [T] {
static
INITIAL_TMP_STORAGE
:
uint
=
128
;
#[allow(missing_doc)]
pub
fn
tim_sort
<
T
:
C
opy
+
C
lone
+
Ord
>
(
array
:
&
mut
[
T
])
{
pub
fn
tim_sort
<
T
:
Clone
+
Ord
>
(
array
:
&
mut
[
T
])
{
let
size
=
array
.len
();
if
size
<
2
{
return
;
...
...
@@ -227,7 +227,7 @@ pub fn tim_sort<T:Copy + Clone + Ord>(array: &mut [T]) {
ms
.merge_force_collapse
(
array
);
}
fn
binarysort
<
T
:
C
opy
+
C
lone
+
Ord
>
(
array
:
&
mut
[
T
],
start
:
uint
)
{
fn
binarysort
<
T
:
Clone
+
Ord
>
(
array
:
&
mut
[
T
],
start
:
uint
)
{
let
size
=
array
.len
();
let
mut
start
=
start
;
assert
!
(
start
<=
size
);
...
...
@@ -419,7 +419,7 @@ fn MergeState<T>() -> MergeState<T> {
}
}
impl
<
T
:
C
opy
+
C
lone
+
Ord
>
MergeState
<
T
>
{
impl
<
T
:
Clone
+
Ord
>
MergeState
<
T
>
{
fn
push_run
(
&
mut
self
,
run_base
:
uint
,
run_len
:
uint
)
{
let
tmp
=
RunState
{
base
:
run_base
,
len
:
run_len
};
self
.runs
.push
(
tmp
);
...
...
@@ -739,10 +739,7 @@ fn copy_vec<T:Clone>(dest: &mut [T],
}
#[inline]
fn
shift_vec
<
T
:
Copy
+
Clone
>
(
dest
:
&
mut
[
T
],
s1
:
uint
,
s2
:
uint
,
len
:
uint
)
{
fn
shift_vec
<
T
:
Clone
>
(
dest
:
&
mut
[
T
],
s1
:
uint
,
s2
:
uint
,
len
:
uint
)
{
assert
!
(
s1
+
len
<=
dest
.len
());
let
tmp
=
dest
.slice
(
s2
,
s2
+
len
)
.to_owned
();
...
...
src/libextra/timer.rs
浏览文件 @
e20549ff
...
...
@@ -118,10 +118,8 @@ pub fn sleep(iotask: &IoTask, msecs: uint) {
* on the provided port in the allotted timeout period, then the result will
* be a `Some(T)`. If not, then `None` will be returned.
*/
pub
fn
recv_timeout
<
T
:
Copy
+
Send
>
(
iotask
:
&
IoTask
,
msecs
:
uint
,
wait_po
:
&
Port
<
T
>
)
->
Option
<
T
>
{
pub
fn
recv_timeout
<
T
:
Send
>
(
iotask
:
&
IoTask
,
msecs
:
uint
,
wait_po
:
&
Port
<
T
>
)
->
Option
<
T
>
{
let
(
timeout_po
,
timeout_ch
)
=
stream
::
<
()
>
();
let
mut
timeout_po
=
timeout_po
;
delayed_send
(
iotask
,
msecs
,
&
timeout_ch
,
());
...
...
src/librust/rust.rs
浏览文件 @
e20549ff
...
...
@@ -43,19 +43,19 @@ fn is_valid(&self) -> bool {
}
}
enum
Action
<
'self
>
{
Call
(
&
'self
fn
:
Copy
(
args
:
&
[
~
str
])
->
ValidUsage
),
CallMain
(
&
'static
str
,
&
'self
fn
:
Copy
()),
enum
Action
{
Call
(
extern
"Rust"
fn
(
args
:
&
[
~
str
])
->
ValidUsage
),
CallMain
(
&
'static
str
,
extern
"Rust"
fn
()),
}
enum
UsageSource
<
'self
>
{
UsgStr
(
&
'self
str
),
UsgCall
(
&
'self
fn
:
Copy
()),
UsgCall
(
extern
"Rust"
fn
()),
}
struct
Command
<
'self
>
{
cmd
:
&
'self
str
,
action
:
Action
<
'self
>
,
action
:
Action
,
usage_line
:
&
'self
str
,
usage_full
:
UsageSource
<
'self
>
,
}
...
...
src/librustc/driver/driver.rs
浏览文件 @
e20549ff
...
...
@@ -199,8 +199,9 @@ pub fn compile_rest(sess: Session,
//
// baz! should not use this definition unless foo is enabled.
crate
=
time
(
time_passes
,
~
"std macros injection"
,
||
syntax
::
ext
::
expand
::
inject_std_macros
(
sess
.parse_sess
,
copy
cfg
,
crate
));
syntax
::
ext
::
expand
::
inject_std_macros
(
sess
.parse_sess
,
cfg
.clone
(),
crate
));
crate
=
time
(
time_passes
,
~
"configuration 1"
,
||
front
::
config
::
strip_unconfigured_items
(
crate
));
...
...
src/librustc/front/std_inject.rs
浏览文件 @
e20549ff
...
...
@@ -37,7 +37,7 @@ fn no_prelude(attrs: &[ast::attribute]) -> bool {
}
fn
inject_libstd_ref
(
sess
:
Session
,
crate
:
&
ast
::
crate
)
->
@
ast
::
crate
{
fn
spanned
<
T
:
Copy
>
(
x
:
T
)
->
codemap
::
spanned
<
T
>
{
fn
spanned
<
T
>
(
x
:
T
)
->
codemap
::
spanned
<
T
>
{
codemap
::
spanned
{
node
:
x
,
span
:
dummy_sp
()
}
}
...
...
src/librustc/front/test.rs
浏览文件 @
e20549ff
...
...
@@ -343,7 +343,7 @@ pub fn main() {
return
@
item
;
}
fn
nospan
<
T
:
Copy
>
(
t
:
T
)
->
codemap
::
spanned
<
T
>
{
fn
nospan
<
T
>
(
t
:
T
)
->
codemap
::
spanned
<
T
>
{
codemap
::
spanned
{
node
:
t
,
span
:
dummy_sp
()
}
}
...
...
src/librustc/metadata/filesearch.rs
浏览文件 @
e20549ff
...
...
@@ -87,7 +87,7 @@ fn get_target_lib_file_path(&self, file: &Path) -> Path {
}
as
@
FileSearch
}
pub
fn
search
<
T
:
Copy
>
(
filesearch
:
@
FileSearch
,
pick
:
pick
<
T
>
)
->
Option
<
T
>
{
pub
fn
search
<
T
>
(
filesearch
:
@
FileSearch
,
pick
:
pick
<
T
>
)
->
Option
<
T
>
{
let
mut
rslt
=
None
;
for
filesearch
.for_each_lib_search_path
()
|
lib_search_path
|
{
debug!
(
"searching %s"
,
lib_search_path
.to_str
());
...
...
src/librustc/middle/astencode.rs
浏览文件 @
e20549ff
...
...
@@ -1282,14 +1282,14 @@ fn foo(x: uint, y: uint) -> uint {
fn
test_simplification
()
{
let
ext_cx
=
mk_ctxt
();
let
item_in
=
ast
::
ii_item
(
quote_item!
(
fn
new_int_alist
<
B
:
Copy
>
()
->
alist
<
int
,
B
>
{
fn
new_int_alist
<
B
>
()
->
alist
<
int
,
B
>
{
fn
eq_int
(
a
:
int
,
b
:
int
)
->
bool
{
a
==
b
}
return
alist
{
eq_fn
:
eq_int
,
data
:
~
[]};
}
)
.get
());
let
item_out
=
simplify_ast
(
&
item_in
);
let
item_exp
=
ast
::
ii_item
(
quote_item!
(
fn
new_int_alist
<
B
:
Copy
>
()
->
alist
<
int
,
B
>
{
fn
new_int_alist
<
B
>
()
->
alist
<
int
,
B
>
{
return
alist
{
eq_fn
:
eq_int
,
data
:
~
[]};
}
)
.get
());
...
...
src/librustc/middle/lint.rs
浏览文件 @
e20549ff
...
...
@@ -561,7 +561,7 @@ pub fn each_lint(sess: session::Session,
// This is used to make the simple visitors used for the lint passes
// not traverse into subitems, since that is handled by the outer
// lint visitor.
fn
item_stopping_visitor
<
E
:
Copy
>
(
outer
:
visit
::
vt
<
E
>
)
->
visit
::
vt
<
E
>
{
fn
item_stopping_visitor
<
E
>
(
outer
:
visit
::
vt
<
E
>
)
->
visit
::
vt
<
E
>
{
visit
::
mk_vt
(
@
visit
::
Visitor
{
visit_item
:
|
_
i
,
(
_
e
,
_
v
)|
{
},
visit_fn
:
|
fk
,
fd
,
b
,
s
,
id
,
(
e
,
v
)|
{
...
...
src/librustc/middle/trans/type_use.rs
浏览文件 @
e20549ff
...
...
@@ -62,7 +62,7 @@ pub fn type_uses_for(ccx: @mut CrateContext, fn_id: def_id, n_tps: uint)
fn
store_type_uses
(
cx
:
Context
,
fn_id
:
def_id
)
->
@~
[
type_uses
]
{
let
Context
{
uses
,
ccx
}
=
cx
;
let
uses
=
@
copy
*
uses
;
// freeze
let
uses
=
@
(
*
uses
)
.clone
()
;
// freeze
ccx
.type_use_cache
.insert
(
fn_id
,
uses
);
uses
}
...
...
src/librustc/middle/ty.rs
浏览文件 @
e20549ff
...
...
@@ -860,7 +860,7 @@ fn mk_rcache() -> creader_cache {
return
@
mut
HashMap
::
new
();
}
pub
fn
new_ty_hash
<
V
:
Copy
>
()
->
@
mut
HashMap
<
t
,
V
>
{
pub
fn
new_ty_hash
<
V
>
()
->
@
mut
HashMap
<
t
,
V
>
{
@
mut
HashMap
::
new
()
}
...
...
src/librustc/middle/typeck/check/mod.rs
浏览文件 @
e20549ff
...
...
@@ -1686,10 +1686,10 @@ fn check_user_unop(fcx: @mut FnCtxt,
// through the `unpack` function. It there is no expected type or
// resolution is not possible (e.g., no constraints yet present), just
// returns `none`.
fn
unpack_expected
<
O
:
Copy
>
(
fcx
:
@
mut
FnCtxt
,
expected
:
Option
<
ty
::
t
>
,
unpack
:
&
fn
(
&
ty
::
sty
)
->
Option
<
O
>
)
->
Option
<
O
>
{
fn
unpack_expected
<
O
>
(
fcx
:
@
mut
FnCtxt
,
expected
:
Option
<
ty
::
t
>
,
unpack
:
&
fn
(
&
ty
::
sty
)
->
Option
<
O
>
)
->
Option
<
O
>
{
match
expected
{
Some
(
t
)
=>
{
match
resolve_type
(
fcx
.infcx
(),
t
,
force_tvar
)
{
...
...
src/librustdoc/astsrv.rs
浏览文件 @
e20549ff
...
...
@@ -114,7 +114,8 @@ fn build_ctxt(sess: Session,
use
rustc
::
front
::
config
;
let
ast
=
syntax
::
ext
::
expand
::
inject_std_macros
(
sess
.parse_sess
,
copy
sess
.opts.cfg
,
ast
);
sess
.opts.cfg
.clone
(),
ast
);
let
ast
=
config
::
strip_unconfigured_items
(
ast
);
let
ast
=
syntax
::
ext
::
expand
::
expand_crate
(
sess
.parse_sess
,
sess
.opts.cfg
.clone
(),
...
...
src/librustdoc/markdown_index_pass.rs
浏览文件 @
e20549ff
...
...
@@ -208,8 +208,8 @@ fn should_remove_punctuation_from_headers() {
==
~
"impl-of-selectt-u-for-left-right"
);
assert
!
(
pandoc_header_id
(
"impl of Condition<'self, T, U>"
)
==
~
"impl-of-conditionself-t-u"
);
assert
!
(
pandoc_header_id
(
"impl of Condition<T: C
opy + C
lone>"
)
==
~
"impl-of-conditiont-c
opy-c
lone"
);
assert
!
(
pandoc_header_id
(
"impl of Condition<T: Clone>"
)
==
~
"impl-of-conditiont-clone"
);
}
#[test]
...
...
src/librustdoc/tystr_pass.rs
浏览文件 @
e20549ff
...
...
@@ -394,8 +394,8 @@ fn should_add_trait_method_sigs() {
#[test]
fn
should_add_impl_bounds
()
{
let
doc
=
mk_doc
(
~
"impl<T, U
: Copy, V: Copy +
Clone> Option<T, U, V> { }"
);
assert
!
(
doc
.cratemod
()
.impls
()[
0
]
.bounds_str
==
Some
(
~
"<T, U
: Copy, V: Copy +
Clone>"
));
let
doc
=
mk_doc
(
~
"impl<T, U
, V:
Clone> Option<T, U, V> { }"
);
assert
!
(
doc
.cratemod
()
.impls
()[
0
]
.bounds_str
==
Some
(
~
"<T, U
, V:
Clone>"
));
}
#[test]
...
...
src/librustpkg/tests.rs
浏览文件 @
e20549ff
...
...
@@ -839,7 +839,7 @@ fn install_check_duplicates() {
fail
!
(
"package database contains duplicate ID"
);
}
else
{
contents
.push
(
copy
*
p
);
contents
.push
(
(
*
p
)
.clone
()
);
}
false
};
...
...
src/libstd/clone.rs
浏览文件 @
e20549ff
...
...
@@ -15,10 +15,9 @@
leaving the original value in place. These types do not require
allocation to copy and do not have finalizers (i.e. they do not
contain owned boxes or implement `Drop`), so the compiler considers
them cheap and safe to copy and automatically implements the `Copy`
trait for them. For other types copies must be made explicitly,
by convention implementing the `Clone` trait and calling the
`clone` method.
them cheap and safe to copy. For other types copies must be made
explicitly, by convention implementing the `Clone` trait and calling
the `clone` method.
*/
...
...
src/libstd/condition.rs
浏览文件 @
e20549ff
...
...
@@ -47,7 +47,7 @@ pub fn trap<'a>(&'a self, h: &'a fn(T) -> U) -> Trap<'a, T, U> {
pub
fn
raise
(
&
self
,
t
:
T
)
->
U
{
let
msg
=
fmt!
(
"Unhandled condition: %s: %?"
,
self
.name
,
t
);
self
.raise_default
(
t
,
||
fail
!
(
copy
msg
))
self
.raise_default
(
t
,
||
fail
!
(
msg
.clone
()
))
}
pub
fn
raise_default
(
&
self
,
t
:
T
,
default
:
&
fn
()
->
U
)
->
U
{
...
...
@@ -78,7 +78,8 @@ impl<'self, T, U> Condition<'self, T, U> {
pub
fn
trap
<
'a
>
(
&
'a
self
,
h
:
&
'a
fn
(
T
)
->
U
)
->
Trap
<
'a
,
T
,
U
>
{
unsafe
{
let
p
:
*
RustClosure
=
::
cast
::
transmute
(
&
h
);
let
prev
=
local_data
::
get
(
self
.key
,
|
k
|
k
.map
(|
&
x
|
*
x
));
let
prev
=
local_data
::
get
(::
cast
::
unsafe_copy
(
&
self
.key
),
|
k
|
k
.map
(|
&
x
|
*
x
));
let
h
=
@
Handler
{
handle
:
*
p
,
prev
:
prev
};
Trap
{
cond
:
self
,
handler
:
h
}
}
...
...
@@ -91,7 +92,7 @@ pub fn raise(&self, t: T) -> U {
pub
fn
raise_default
(
&
self
,
t
:
T
,
default
:
&
fn
()
->
U
)
->
U
{
unsafe
{
match
local_data
::
pop
(
self
.key
)
{
match
local_data
::
pop
(
::
cast
::
unsafe_copy
(
&
self
.key
)
)
{
None
=>
{
debug!
(
"Condition.raise: found no handler"
);
default
()
...
...
@@ -100,12 +101,15 @@ pub fn raise_default(&self, t: T, default: &fn() -> U) -> U {
debug!
(
"Condition.raise: found handler"
);
match
handler
.prev
{
None
=>
{}
Some
(
hp
)
=>
local_data
::
set
(
self
.key
,
hp
)
Some
(
hp
)
=>
{
local_data
::
set
(::
cast
::
unsafe_copy
(
&
self
.key
),
hp
)
}
}
let
handle
:
&
fn
(
T
)
->
U
=
::
cast
::
transmute
(
handler
.handle
);
let
u
=
handle
(
t
);
local_data
::
set
(
self
.key
,
handler
);
local_data
::
set
(
::
cast
::
unsafe_copy
(
&
self
.key
)
,
handler
);
u
}
}
...
...
src/libstd/kinds.rs
浏览文件 @
e20549ff
...
...
@@ -18,22 +18,13 @@
They cannot be implemented by user code, but are instead implemented
by the compiler automatically for the types to which they apply.
The 3 kinds are
* Copy - types that may be copied without allocation. This includes
scalar types and managed pointers, and exludes owned pointers. It
also excludes types that implement `Drop`.
The 2 kinds are
* Send - owned types and types containing owned types. These types
may be transferred across task boundaries.
* Freeze - types that are deeply immutable.
`Copy` types include both implicitly copyable types that the compiler
will copy automatically and non-implicitly copyable types that require
the `copy` keyword to copy. Types that do not implement `Copy` may
instead implement `Clone`.
*/
#[allow(missing_doc)]
;
...
...
src/libstd/local_data.rs
浏览文件 @
e20549ff
...
...
@@ -59,7 +59,7 @@
#[cfg(not(stage0))]
pub
type
Key
<
T
>
=
&
'static
KeyValue
<
T
>
;
#[cfg(stage0)]
pub
type
Key
<
'self
,
T
>
=
&
'self
fn
:
Copy
(
v
:
T
);
pub
type
Key
<
'self
,
T
>
=
&
'self
fn
(
v
:
T
);
pub
enum
KeyValue
<
T
>
{
Key
}
...
...
src/libstd/num/num.rs
浏览文件 @
e20549ff
...
...
@@ -16,7 +16,6 @@
use
ops
::{
Add
,
Sub
,
Mul
,
Div
,
Rem
,
Neg
};
use
ops
::{
Not
,
BitAnd
,
BitOr
,
BitXor
,
Shl
,
Shr
};
use
option
::
Option
;
use
kinds
::
Copy
;
pub
mod
strconv
;
...
...
@@ -428,7 +427,7 @@ pub trait FromStrRadix {
/// - If code written to use this function doesn't care about it, it's
/// probably assuming that `x^0` always equals `1`.
///
pub
fn
pow_with_uint
<
T
:
NumCast
+
One
+
Zero
+
Copy
+
Div
<
T
,
T
>+
Mul
<
T
,
T
>>
(
radix
:
uint
,
pow
:
uint
)
->
T
{
pub
fn
pow_with_uint
<
T
:
NumCast
+
One
+
Zero
+
Div
<
T
,
T
>+
Mul
<
T
,
T
>>
(
radix
:
uint
,
pow
:
uint
)
->
T
{
let
_0
:
T
=
Zero
::
zero
();
let
_1
:
T
=
One
::
one
();
...
...
src/libstd/num/strconv.rs
浏览文件 @
e20549ff
...
...
@@ -16,9 +16,8 @@
use
ops
::{
Add
,
Sub
,
Mul
,
Div
,
Rem
,
Neg
};
use
option
::{
None
,
Option
,
Some
};
use
char
;
use
str
::{
StrSlice
};
use
str
;
use
str
::
StrSlice
;
use
kinds
::
Copy
;
use
vec
::{
CopyableVector
,
ImmutableVector
,
MutableVector
};
use
vec
::
OwnedVector
;
use
num
::{
NumCast
,
Zero
,
One
,
cast
,
pow_with_uint
,
Integer
};
...
...
@@ -466,7 +465,7 @@ pub fn float_to_str_common<T:NumCast+Zero+One+Eq+Ord+NumStrConv+Float+Round+
* - Fails if `radix` > 18 and `special == true` due to conflict
* between digit and lowest first character in `inf` and `NaN`, the `'i'`.
*/
pub
fn
from_str_bytes_common
<
T
:
NumCast
+
Zero
+
One
+
Eq
+
Ord
+
Copy
+
Div
<
T
,
T
>+
pub
fn
from_str_bytes_common
<
T
:
NumCast
+
Zero
+
One
+
Eq
+
Ord
+
Div
<
T
,
T
>+
Mul
<
T
,
T
>+
Sub
<
T
,
T
>+
Neg
<
T
>+
Add
<
T
,
T
>+
NumStrConv
+
Clone
>
(
buf
:
&
[
u8
],
radix
:
uint
,
negative
:
bool
,
fractional
:
bool
,
...
...
@@ -663,7 +662,7 @@ pub fn from_str_bytes_common<T:NumCast+Zero+One+Eq+Ord+Copy+Div<T,T>+
* `from_str_bytes_common()`, for details see there.
*/
#[inline]
pub
fn
from_str_common
<
T
:
NumCast
+
Zero
+
One
+
Eq
+
Ord
+
Copy
+
Div
<
T
,
T
>+
Mul
<
T
,
T
>+
pub
fn
from_str_common
<
T
:
NumCast
+
Zero
+
One
+
Eq
+
Ord
+
Div
<
T
,
T
>+
Mul
<
T
,
T
>+
Sub
<
T
,
T
>+
Neg
<
T
>+
Add
<
T
,
T
>+
NumStrConv
+
Clone
>
(
buf
:
&
str
,
radix
:
uint
,
negative
:
bool
,
fractional
:
bool
,
special
:
bool
,
exponent
:
ExponentFormat
,
empty_zero
:
bool
,
...
...
src/libstd/prelude.rs
浏览文件 @
e20549ff
...
...
@@ -29,7 +29,7 @@
// Reexported core operators
pub
use
either
::{
Either
,
Left
,
Right
};
pub
use
kinds
::
{
Copy
,
Sized
}
;
pub
use
kinds
::
Sized
;
pub
use
kinds
::{
Freeze
,
Send
};
pub
use
ops
::{
Add
,
Sub
,
Mul
,
Div
,
Rem
,
Neg
,
Not
};
pub
use
ops
::{
BitAnd
,
BitOr
,
BitXor
};
...
...
src/libstd/rand.rs
浏览文件 @
e20549ff
...
...
@@ -356,7 +356,7 @@ pub trait RngUtil {
* }
* ~~~
*/
fn
choose
<
T
:
C
opy
+
C
lone
>
(
&
mut
self
,
values
:
&
[
T
])
->
T
;
fn
choose
<
T
:
Clone
>
(
&
mut
self
,
values
:
&
[
T
])
->
T
;
/// Choose Some(item) randomly, returning None if values is empty
fn
choose_option
<
T
:
Clone
>
(
&
mut
self
,
values
:
&
[
T
])
->
Option
<
T
>
;
/**
...
...
@@ -379,7 +379,7 @@ pub trait RngUtil {
* }
* ~~~
*/
fn
choose_weighted
<
T
:
C
opy
+
C
lone
>
(
&
mut
self
,
v
:
&
[
Weighted
<
T
>
])
->
T
;
fn
choose_weighted
<
T
:
Clone
>
(
&
mut
self
,
v
:
&
[
Weighted
<
T
>
])
->
T
;
/**
* Choose Some(item) respecting the relative weights, returning none if
* the sum of the weights is 0
...
...
@@ -439,7 +439,7 @@ fn choose_weighted_option<T:Clone>(&mut self, v: &[Weighted<T>])
* }
* ~~~
*/
fn
shuffle
<
T
:
C
opy
+
C
lone
>
(
&
mut
self
,
values
:
&
[
T
])
->
~
[
T
];
fn
shuffle
<
T
:
Clone
>
(
&
mut
self
,
values
:
&
[
T
])
->
~
[
T
];
/**
* Shuffle a mutable vec in place
*
...
...
@@ -532,7 +532,7 @@ fn gen_bytes(&mut self, len: uint) -> ~[u8] {
}
/// Choose an item randomly, failing if values is empty
fn
choose
<
T
:
C
opy
+
C
lone
>
(
&
mut
self
,
values
:
&
[
T
])
->
T
{
fn
choose
<
T
:
Clone
>
(
&
mut
self
,
values
:
&
[
T
])
->
T
{
self
.choose_option
(
values
)
.get
()
}
...
...
@@ -548,7 +548,7 @@ fn choose_option<T:Clone>(&mut self, values: &[T]) -> Option<T> {
* Choose an item respecting the relative weights, failing if the sum of
* the weights is 0
*/
fn
choose_weighted
<
T
:
C
opy
+
C
lone
>
(
&
mut
self
,
v
:
&
[
Weighted
<
T
>
])
->
T
{
fn
choose_weighted
<
T
:
Clone
>
(
&
mut
self
,
v
:
&
[
Weighted
<
T
>
])
->
T
{
self
.choose_weighted_option
(
v
)
.get
()
}
...
...
@@ -591,7 +591,7 @@ fn weighted_vec<T:Clone>(&mut self, v: &[Weighted<T>]) -> ~[T] {
}
/// Shuffle a vec
fn
shuffle
<
T
:
C
opy
+
C
lone
>
(
&
mut
self
,
values
:
&
[
T
])
->
~
[
T
]
{
fn
shuffle
<
T
:
Clone
>
(
&
mut
self
,
values
:
&
[
T
])
->
~
[
T
]
{
let
mut
m
=
values
.to_owned
();
self
.shuffle_mut
(
m
);
m
...
...
src/libstd/task/local_data_priv.rs
浏览文件 @
e20549ff
...
...
@@ -15,6 +15,7 @@
use
local_data
;
use
prelude
::
*
;
use
ptr
;
use
sys
;
use
task
::
rt
;
use
util
;
...
...
@@ -156,8 +157,9 @@ unsafe fn newsched_map(local: *mut LocalStorage) -> &mut TaskLocalMap {
}
}
fn
key_to_key_value
<
T
:
'static
>
(
key
:
local_data
::
Key
<
T
>
)
->
*
libc
::
c_void
{
unsafe
{
cast
::
transmute
(
key
)
}
unsafe
fn
key_to_key_value
<
T
:
'static
>
(
key
:
local_data
::
Key
<
T
>
)
->
*
libc
::
c_void
{
let
pair
:
sys
::
Closure
=
cast
::
transmute_copy
(
&
key
);
return
pair
.code
as
*
libc
::
c_void
;
}
pub
unsafe
fn
local_pop
<
T
:
'static
>
(
handle
:
Handle
,
...
...
src/libstd/trie.rs
浏览文件 @
e20549ff
...
...
@@ -264,7 +264,8 @@ struct TrieNode<T> {
impl
<
T
>
TrieNode
<
T
>
{
#[inline]
fn
new
()
->
TrieNode
<
T
>
{
// FIXME: #5244: [Nothing, ..SIZE] should be possible without Copy
// FIXME: #5244: [Nothing, ..SIZE] should be possible without implicit
// copyability
TrieNode
{
count
:
0
,
children
:
[
Nothing
,
Nothing
,
Nothing
,
Nothing
,
Nothing
,
Nothing
,
Nothing
,
Nothing
,
...
...
src/libstd/tuple.rs
浏览文件 @
e20549ff
...
...
@@ -13,7 +13,6 @@
#[allow(missing_doc)]
;
use
clone
::
Clone
;
use
kinds
::
Copy
;
use
vec
;
use
vec
::
ImmutableVector
;
use
iterator
::
IteratorUtil
;
...
...
@@ -86,8 +85,8 @@ pub trait ExtendedTupleOps<A,B> {
}
impl
<
'self
,
A
:
C
opy
+
C
lone
,
B
:
C
opy
+
C
lone
>
A
:
Clone
,
B
:
Clone
>
ExtendedTupleOps
<
A
,
B
>
for
(
&
'self
[
A
],
&
'self
[
B
])
{
#[inline]
...
...
@@ -109,10 +108,7 @@ fn map<C>(&self, f: &fn(a: &A, b: &B) -> C) -> ~[C] {
}
}
impl
<
A
:
Copy
+
Clone
,
B
:
Copy
+
Clone
>
ExtendedTupleOps
<
A
,
B
>
for
(
~
[
A
],
~
[
B
])
{
impl
<
A
:
Clone
,
B
:
Clone
>
ExtendedTupleOps
<
A
,
B
>
for
(
~
[
A
],
~
[
B
])
{
#[inline]
fn
zip
(
&
self
)
->
~
[(
A
,
B
)]
{
match
*
self
{
...
...
src/libsyntax/ast_util.rs
浏览文件 @
e20549ff
...
...
@@ -16,11 +16,13 @@
use
parse
::
token
;
use
visit
;
use
std
::
cast
::
unsafe_copy
;
use
std
::
cast
;
use
std
::
hashmap
::
HashMap
;
use
std
::
int
;
use
std
::
local_data
;
use
std
::
num
;
use
std
::
option
;
use
std
::
local_data
;
pub
fn
path_name_i
(
idents
:
&
[
ident
])
->
~
str
{
// FIXME: Bad copies (#2543 -- same for everything else that says "bad")
...
...
src/libsyntax/ext/base.rs
浏览文件 @
e20549ff
...
...
@@ -414,7 +414,7 @@ pub enum MapChain<K,V> {
// get the map from an env frame
impl
<
K
:
Eq
+
Hash
+
IterBytes
,
V
:
Copy
>
MapChain
<
K
,
V
>
{
impl
<
K
:
Eq
+
Hash
+
IterBytes
,
V
>
MapChain
<
K
,
V
>
{
// Constructor. I don't think we need a zero-arg one.
fn
new
(
init
:
~
HashMap
<
K
,
@
V
>
)
->
@
mut
MapChain
<
K
,
V
>
{
...
...
src/libsyntax/ext/expand.rs
浏览文件 @
e20549ff
...
...
@@ -693,7 +693,7 @@ pub fn inject_std_macros(parse_sess: @mut parse::ParseSess,
cfg
:
ast
::
crate_cfg
,
c
:
&
crate
)
->
@
crate
{
let
sm
=
match
parse_item_from_source_str
(
@
"<std-macros>"
,
std_macros
(),
c
opy
cfg
,
c
fg
.clone
()
,
~
[],
parse_sess
)
{
Some
(
item
)
=>
item
,
...
...
@@ -708,7 +708,7 @@ pub fn inject_std_macros(parse_sess: @mut parse::ParseSess,
ast
::
_
mod
{
items
:
items
,
// FIXME #2543: Bad copy.
..
copy
*
modd
..
(
*
modd
)
.clone
()
}
},
..
*
default_ast_fold
()
...
...
src/libsyntax/parse/parser.rs
浏览文件 @
e20549ff
...
...
@@ -473,10 +473,10 @@ pub fn expect_gt(&self) {
// parse a sequence bracketed by '<' and '>', stopping
// before the '>'.
pub
fn
parse_seq_to_before_gt
<
T
:
Copy
>
(
&
self
,
sep
:
Option
<
token
::
Token
>
,
f
:
&
fn
(
&
Parser
)
->
T
)
->
OptVec
<
T
>
{
pub
fn
parse_seq_to_before_gt
<
T
>
(
&
self
,
sep
:
Option
<
token
::
Token
>
,
f
:
&
fn
(
&
Parser
)
->
T
)
->
OptVec
<
T
>
{
let
mut
first
=
true
;
let
mut
v
=
opt_vec
::
Empty
;
while
*
self
.token
!=
token
::
GT
...
...
@@ -493,10 +493,10 @@ pub fn parse_seq_to_before_gt<T: Copy>(&self,
return
v
;
}
pub
fn
parse_seq_to_gt
<
T
:
Copy
>
(
&
self
,
sep
:
Option
<
token
::
Token
>
,
f
:
&
fn
(
&
Parser
)
->
T
)
->
OptVec
<
T
>
{
pub
fn
parse_seq_to_gt
<
T
>
(
&
self
,
sep
:
Option
<
token
::
Token
>
,
f
:
&
fn
(
&
Parser
)
->
T
)
->
OptVec
<
T
>
{
let
v
=
self
.parse_seq_to_before_gt
(
sep
,
f
);
self
.expect_gt
();
return
v
;
...
...
@@ -505,11 +505,11 @@ pub fn parse_seq_to_gt<T: Copy>(&self,
// parse a sequence, including the closing delimiter. The function
// f must consume tokens until reaching the next separator or
// closing bracket.
pub
fn
parse_seq_to_end
<
T
:
Copy
>
(
&
self
,
ket
:
&
token
::
Token
,
sep
:
SeqSep
,
f
:
&
fn
(
&
Parser
)
->
T
)
->
~
[
T
]
{
pub
fn
parse_seq_to_end
<
T
>
(
&
self
,
ket
:
&
token
::
Token
,
sep
:
SeqSep
,
f
:
&
fn
(
&
Parser
)
->
T
)
->
~
[
T
]
{
let
val
=
self
.parse_seq_to_before_end
(
ket
,
sep
,
f
);
self
.bump
();
val
...
...
@@ -518,11 +518,11 @@ pub fn parse_seq_to_end<T: Copy>(&self,
// parse a sequence, not including the closing delimiter. The function
// f must consume tokens until reaching the next separator or
// closing bracket.
pub
fn
parse_seq_to_before_end
<
T
:
Copy
>
(
&
self
,
ket
:
&
token
::
Token
,
sep
:
SeqSep
,
f
:
&
fn
(
&
Parser
)
->
T
)
->
~
[
T
]
{
pub
fn
parse_seq_to_before_end
<
T
>
(
&
self
,
ket
:
&
token
::
Token
,
sep
:
SeqSep
,
f
:
&
fn
(
&
Parser
)
->
T
)
->
~
[
T
]
{
let
mut
first
:
bool
=
true
;
let
mut
v
:
~
[
T
]
=
~
[];
while
*
self
.token
!=
*
ket
{
...
...
@@ -542,12 +542,12 @@ pub fn parse_seq_to_before_end<T: Copy>(&self,
// parse a sequence, including the closing delimiter. The function
// f must consume tokens until reaching the next separator or
// closing bracket.
pub
fn
parse_unspanned_seq
<
T
:
Copy
>
(
&
self
,
bra
:
&
token
::
Token
,
ket
:
&
token
::
Token
,
sep
:
SeqSep
,
f
:
&
fn
(
&
Parser
)
->
T
)
->
~
[
T
]
{
pub
fn
parse_unspanned_seq
<
T
>
(
&
self
,
bra
:
&
token
::
Token
,
ket
:
&
token
::
Token
,
sep
:
SeqSep
,
f
:
&
fn
(
&
Parser
)
->
T
)
->
~
[
T
]
{
self
.expect
(
bra
);
let
result
=
self
.parse_seq_to_before_end
(
ket
,
sep
,
f
);
self
.bump
();
...
...
@@ -556,12 +556,12 @@ pub fn parse_unspanned_seq<T: Copy>(&self,
// NB: Do not use this function unless you actually plan to place the
// spanned list in the AST.
pub
fn
parse_seq
<
T
:
Copy
>
(
&
self
,
bra
:
&
token
::
Token
,
ket
:
&
token
::
Token
,
sep
:
SeqSep
,
f
:
&
fn
(
&
Parser
)
->
T
)
->
spanned
<~
[
T
]
>
{
pub
fn
parse_seq
<
T
>
(
&
self
,
bra
:
&
token
::
Token
,
ket
:
&
token
::
Token
,
sep
:
SeqSep
,
f
:
&
fn
(
&
Parser
)
->
T
)
->
spanned
<~
[
T
]
>
{
let
lo
=
self
.span.lo
;
self
.expect
(
bra
);
let
result
=
self
.parse_seq_to_before_end
(
ket
,
sep
,
f
);
...
...
src/test/auxiliary/static-methods-crate.rs
浏览文件 @
e20549ff
...
...
@@ -35,7 +35,7 @@ fn readMaybe(s: ~str) -> Option<bool> {
}
}
pub
fn
read
<
T
:
read
+
Copy
>
(
s
:
~
str
)
->
T
{
pub
fn
read
<
T
:
read
>
(
s
:
~
str
)
->
T
{
match
read
::
readMaybe
(
s
)
{
Some
(
x
)
=>
x
,
_
=>
fail
!
(
"read failed!"
)
...
...
src/test/bench/shootout-k-nucleotide-pipes.rs
浏览文件 @
e20549ff
...
...
@@ -34,8 +34,8 @@ fn pct(xx: uint, yy: uint) -> float {
return
(
xx
as
float
)
*
100
f
/
(
yy
as
float
);
}
fn
le_by_val
<
TT
:
C
opy
+
C
lone
,
UU
:
C
opy
+
C
lone
+
Ord
>
(
fn
le_by_val
<
TT
:
Clone
,
UU
:
Clone
+
Ord
>
(
kv0
:
&
(
TT
,
UU
),
kv1
:
&
(
TT
,
UU
))
->
bool
{
...
...
@@ -44,8 +44,8 @@ fn le_by_val<TT:Copy + Clone,
return
v0
>=
v1
;
}
fn
le_by_key
<
TT
:
C
opy
+
C
lone
+
Ord
,
UU
:
C
opy
+
C
lone
>
(
fn
le_by_key
<
TT
:
Clone
+
Ord
,
UU
:
Clone
>
(
kv0
:
&
(
TT
,
UU
),
kv1
:
&
(
TT
,
UU
))
->
bool
{
...
...
@@ -55,10 +55,7 @@ fn le_by_key<TT:Copy + Clone + Ord,
}
// sort by key, then by value
fn
sortKV
<
TT
:
Copy
+
Clone
+
Ord
,
UU
:
Copy
+
Clone
+
Ord
>
(
orig
:
~
[(
TT
,
UU
)])
->
~
[(
TT
,
UU
)]
{
fn
sortKV
<
TT
:
Clone
+
Ord
,
UU
:
Clone
+
Ord
>
(
orig
:
~
[(
TT
,
UU
)])
->
~
[(
TT
,
UU
)]
{
return
sort
::
merge_sort
(
sort
::
merge_sort
(
orig
,
le_by_key
),
le_by_val
);
}
...
...
src/test/compile-fail/bad-method-typaram-kind.rs
浏览文件 @
e20549ff
...
...
@@ -9,15 +9,15 @@
// except according to those terms.
fn
foo
<
T
>
()
{
1u
.bar
::
<
T
>
();
//~ ERROR: does not fulfill `
Copy
`
1u
.bar
::
<
T
>
();
//~ ERROR: does not fulfill `
Send
`
}
trait
bar
{
fn
bar
<
T
:
Copy
>
(
&
self
);
fn
bar
<
T
:
Send
>
(
&
self
);
}
impl
bar
for
uint
{
fn
bar
<
T
:
Copy
>
(
&
self
)
{
fn
bar
<
T
:
Send
>
(
&
self
)
{
}
}
...
...
src/test/compile-fail/closure-bounds-cant-promote-superkind-in-struct.rs
浏览文件 @
e20549ff
...
...
@@ -9,11 +9,11 @@
// except according to those terms.
struct
X
{
field
:
@
fn
:
Copy
(),
field
:
@
fn
:
Send
(),
}
fn
foo
(
blk
:
@
fn
:())
->
X
{
return
X
{
field
:
blk
};
//~ ERROR expected bounds `
Copy
` but found no bounds
return
X
{
field
:
blk
};
//~ ERROR expected bounds `
Send
` but found no bounds
}
fn
main
()
{
...
...
src/test/compile-fail/closure-bounds-copy-cant-capture-noncopyable.rs
已删除
100644 → 0
浏览文件 @
99d44d24
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use
std
::
comm
;
// If this were legal you could use it to copy captured noncopyables.
// Issue (#2828)
fn
foo
(
blk
:
~
fn
:
Copy
())
{
blk
();
}
fn
main
()
{
let
(
p
,
c
)
=
comm
::
stream
();
do
foo
{
c
.send
(());
//~ ERROR does not fulfill `Copy`
}
p
.recv
();
}
src/test/compile-fail/closure-bounds-subtype.rs
浏览文件 @
e20549ff
...
...
@@ -2,38 +2,16 @@
fn
take_any
(
_
:
&
fn
:())
{
}
fn
take_copyable
(
_
:
&
fn
:
Copy
())
{
}
fn
take_copyable_owned
(
_
:
&
fn
:
Copy
+
Send
())
{
}
fn
take_const_owned
(
_
:
&
fn
:
Freeze
+
Send
())
{
}
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+Send` but found no bounds
}
fn
give_copyable
(
f
:
&
fn
:
Copy
())
{
take_any
(
f
);
take_copyable
(
f
);
take_copyable_owned
(
f
);
//~ ERROR expected bounds `Copy+Send` but found bounds `Copy`
}
fn
give_owned
(
f
:
&
fn
:
Send
())
{
take_any
(
f
);
take_copyable
(
f
);
//~ ERROR expected bounds `Copy` but found bounds `Send`
take_copyable_owned
(
f
);
//~ ERROR expected bounds `Copy+Send` but found bounds `Send`
}
fn
give_copyable_owned
(
f
:
&
fn
:
Copy
+
Send
())
{
take_any
(
f
);
take_copyable
(
f
);
take_copyable_owned
(
f
);
take_const_owned
(
f
);
//~ ERROR expected bounds `Send+Freeze` but found bounds `Copy+Send`
take_const_owned
(
f
);
//~ ERROR expected bounds `Freeze+Send` but found bounds `Send`
}
fn
main
()
{}
src/test/compile-fail/fn-variance-2.rs
浏览文件 @
e20549ff
...
...
@@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
fn
reproduce
<
T
:
Copy
>
(
t
:
T
)
->
@
fn
()
->
T
{
fn
reproduce
<
T
>
(
t
:
T
)
->
@
fn
()
->
T
{
let
result
:
@
fn
()
->
T
=
||
t
;
result
}
...
...
src/test/compile-fail/fn-variance-3.rs
浏览文件 @
e20549ff
...
...
@@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
fn
mk_identity
<
T
:
Copy
>
()
->
@
fn
(
T
)
->
T
{
fn
mk_identity
<
T
>
()
->
@
fn
(
T
)
->
T
{
let
result
:
@
fn
(
t
:
T
)
->
T
=
|
t
|
t
;
result
}
...
...
src/test/compile-fail/issue-2548.rs
浏览文件 @
e20549ff
...
...
@@ -37,7 +37,7 @@ fn main() {
let
mut
res
=
foo
(
x
);
let
mut
v
=
~
[];
v
=
~
[(
res
)]
+
v
;
//~ instantiating a type parameter with an incompatible type `foo`, which does not fulfill `C
opy
`
v
=
~
[(
res
)]
+
v
;
//~ instantiating a type parameter with an incompatible type `foo`, which does not fulfill `C
lone
`
assert_eq!
(
v
.len
(),
2
);
}
...
...
src/test/compile-fail/issue-2611-4.rs
浏览文件 @
e20549ff
...
...
@@ -12,7 +12,7 @@
// than the trait method it's implementing
trait
A
{
fn
b
<
C
:
Copy
,
D
>
(
x
:
C
)
->
C
;
fn
b
<
C
,
D
>
(
x
:
C
)
->
C
;
}
struct
E
{
...
...
@@ -20,7 +20,7 @@ struct E {
}
impl
A
for
E
{
fn
b
<
F
:
Copy
+
Freeze
,
G
>
(
_
x
:
F
)
->
F
{
fail
!
()
}
//~ ERROR type parameter 0 requires `Freeze`
fn
b
<
F
:
Freeze
,
G
>
(
_
x
:
F
)
->
F
{
fail
!
()
}
//~ ERROR type parameter 0 requires `Freeze`
}
fn
main
()
{}
src/test/compile-fail/issue-2611-5.rs
浏览文件 @
e20549ff
...
...
@@ -12,7 +12,7 @@
// an impl against a trait
trait
A
{
fn
b
<
C
:
C
opy
,
D
>
(
&
self
,
x
:
C
)
->
C
;
fn
b
<
C
:
C
lone
,
D
>
(
&
self
,
x
:
C
)
->
C
;
}
struct
E
{
...
...
@@ -21,7 +21,7 @@ struct E {
impl
A
for
E
{
// n.b. The error message is awful -- see #3404
fn
b
<
F
:
C
opy
,
G
>
(
&
self
,
_
x
:
G
)
->
G
{
fail
!
()
}
//~ ERROR method `b` has an incompatible type
fn
b
<
F
:
C
lone
,
G
>
(
&
self
,
_
x
:
G
)
->
G
{
fail
!
()
}
//~ ERROR method `b` has an incompatible type
}
fn
main
()
{}
src/test/compile-fail/kindck-owned-trait-contains.rs
浏览文件 @
e20549ff
...
...
@@ -10,11 +10,11 @@
trait
repeat
<
A
>
{
fn
get
(
&
self
)
->
A
;
}
impl
<
A
:
C
opy
>
repeat
<
A
>
for
@
A
{
impl
<
A
:
C
lone
>
repeat
<
A
>
for
@
A
{
fn
get
(
&
self
)
->
A
{
**
self
}
}
fn
repeater
<
A
:
C
opy
>
(
v
:
@
A
)
->
@
repeat
<
A
>
{
fn
repeater
<
A
:
C
lone
>
(
v
:
@
A
)
->
@
repeat
<
A
>
{
// Note: owned kind is not necessary as A appears in the trait type
@
v
as
@
repeat
<
A
>
// No
}
...
...
src/test/compile-fail/kindck-owned-trait-scoped.rs
浏览文件 @
e20549ff
...
...
@@ -18,11 +18,11 @@ trait foo {
fn
foo
(
&
self
,
i
:
&
'self
int
)
->
int
;
}
impl
<
T
:
C
opy
>
foo
for
T
{
impl
<
T
:
C
lone
>
foo
for
T
{
fn
foo
(
&
self
,
i
:
&
'self
int
)
->
int
{
*
i
}
}
fn
to_foo
<
T
:
C
opy
>
(
t
:
T
)
{
fn
to_foo
<
T
:
C
lone
>
(
t
:
T
)
{
// This version is ok because, although T may contain borrowed
// pointers, it never escapes the fn body. We know this because
// the type of foo includes a region which will be resolved to
...
...
@@ -33,14 +33,14 @@ struct F<T> { f: T }
assert_eq!
(
x
.foo
(
v
),
3
);
}
fn
to_foo_2
<
T
:
C
opy
>
(
t
:
T
)
->
@
foo
{
fn
to_foo_2
<
T
:
C
lone
>
(
t
:
T
)
->
@
foo
{
// Not OK---T may contain borrowed ptrs and it is going to escape
// as part of the returned foo value
struct
F
<
T
>
{
f
:
T
}
@
F
{
f
:
t
}
as
@
foo
//~ ERROR value may contain borrowed pointers; add `'static` bound
}
fn
to_foo_3
<
T
:
C
opy
+
'static
>
(
t
:
T
)
->
@
foo
{
fn
to_foo_3
<
T
:
C
lone
+
'static
>
(
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
struct
F
<
T
>
{
f
:
T
}
...
...
src/test/compile-fail/kindck-owned-trait.rs
浏览文件 @
e20549ff
...
...
@@ -10,13 +10,13 @@
trait
foo
{
fn
foo
(
&
self
);
}
fn
to_foo
<
T
:
C
opy
+
foo
>
(
t
:
T
)
->
@
foo
{
fn
to_foo
<
T
:
C
lone
+
foo
>
(
t
:
T
)
->
@
foo
{
@
t
as
@
foo
//~^ ERROR value may contain borrowed pointers; add `'static` bound
//~^^ ERROR cannot pack type
}
fn
to_foo2
<
T
:
C
opy
+
foo
+
'static
>
(
t
:
T
)
->
@
foo
{
fn
to_foo2
<
T
:
C
lone
+
foo
+
'static
>
(
t
:
T
)
->
@
foo
{
@
t
as
@
foo
}
...
...
src/test/compile-fail/trait-bounds-cant-coerce.rs
浏览文件 @
e20549ff
...
...
@@ -14,11 +14,11 @@ trait Foo {
fn
a
(
_
x
:
~
Foo
:
Send
)
{
}
fn
b
(
_
x
:
~
Foo
:
Send
+
C
opy
)
{
fn
b
(
_
x
:
~
Foo
:
Send
+
C
lone
)
{
}
fn
c
(
x
:
~
Foo
:
Freeze
+
Send
)
{
b
(
x
);
//~ ERROR expected bounds `C
opy
+Send`
b
(
x
);
//~ ERROR expected bounds `C
lone
+Send`
}
fn
d
(
x
:
~
Foo
:)
{
...
...
src/test/run-pass/auto-instantiate.rs
浏览文件 @
e20549ff
...
...
@@ -16,7 +16,7 @@
struct
Pair
<
T
,
U
>
{
a
:
T
,
b
:
U
}
struct
Triple
{
x
:
int
,
y
:
int
,
z
:
int
}
fn
f
<
T
:
Copy
,
U
:
Copy
>
(
x
:
T
,
y
:
U
)
->
Pair
<
T
,
U
>
{
return
Pair
{
a
:
x
,
b
:
y
};
}
fn
f
<
T
,
U
>
(
x
:
T
,
y
:
U
)
->
Pair
<
T
,
U
>
{
return
Pair
{
a
:
x
,
b
:
y
};
}
pub
fn
main
()
{
info!
(
"%?"
,
f
(
Triple
{
x
:
3
,
y
:
4
,
z
:
5
},
4
)
.a.x
);
...
...
src/test/run-pass/autobind.rs
浏览文件 @
e20549ff
...
...
@@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
fn
f
<
T
:
Copy
>
(
x
:
~
[
T
])
->
T
{
return
x
[
0
];
}
fn
f
<
T
>
(
x
:
~
[
T
])
->
T
{
return
x
[
0
];
}
fn
g
(
act
:
&
fn
(
~
[
int
])
->
int
)
->
int
{
return
act
(
~
[
1
,
2
,
3
]);
}
...
...
src/test/run-pass/cond-macro-no-default.rs
浏览文件 @
e20549ff
...
...
@@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
fn
clamp
<
T
:
Copy
+
Ord
+
Signed
>
(
x
:
T
,
mn
:
T
,
mx
:
T
)
->
T
{
fn
clamp
<
T
:
Ord
+
Signed
>
(
x
:
T
,
mn
:
T
,
mx
:
T
)
->
T
{
cond!
(
(
x
>
mx
)
{
return
mx
;
}
(
x
<
mn
)
{
return
mn
;
}
...
...
src/test/run-pass/cond-macro.rs
浏览文件 @
e20549ff
...
...
@@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
fn
clamp
<
T
:
Copy
+
Ord
+
Signed
>
(
x
:
T
,
mn
:
T
,
mx
:
T
)
->
T
{
fn
clamp
<
T
:
Ord
+
Signed
>
(
x
:
T
,
mn
:
T
,
mx
:
T
)
->
T
{
cond!
(
(
x
>
mx
)
{
mx
}
(
x
<
mn
)
{
mn
}
...
...
src/test/run-pass/const-bound.rs
浏览文件 @
e20549ff
...
...
@@ -12,7 +12,7 @@
// are const.
fn
foo
<
T
:
Copy
+
Freeze
>
(
x
:
T
)
->
T
{
x
}
fn
foo
<
T
:
Freeze
>
(
x
:
T
)
->
T
{
x
}
struct
F
{
field
:
int
}
...
...
src/test/run-pass/expr-block-generic-unique1.rs
浏览文件 @
e20549ff
...
...
@@ -13,7 +13,7 @@
// -*- rust -*-
type
compare
<
T
>
=
@
fn
(
~
T
,
~
T
)
->
bool
;
fn
test_generic
<
T
:
C
opy
+
C
lone
>
(
expected
:
~
T
,
eq
:
compare
<
T
>
)
{
fn
test_generic
<
T
:
Clone
>
(
expected
:
~
T
,
eq
:
compare
<
T
>
)
{
let
actual
:
~
T
=
{
expected
.clone
()
};
assert
!
((
eq
(
expected
,
actual
)));
}
...
...
src/test/run-pass/expr-fn.rs
浏览文件 @
e20549ff
...
...
@@ -19,7 +19,7 @@ fn f() -> ~[int] { ~[10, 11] }
}
fn
test_generic
()
{
fn
f
<
T
:
Copy
>
(
t
:
T
)
->
T
{
t
}
fn
f
<
T
>
(
t
:
T
)
->
T
{
t
}
assert_eq!
(
f
(
10
),
10
);
}
...
...
src/test/run-pass/expr-match-generic-unique1.rs
浏览文件 @
e20549ff
...
...
@@ -13,7 +13,7 @@
// -*- rust -*-
type
compare
<
T
>
=
@
fn
(
~
T
,
~
T
)
->
bool
;
fn
test_generic
<
T
:
C
opy
+
C
lone
>
(
expected
:
~
T
,
eq
:
compare
<
T
>
)
{
fn
test_generic
<
T
:
Clone
>
(
expected
:
~
T
,
eq
:
compare
<
T
>
)
{
let
actual
:
~
T
=
match
true
{
true
=>
{
expected
.clone
()
},
_
=>
fail
!
(
"wat"
)
...
...
src/test/run-pass/expr-match-generic-unique2.rs
浏览文件 @
e20549ff
...
...
@@ -13,7 +13,7 @@
type
compare
<
T
>
=
@
fn
(
T
,
T
)
->
bool
;
fn
test_generic
<
T
:
C
opy
+
C
lone
>
(
expected
:
T
,
eq
:
compare
<
T
>
)
{
fn
test_generic
<
T
:
Clone
>
(
expected
:
T
,
eq
:
compare
<
T
>
)
{
let
actual
:
T
=
match
true
{
true
=>
expected
.clone
(),
_
=>
fail
!
(
"wat"
)
...
...
src/test/run-pass/generic-alias-box.rs
浏览文件 @
e20549ff
...
...
@@ -10,7 +10,7 @@
fn
id
<
T
:
Copy
>
(
t
:
T
)
->
T
{
return
t
;
}
fn
id
<
T
>
(
t
:
T
)
->
T
{
return
t
;
}
pub
fn
main
()
{
let
expected
=
@
100
;
...
...
src/test/run-pass/generic-alias-unique.rs
浏览文件 @
e20549ff
...
...
@@ -10,7 +10,7 @@
fn
id
<
T
:
Copy
+
Send
>
(
t
:
T
)
->
T
{
return
t
;
}
fn
id
<
T
:
Send
>
(
t
:
T
)
->
T
{
return
t
;
}
pub
fn
main
()
{
let
expected
=
~
100
;
...
...
src/test/run-pass/generic-box.rs
浏览文件 @
e20549ff
...
...
@@ -10,7 +10,7 @@
fn
box
<
T
:
Copy
>
(
x
:
Box
<
T
>
)
->
@
Box
<
T
>
{
return
@
x
;
}
fn
box
<
T
>
(
x
:
Box
<
T
>
)
->
@
Box
<
T
>
{
return
@
x
;
}
struct
Box
<
T
>
{
x
:
T
,
y
:
T
,
z
:
T
}
...
...
src/test/run-pass/generic-drop-glue.rs
浏览文件 @
e20549ff
...
...
@@ -11,6 +11,6 @@
struct
Pair
{
x
:
@
int
,
y
:
@
int
}
fn
f
<
T
:
Copy
>
(
t
:
T
)
{
let
t1
:
T
=
t
;
}
fn
f
<
T
>
(
t
:
T
)
{
let
t1
:
T
=
t
;
}
pub
fn
main
()
{
let
x
=
Pair
{
x
:
@
10
,
y
:
@
12
};
f
(
x
);
}
src/test/run-pass/generic-exterior-box.rs
浏览文件 @
e20549ff
...
...
@@ -12,7 +12,7 @@
struct
Recbox
<
T
>
{
x
:
@
T
}
fn
reclift
<
T
:
Copy
>
(
t
:
T
)
->
Recbox
<
T
>
{
return
Recbox
{
x
:
@
t
};
}
fn
reclift
<
T
>
(
t
:
T
)
->
Recbox
<
T
>
{
return
Recbox
{
x
:
@
t
};
}
pub
fn
main
()
{
let
foo
:
int
=
17
;
...
...
src/test/run-pass/generic-exterior-unique.rs
浏览文件 @
e20549ff
...
...
@@ -10,7 +10,7 @@
struct
Recbox
<
T
>
{
x
:
~
T
}
fn
reclift
<
T
:
Copy
>
(
t
:
T
)
->
Recbox
<
T
>
{
return
Recbox
{
x
:
~
t
};
}
fn
reclift
<
T
>
(
t
:
T
)
->
Recbox
<
T
>
{
return
Recbox
{
x
:
~
t
};
}
pub
fn
main
()
{
let
foo
:
int
=
17
;
...
...
src/test/run-pass/generic-fn-infer.rs
浏览文件 @
e20549ff
...
...
@@ -14,6 +14,6 @@
// -*- rust -*-
// Issue #45: infer type parameters in function applications
fn
id
<
T
:
Copy
>
(
x
:
T
)
->
T
{
return
x
;
}
fn
id
<
T
>
(
x
:
T
)
->
T
{
return
x
;
}
pub
fn
main
()
{
let
x
:
int
=
42
;
let
y
:
int
=
id
(
x
);
assert
!
((
x
==
y
));
}
src/test/run-pass/generic-fn-unique.rs
浏览文件 @
e20549ff
...
...
@@ -9,6 +9,6 @@
// except according to those terms.
fn
f
<
T
:
Copy
>
(
x
:
~
T
)
->
~
T
{
return
x
;
}
fn
f
<
T
>
(
x
:
~
T
)
->
~
T
{
return
x
;
}
pub
fn
main
()
{
let
x
=
f
(
~
3
);
info!
(
*
x
);
}
src/test/run-pass/generic-fn.rs
浏览文件 @
e20549ff
...
...
@@ -12,7 +12,7 @@
// -*- rust -*-
fn
id
<
T
:
Copy
>
(
x
:
T
)
->
T
{
return
x
;
}
fn
id
<
T
>
(
x
:
T
)
->
T
{
return
x
;
}
struct
Triple
{
x
:
int
,
y
:
int
,
z
:
int
}
...
...
src/test/run-pass/generic-tup.rs
浏览文件 @
e20549ff
...
...
@@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
fn
get_third
<
T
:
Copy
>
(
t
:
(
T
,
T
,
T
))
->
T
{
let
(
_
,
_
,
x
)
=
t
;
return
x
;
}
fn
get_third
<
T
>
(
t
:
(
T
,
T
,
T
))
->
T
{
let
(
_
,
_
,
x
)
=
t
;
return
x
;
}
pub
fn
main
()
{
info!
(
get_third
((
1
,
2
,
3
)));
...
...
src/test/run-pass/generic-unique.rs
浏览文件 @
e20549ff
...
...
@@ -10,7 +10,7 @@
struct
Triple
<
T
>
{
x
:
T
,
y
:
T
,
z
:
T
}
fn
box
<
T
:
Copy
>
(
x
:
Triple
<
T
>
)
->
~
Triple
<
T
>
{
return
~
x
;
}
fn
box
<
T
>
(
x
:
Triple
<
T
>
)
->
~
Triple
<
T
>
{
return
~
x
;
}
pub
fn
main
()
{
let
x
:
~
Triple
<
int
>
=
box
::
<
int
>
(
Triple
{
x
:
1
,
y
:
2
,
z
:
3
});
...
...
src/test/run-pass/issue-2288.rs
浏览文件 @
e20549ff
...
...
@@ -8,25 +8,25 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
trait
clam
<
A
:
Copy
>
{
trait
clam
<
A
>
{
fn
chowder
(
&
self
,
y
:
A
);
}
struct
foo
<
A
>
{
x
:
A
,
}
impl
<
A
:
Copy
>
clam
<
A
>
for
foo
<
A
>
{
impl
<
A
>
clam
<
A
>
for
foo
<
A
>
{
fn
chowder
(
&
self
,
y
:
A
)
{
}
}
fn
foo
<
A
:
Copy
>
(
b
:
A
)
->
foo
<
A
>
{
fn
foo
<
A
>
(
b
:
A
)
->
foo
<
A
>
{
foo
{
x
:
b
}
}
fn
f
<
A
:
Copy
>
(
x
:
@
clam
<
A
>
,
a
:
A
)
{
fn
f
<
A
>
(
x
:
@
clam
<
A
>
,
a
:
A
)
{
x
.chowder
(
a
);
}
...
...
src/test/run-pass/issue-2311-2.rs
浏览文件 @
e20549ff
...
...
@@ -8,18 +8,18 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
trait
clam
<
A
:
Copy
>
{
}
trait
clam
<
A
>
{
}
struct
foo
<
A
>
{
x
:
A
,
}
impl
<
A
:
Copy
>
foo
<
A
>
{
impl
<
A
>
foo
<
A
>
{
pub
fn
bar
<
B
,
C
:
clam
<
A
>>
(
&
self
,
c
:
C
)
->
B
{
fail
!
();
}
}
fn
foo
<
A
:
Copy
>
(
b
:
A
)
->
foo
<
A
>
{
fn
foo
<
A
>
(
b
:
A
)
->
foo
<
A
>
{
foo
{
x
:
b
}
...
...
src/test/run-pass/issue-2445-b.rs
浏览文件 @
e20549ff
...
...
@@ -12,18 +12,18 @@ struct c1<T> {
x
:
T
,
}
impl
<
T
:
Copy
>
c1
<
T
>
{
impl
<
T
>
c1
<
T
>
{
pub
fn
f1
(
&
self
,
x
:
int
)
{
}
}
fn
c1
<
T
:
Copy
>
(
x
:
T
)
->
c1
<
T
>
{
fn
c1
<
T
>
(
x
:
T
)
->
c1
<
T
>
{
c1
{
x
:
x
}
}
impl
<
T
:
Copy
>
c1
<
T
>
{
impl
<
T
>
c1
<
T
>
{
pub
fn
f2
(
&
self
,
x
:
int
)
{
}
}
...
...
src/test/run-pass/issue-2445.rs
浏览文件 @
e20549ff
...
...
@@ -12,17 +12,17 @@ struct c1<T> {
x
:
T
,
}
impl
<
T
:
Copy
>
c1
<
T
>
{
impl
<
T
>
c1
<
T
>
{
pub
fn
f1
(
&
self
,
x
:
T
)
{}
}
fn
c1
<
T
:
Copy
>
(
x
:
T
)
->
c1
<
T
>
{
fn
c1
<
T
>
(
x
:
T
)
->
c1
<
T
>
{
c1
{
x
:
x
}
}
impl
<
T
:
Copy
>
c1
<
T
>
{
impl
<
T
>
c1
<
T
>
{
pub
fn
f2
(
&
self
,
x
:
T
)
{}
}
...
...
src/test/run-pass/issue-2550.rs
浏览文件 @
e20549ff
...
...
@@ -18,7 +18,7 @@ fn C(x: uint) -> C {
}
}
fn
f
<
T
:
Copy
>
(
_
x
:
T
)
{
fn
f
<
T
>
(
_
x
:
T
)
{
}
#[deny(non_implicitly_copyable_typarams)]
...
...
src/test/run-pass/issue-2611-3.rs
浏览文件 @
e20549ff
...
...
@@ -12,7 +12,7 @@
// than the traits require.
trait
A
{
fn
b
<
C
:
Copy
+
Freeze
,
D
>
(
x
:
C
)
->
C
;
fn
b
<
C
:
Freeze
,
D
>
(
x
:
C
)
->
C
;
}
struct
E
{
...
...
@@ -20,7 +20,7 @@ struct E {
}
impl
A
for
E
{
fn
b
<
F
:
Copy
,
G
>
(
_
x
:
F
)
->
F
{
fail
!
()
}
//~ ERROR in method `b`, type parameter 0 has 1 bound, but
fn
b
<
F
,
G
>
(
_
x
:
F
)
->
F
{
fail
!
()
}
//~ ERROR in method `b`, type parameter 0 has 1 bound, but
}
fn
main
()
{}
src/test/run-pass/issue-3149.rs
浏览文件 @
e20549ff
...
...
@@ -8,12 +8,11 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
fn
Matrix4
<
T
:
Copy
>
(
m11
:
T
,
m12
:
T
,
m13
:
T
,
m14
:
T
,
m21
:
T
,
m22
:
T
,
m23
:
T
,
m24
:
T
,
m31
:
T
,
m32
:
T
,
m33
:
T
,
m34
:
T
,
m41
:
T
,
m42
:
T
,
m43
:
T
,
m44
:
T
)
->
Matrix4
<
T
>
{
fn
Matrix4
<
T
>
(
m11
:
T
,
m12
:
T
,
m13
:
T
,
m14
:
T
,
m21
:
T
,
m22
:
T
,
m23
:
T
,
m24
:
T
,
m31
:
T
,
m32
:
T
,
m33
:
T
,
m34
:
T
,
m41
:
T
,
m42
:
T
,
m43
:
T
,
m44
:
T
)
->
Matrix4
<
T
>
{
Matrix4
{
m11
:
m11
,
m12
:
m12
,
m13
:
m13
,
m14
:
m14
,
m21
:
m21
,
m22
:
m22
,
m23
:
m23
,
m24
:
m24
,
...
...
src/test/run-pass/issue-333.rs
浏览文件 @
e20549ff
...
...
@@ -8,8 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
fn
quux
<
T
:
Copy
>
(
x
:
T
)
->
T
{
let
f
=
id
::
<
T
>
;
return
f
(
x
);
}
fn
quux
<
T
>
(
x
:
T
)
->
T
{
let
f
=
id
::
<
T
>
;
return
f
(
x
);
}
fn
id
<
T
:
Copy
>
(
x
:
T
)
->
T
{
return
x
;
}
fn
id
<
T
>
(
x
:
T
)
->
T
{
return
x
;
}
pub
fn
main
()
{
assert
!
((
quux
(
10
)
==
10
));
}
src/test/run-pass/ivec-add.rs
浏览文件 @
e20549ff
...
...
@@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
fn
double
<
T
:
C
opy
+
C
lone
>
(
a
:
T
)
->
~
[
T
]
{
return
~
[
a
.clone
()]
+
~
[
a
];
}
fn
double
<
T
:
Clone
>
(
a
:
T
)
->
~
[
T
]
{
return
~
[
a
.clone
()]
+
~
[
a
];
}
fn
double_int
(
a
:
int
)
->
~
[
int
]
{
return
~
[
a
]
+
~
[
a
];
}
...
...
src/test/run-pass/monad.rs
浏览文件 @
e20549ff
...
...
@@ -13,11 +13,11 @@
use
std
::
int
;
trait
vec_monad
<
A
>
{
fn
bind
<
B
:
Copy
>
(
&
self
,
f
:
&
fn
(
&
A
)
->
~
[
B
])
->
~
[
B
];
fn
bind
<
B
>
(
&
self
,
f
:
&
fn
(
&
A
)
->
~
[
B
])
->
~
[
B
];
}
impl
<
A
>
vec_monad
<
A
>
for
~
[
A
]
{
fn
bind
<
B
:
Copy
>
(
&
self
,
f
:
&
fn
(
&
A
)
->
~
[
B
])
->
~
[
B
]
{
fn
bind
<
B
>
(
&
self
,
f
:
&
fn
(
&
A
)
->
~
[
B
])
->
~
[
B
]
{
let
mut
r
=
~
[];
for
self
.iter
()
.advance
|
elt
|
{
r
.push_all_move
(
f
(
elt
));
...
...
src/test/run-pass/monomorphized-callees-with-ty-params-3314.rs
浏览文件 @
e20549ff
...
...
@@ -25,7 +25,7 @@ fn serialize<S:Serializer>(&self, _s: S) { }
struct
F
<
A
>
{
a
:
A
}
impl
<
A
:
Copy
+
Serializable
>
Serializable
for
F
<
A
>
{
impl
<
A
:
Serializable
>
Serializable
for
F
<
A
>
{
fn
serialize
<
S
:
Serializer
>
(
&
self
,
s
:
S
)
{
self
.a
.serialize
(
s
);
}
...
...
src/test/run-pass/non-boolean-pure-fns.rs
浏览文件 @
e20549ff
...
...
@@ -14,15 +14,15 @@
use
extra
::
list
::
*
;
fn
pure_length_go
<
T
:
Copy
>
(
ls
:
@
List
<
T
>
,
acc
:
uint
)
->
uint
{
fn
pure_length_go
<
T
>
(
ls
:
@
List
<
T
>
,
acc
:
uint
)
->
uint
{
match
*
ls
{
Nil
=>
{
acc
}
Cons
(
_
,
tl
)
=>
{
pure_length_go
(
tl
,
acc
+
1u
)
}
}
}
fn
pure_length
<
T
:
Copy
>
(
ls
:
@
List
<
T
>
)
->
uint
{
pure_length_go
(
ls
,
0u
)
}
fn
pure_length
<
T
>
(
ls
:
@
List
<
T
>
)
->
uint
{
pure_length_go
(
ls
,
0u
)
}
fn
nonempty_list
<
T
:
Copy
>
(
ls
:
@
List
<
T
>
)
->
bool
{
pure_length
(
ls
)
>
0u
}
fn
nonempty_list
<
T
>
(
ls
:
@
List
<
T
>
)
->
bool
{
pure_length
(
ls
)
>
0u
}
fn
safe_head
<
T
:
Copy
>
(
ls
:
@
List
<
T
>
)
->
T
{
fn
safe_head
<
T
>
(
ls
:
@
List
<
T
>
)
->
T
{
assert
!
(
!
is_empty
(
ls
));
return
head
(
ls
);
}
...
...
src/test/run-pass/ret-break-cont-in-block.rs
浏览文件 @
e20549ff
...
...
@@ -23,7 +23,7 @@ fn iter<T>(v: ~[T], it: &fn(&T) -> bool) -> bool {
return
true
;
}
fn
find_pos
<
T
:
Eq
+
C
opy
+
C
lone
>
(
n
:
T
,
h
:
~
[
T
])
->
Option
<
uint
>
{
fn
find_pos
<
T
:
Eq
+
Clone
>
(
n
:
T
,
h
:
~
[
T
])
->
Option
<
uint
>
{
let
mut
i
=
0u
;
for
iter
(
h
.clone
())
|
e
|
{
if
*
e
==
n
{
return
Some
(
i
);
}
...
...
src/test/run-pass/ret-none.rs
浏览文件 @
e20549ff
...
...
@@ -12,6 +12,6 @@
enum
option
<
T
>
{
none
,
some
(
T
),
}
fn
f
<
T
:
Copy
>
()
->
option
<
T
>
{
return
none
;
}
fn
f
<
T
>
()
->
option
<
T
>
{
return
none
;
}
pub
fn
main
()
{
f
::
<
int
>
();
}
src/test/run-pass/static-impl.rs
浏览文件 @
e20549ff
...
...
@@ -43,13 +43,13 @@ fn multi(&self, f: &fn(uint)) {
trait
vec_utils
<
T
>
{
fn
length_
(
&
self
,
)
->
uint
;
fn
iter_
(
&
self
,
f
:
&
fn
(
&
T
));
fn
map_
<
U
:
Copy
>
(
&
self
,
f
:
&
fn
(
&
T
)
->
U
)
->
~
[
U
];
fn
map_
<
U
>
(
&
self
,
f
:
&
fn
(
&
T
)
->
U
)
->
~
[
U
];
}
impl
<
T
>
vec_utils
<
T
>
for
~
[
T
]
{
fn
length_
(
&
self
)
->
uint
{
self
.len
()
}
fn
iter_
(
&
self
,
f
:
&
fn
(
&
T
))
{
for
self
.iter
()
.advance
|
x
|
{
f
(
x
);
}
}
fn
map_
<
U
:
Copy
>
(
&
self
,
f
:
&
fn
(
&
T
)
->
U
)
->
~
[
U
]
{
fn
map_
<
U
>
(
&
self
,
f
:
&
fn
(
&
T
)
->
U
)
->
~
[
U
]
{
let
mut
r
=
~
[];
for
self
.iter
()
.advance
|
elt
|
{
r
.push
(
f
(
elt
));
...
...
src/test/run-pass/tag-align-dyn-variants.rs
浏览文件 @
e20549ff
...
...
@@ -24,7 +24,7 @@ struct t_rec<A,B> {
tB
:
a_tag
<
A
,
B
>
}
fn
mk_rec
<
A
:
Copy
,
B
:
Copy
>
(
a
:
A
,
b
:
B
)
->
t_rec
<
A
,
B
>
{
fn
mk_rec
<
A
,
B
>
(
a
:
A
,
b
:
B
)
->
t_rec
<
A
,
B
>
{
return
t_rec
{
chA
:
0u8
,
tA
:
varA
(
a
),
chB
:
1u8
,
tB
:
varB
(
b
)
};
}
...
...
src/test/run-pass/trait-bounds-basic.rs
浏览文件 @
e20549ff
...
...
@@ -21,7 +21,7 @@ fn c(x: ~Foo:Freeze+Send) {
a
(
x
);
}
fn
d
(
x
:
~
Foo
:
Send
+
Copy
)
{
fn
d
(
x
:
~
Foo
:
Send
)
{
b
(
x
);
}
...
...
src/test/run-pass/trait-generic.rs
浏览文件 @
e20549ff
...
...
@@ -26,10 +26,10 @@ fn to_str(&self) -> ~str { ~"()" }
}
trait
map
<
T
>
{
fn
map
<
U
:
Copy
>
(
&
self
,
f
:
&
fn
(
&
T
)
->
U
)
->
~
[
U
];
fn
map
<
U
>
(
&
self
,
f
:
&
fn
(
&
T
)
->
U
)
->
~
[
U
];
}
impl
<
T
>
map
<
T
>
for
~
[
T
]
{
fn
map
<
U
:
Copy
>
(
&
self
,
f
:
&
fn
(
&
T
)
->
U
)
->
~
[
U
]
{
fn
map
<
U
>
(
&
self
,
f
:
&
fn
(
&
T
)
->
U
)
->
~
[
U
]
{
let
mut
r
=
~
[];
// FIXME: #7355 generates bad code with Iterator
for
std
::
uint
::
range
(
0
,
self
.len
())
|
i
|
{
...
...
src/test/run-pass/trait-inheritance-overloading-xc-exe.rs
浏览文件 @
e20549ff
...
...
@@ -14,7 +14,7 @@
extern
mod
trait_inheritance_overloading_xc
;
use
trait_inheritance_overloading_xc
::{
MyNum
,
MyInt
};
fn
f
<
T
:
Copy
+
MyNum
>
(
x
:
T
,
y
:
T
)
->
(
T
,
T
,
T
)
{
fn
f
<
T
:
MyNum
>
(
x
:
T
,
y
:
T
)
->
(
T
,
T
,
T
)
{
return
(
x
+
y
,
x
-
y
,
x
*
y
);
}
...
...
src/test/run-pass/trait-inheritance-overloading.rs
浏览文件 @
e20549ff
...
...
@@ -33,7 +33,7 @@ fn ne(&self, other: &MyInt) -> bool { !self.eq(other) }
impl
MyNum
for
MyInt
;
fn
f
<
T
:
Copy
+
MyNum
>
(
x
:
T
,
y
:
T
)
->
(
T
,
T
,
T
)
{
fn
f
<
T
:
MyNum
>
(
x
:
T
,
y
:
T
)
->
(
T
,
T
,
T
)
{
return
(
x
+
y
,
x
-
y
,
x
*
y
);
}
...
...
src/test/run-pass/type-param-constraints.rs
浏览文件 @
e20549ff
...
...
@@ -11,7 +11,7 @@
// xfail-fast
fn
p_foo
<
T
>
(
pinned
:
T
)
{
}
fn
s_foo
<
T
:
Copy
>
(
shared
:
T
)
{
}
fn
s_foo
<
T
>
(
shared
:
T
)
{
}
fn
u_foo
<
T
:
Send
>
(
unique
:
T
)
{
}
struct
r
{
...
...
src/test/run-pass/uniq-cc-generic.rs
浏览文件 @
e20549ff
...
...
@@ -20,7 +20,7 @@ struct Pointy {
d
:
~
fn
()
->
uint
,
}
fn
make_uniq_closure
<
A
:
Send
+
Copy
>
(
a
:
A
)
->
~
fn
()
->
uint
{
fn
make_uniq_closure
<
A
:
Send
>
(
a
:
A
)
->
~
fn
()
->
uint
{
let
result
:
~
fn
()
->
uint
=
||
ptr
::
to_unsafe_ptr
(
&
a
)
as
uint
;
result
}
...
...
src/test/run-pass/unique-assign-generic.rs
浏览文件 @
e20549ff
...
...
@@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
fn
f
<
T
:
Copy
>
(
t
:
T
)
->
T
{
fn
f
<
T
>
(
t
:
T
)
->
T
{
let
t1
=
t
;
t1
}
...
...
src/test/run-pass/unique-generic-assign.rs
浏览文件 @
e20549ff
...
...
@@ -10,7 +10,7 @@
// Issue #976
fn
f
<
T
:
Copy
>
(
x
:
~
T
)
{
fn
f
<
T
>
(
x
:
~
T
)
{
let
_
x2
=
x
;
}
pub
fn
main
()
{
}
src/test/run-pass/unique-kinds.rs
浏览文件 @
e20549ff
...
...
@@ -30,11 +30,11 @@ fn g<T:Send + Eq>(i: T, j: T) {
fn
copyable
()
{
fn
f
<
T
:
Copy
+
Eq
>
(
i
:
T
,
j
:
T
)
{
fn
f
<
T
:
Eq
>
(
i
:
T
,
j
:
T
)
{
assert_eq!
(
i
,
j
);
}
fn
g
<
T
:
Copy
+
Eq
>
(
i
:
T
,
j
:
T
)
{
fn
g
<
T
:
Eq
>
(
i
:
T
,
j
:
T
)
{
assert
!
(
i
!=
j
);
}
...
...
src/test/run-pass/vec-matching-fold.rs
浏览文件 @
e20549ff
fn
foldl
<
T
,
U
:
Copy
+
Clone
>
(
values
:
&
[
T
],
initial
:
U
,
function
:
&
fn
(
partial
:
U
,
element
:
&
T
)
->
U
)
->
U
{
fn
foldl
<
T
,
U
:
Clone
>
(
values
:
&
[
T
],
initial
:
U
,
function
:
&
fn
(
partial
:
U
,
element
:
&
T
)
->
U
)
->
U
{
match
values
{
[
ref
head
,
..
tail
]
=>
foldl
(
tail
,
function
(
initial
,
head
),
function
),
...
...
@@ -10,11 +9,10 @@ fn foldl<T, U: Copy+Clone>(
}
}
fn
foldr
<
T
,
U
:
Copy
+
Clone
>
(
values
:
&
[
T
],
initial
:
U
,
function
:
&
fn
(
element
:
&
T
,
partial
:
U
)
->
U
)
->
U
{
fn
foldr
<
T
,
U
:
Clone
>
(
values
:
&
[
T
],
initial
:
U
,
function
:
&
fn
(
element
:
&
T
,
partial
:
U
)
->
U
)
->
U
{
match
values
{
[
..
head
,
ref
tail
]
=>
foldr
(
head
,
function
(
tail
,
initial
),
function
),
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录