Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
7d5b0454
R
Rust
项目概览
int
/
Rust
11 个月 前同步成功
通知
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,发现更多精彩内容 >>
提交
7d5b0454
编写于
1月 03, 2015
作者:
J
Jorge Aparicio
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix cfail tests
上级
ca17d081
变更
101
展开全部
隐藏空白更改
内联
并排
Showing
101 changed file
with
195 addition
and
612 deletion
+195
-612
src/test/compile-fail/access-mode-in-closures.rs
src/test/compile-fail/access-mode-in-closures.rs
+1
-1
src/test/compile-fail/assign-to-method.rs
src/test/compile-fail/assign-to-method.rs
+1
-1
src/test/compile-fail/block-coerce-no-2.rs
src/test/compile-fail/block-coerce-no-2.rs
+0
-23
src/test/compile-fail/block-coerce-no.rs
src/test/compile-fail/block-coerce-no.rs
+0
-26
src/test/compile-fail/borrowck-assign-comp-idx.rs
src/test/compile-fail/borrowck-assign-comp-idx.rs
+1
-1
src/test/compile-fail/borrowck-autoref-3261.rs
src/test/compile-fail/borrowck-autoref-3261.rs
+2
-2
src/test/compile-fail/borrowck-block-unint.rs
src/test/compile-fail/borrowck-block-unint.rs
+1
-1
src/test/compile-fail/borrowck-call-is-borrow-issue-12224.rs
src/test/compile-fail/borrowck-call-is-borrow-issue-12224.rs
+19
-18
src/test/compile-fail/borrowck-closures-mut-and-imm.rs
src/test/compile-fail/borrowck-closures-mut-and-imm.rs
+12
-12
src/test/compile-fail/borrowck-closures-mut-of-imm.rs
src/test/compile-fail/borrowck-closures-mut-of-imm.rs
+2
-2
src/test/compile-fail/borrowck-closures-two-mut.rs
src/test/compile-fail/borrowck-closures-two-mut.rs
+10
-10
src/test/compile-fail/borrowck-closures-unique-imm.rs
src/test/compile-fail/borrowck-closures-unique-imm.rs
+1
-1
src/test/compile-fail/borrowck-closures-unique.rs
src/test/compile-fail/borrowck-closures-unique.rs
+9
-9
src/test/compile-fail/borrowck-closures-use-after-free.rs
src/test/compile-fail/borrowck-closures-use-after-free.rs
+1
-1
src/test/compile-fail/borrowck-init-in-called-fn-expr.rs
src/test/compile-fail/borrowck-init-in-called-fn-expr.rs
+1
-1
src/test/compile-fail/borrowck-init-in-fn-expr.rs
src/test/compile-fail/borrowck-init-in-fn-expr.rs
+1
-1
src/test/compile-fail/borrowck-insert-during-each.rs
src/test/compile-fail/borrowck-insert-during-each.rs
+1
-1
src/test/compile-fail/borrowck-lend-flow-if.rs
src/test/compile-fail/borrowck-lend-flow-if.rs
+1
-1
src/test/compile-fail/borrowck-lend-flow-loop.rs
src/test/compile-fail/borrowck-lend-flow-loop.rs
+4
-2
src/test/compile-fail/borrowck-lend-flow.rs
src/test/compile-fail/borrowck-lend-flow.rs
+1
-1
src/test/compile-fail/borrowck-loan-blocks-move-cc.rs
src/test/compile-fail/borrowck-loan-blocks-move-cc.rs
+1
-1
src/test/compile-fail/borrowck-loan-blocks-mut-uniq.rs
src/test/compile-fail/borrowck-loan-blocks-mut-uniq.rs
+1
-1
src/test/compile-fail/borrowck-loan-rcvr.rs
src/test/compile-fail/borrowck-loan-rcvr.rs
+2
-2
src/test/compile-fail/borrowck-loan-vec-content.rs
src/test/compile-fail/borrowck-loan-vec-content.rs
+1
-1
src/test/compile-fail/borrowck-move-by-capture.rs
src/test/compile-fail/borrowck-move-by-capture.rs
+1
-1
src/test/compile-fail/borrowck-move-in-irrefut-pat.rs
src/test/compile-fail/borrowck-move-in-irrefut-pat.rs
+1
-1
src/test/compile-fail/borrowck-report-with-custom-diagnostic.rs
...st/compile-fail/borrowck-report-with-custom-diagnostic.rs
+1
-1
src/test/compile-fail/break-outside-loop.rs
src/test/compile-fail/break-outside-loop.rs
+1
-1
src/test/compile-fail/closure-bounds-cant-promote-superkind-in-struct.rs
...e-fail/closure-bounds-cant-promote-superkind-in-struct.rs
+5
-4
src/test/compile-fail/closure-bounds-not-builtin.rs
src/test/compile-fail/closure-bounds-not-builtin.rs
+0
-18
src/test/compile-fail/closure-bounds-static-cant-capture-borrowed.rs
...mpile-fail/closure-bounds-static-cant-capture-borrowed.rs
+1
-2
src/test/compile-fail/closure-bounds-subtype.rs
src/test/compile-fail/closure-bounds-subtype.rs
+5
-5
src/test/compile-fail/closure-reform-bad.rs
src/test/compile-fail/closure-reform-bad.rs
+1
-1
src/test/compile-fail/closure-that-fails.rs
src/test/compile-fail/closure-that-fails.rs
+0
-20
src/test/compile-fail/coerce-bare-fn-to-closure-and-proc.rs
src/test/compile-fail/coerce-bare-fn-to-closure-and-proc.rs
+0
-28
src/test/compile-fail/dead-code-closure-bang.rs
src/test/compile-fail/dead-code-closure-bang.rs
+3
-1
src/test/compile-fail/extern-wrong-value-type.rs
src/test/compile-fail/extern-wrong-value-type.rs
+3
-1
src/test/compile-fail/fn-variance-1.rs
src/test/compile-fail/fn-variance-1.rs
+1
-1
src/test/compile-fail/immut-function-arguments.rs
src/test/compile-fail/immut-function-arguments.rs
+1
-1
src/test/compile-fail/issue-10291.rs
src/test/compile-fail/issue-10291.rs
+1
-1
src/test/compile-fail/issue-11192.rs
src/test/compile-fail/issue-11192.rs
+1
-1
src/test/compile-fail/issue-11873.rs
src/test/compile-fail/issue-11873.rs
+1
-1
src/test/compile-fail/issue-14182.rs
src/test/compile-fail/issue-14182.rs
+2
-0
src/test/compile-fail/issue-16939.rs
src/test/compile-fail/issue-16939.rs
+1
-1
src/test/compile-fail/issue-17636.rs
src/test/compile-fail/issue-17636.rs
+0
-19
src/test/compile-fail/issue-17651.rs
src/test/compile-fail/issue-17651.rs
+1
-1
src/test/compile-fail/issue-18343.rs
src/test/compile-fail/issue-18343.rs
+3
-3
src/test/compile-fail/issue-18345.rs
src/test/compile-fail/issue-18345.rs
+0
-20
src/test/compile-fail/issue-18783.rs
src/test/compile-fail/issue-18783.rs
+7
-7
src/test/compile-fail/issue-19009.rs
src/test/compile-fail/issue-19009.rs
+0
-19
src/test/compile-fail/issue-19141.rs
src/test/compile-fail/issue-19141.rs
+0
-15
src/test/compile-fail/issue-20193.rs
src/test/compile-fail/issue-20193.rs
+0
-24
src/test/compile-fail/issue-20228-1.rs
src/test/compile-fail/issue-20228-1.rs
+0
-20
src/test/compile-fail/issue-20228-2.rs
src/test/compile-fail/issue-20228-2.rs
+0
-20
src/test/compile-fail/issue-2149.rs
src/test/compile-fail/issue-2149.rs
+3
-3
src/test/compile-fail/issue-3044.rs
src/test/compile-fail/issue-3044.rs
+1
-1
src/test/compile-fail/issue-3563.rs
src/test/compile-fail/issue-3563.rs
+4
-3
src/test/compile-fail/issue-4335.rs
src/test/compile-fail/issue-4335.rs
+5
-3
src/test/compile-fail/issue-4523.rs
src/test/compile-fail/issue-4523.rs
+0
-17
src/test/compile-fail/issue-5216.rs
src/test/compile-fail/issue-5216.rs
+2
-2
src/test/compile-fail/issue-5239-1.rs
src/test/compile-fail/issue-5239-1.rs
+1
-1
src/test/compile-fail/issue-6801.rs
src/test/compile-fail/issue-6801.rs
+2
-2
src/test/compile-fail/issue-7573.rs
src/test/compile-fail/issue-7573.rs
+2
-2
src/test/compile-fail/kindck-copy.rs
src/test/compile-fail/kindck-copy.rs
+0
-3
src/test/compile-fail/kindck-send-object.rs
src/test/compile-fail/kindck-send-object.rs
+0
-5
src/test/compile-fail/lint-unused-mut-variables.rs
src/test/compile-fail/lint-unused-mut-variables.rs
+3
-3
src/test/compile-fail/lint-unused-unsafe.rs
src/test/compile-fail/lint-unused-unsafe.rs
+1
-1
src/test/compile-fail/liveness-closure-require-ret.rs
src/test/compile-fail/liveness-closure-require-ret.rs
+1
-1
src/test/compile-fail/moves-based-on-type-block-bad.rs
src/test/compile-fail/moves-based-on-type-block-bad.rs
+1
-1
src/test/compile-fail/moves-based-on-type-move-out-of-closure-env-issue-1965.rs
...moves-based-on-type-move-out-of-closure-env-issue-1965.rs
+1
-1
src/test/compile-fail/moves-based-on-type-no-recursive-stack-closure.rs
...le-fail/moves-based-on-type-no-recursive-stack-closure.rs
+7
-5
src/test/compile-fail/pptypedef.rs
src/test/compile-fail/pptypedef.rs
+1
-1
src/test/compile-fail/refutable-pattern-in-fn-arg.rs
src/test/compile-fail/refutable-pattern-in-fn-arg.rs
+1
-1
src/test/compile-fail/region-bound-on-closure-outlives-call.rs
...est/compile-fail/region-bound-on-closure-outlives-call.rs
+2
-2
src/test/compile-fail/regionck-closure-lifetimes.rs
src/test/compile-fail/regionck-closure-lifetimes.rs
+0
-60
src/test/compile-fail/regions-addr-of-upvar-self.rs
src/test/compile-fail/regions-addr-of-upvar-self.rs
+1
-1
src/test/compile-fail/regions-bounded-by-send.rs
src/test/compile-fail/regions-bounded-by-send.rs
+0
-5
src/test/compile-fail/regions-creating-enums.rs
src/test/compile-fail/regions-creating-enums.rs
+4
-4
src/test/compile-fail/regions-escape-bound-fn-2.rs
src/test/compile-fail/regions-escape-bound-fn-2.rs
+1
-1
src/test/compile-fail/regions-escape-bound-fn.rs
src/test/compile-fail/regions-escape-bound-fn.rs
+1
-1
src/test/compile-fail/regions-escape-method.rs
src/test/compile-fail/regions-escape-method.rs
+1
-1
src/test/compile-fail/regions-escape-via-trait-or-not.rs
src/test/compile-fail/regions-escape-via-trait-or-not.rs
+1
-1
src/test/compile-fail/regions-fn-subtyping.rs
src/test/compile-fail/regions-fn-subtyping.rs
+0
-45
src/test/compile-fail/regions-fns.rs
src/test/compile-fail/regions-fns.rs
+0
-21
src/test/compile-fail/regions-free-region-ordering-callee.rs
src/test/compile-fail/regions-free-region-ordering-callee.rs
+1
-1
src/test/compile-fail/regions-freevar.rs
src/test/compile-fail/regions-freevar.rs
+0
-18
src/test/compile-fail/regions-infer-at-fn-not-param.rs
src/test/compile-fail/regions-infer-at-fn-not-param.rs
+3
-3
src/test/compile-fail/regions-infer-borrow-scope-within-loop.rs
...st/compile-fail/regions-infer-borrow-scope-within-loop.rs
+4
-1
src/test/compile-fail/regions-infer-call-3.rs
src/test/compile-fail/regions-infer-call-3.rs
+1
-1
src/test/compile-fail/regions-infer-invariance-due-to-mutability-3.rs
...pile-fail/regions-infer-invariance-due-to-mutability-3.rs
+1
-1
src/test/compile-fail/regions-infer-invariance-due-to-mutability-4.rs
...pile-fail/regions-infer-invariance-due-to-mutability-4.rs
+1
-1
src/test/compile-fail/regions-infer-not-param.rs
src/test/compile-fail/regions-infer-not-param.rs
+2
-2
src/test/compile-fail/regions-name-undeclared.rs
src/test/compile-fail/regions-name-undeclared.rs
+6
-9
src/test/compile-fail/regions-nested-fns-2.rs
src/test/compile-fail/regions-nested-fns-2.rs
+1
-1
src/test/compile-fail/regions-nested-fns.rs
src/test/compile-fail/regions-nested-fns.rs
+2
-2
src/test/compile-fail/regions-ref-in-fn-arg.rs
src/test/compile-fail/regions-ref-in-fn-arg.rs
+1
-1
src/test/compile-fail/regions-ret-borrowed-1.rs
src/test/compile-fail/regions-ret-borrowed-1.rs
+1
-1
src/test/compile-fail/regions-ret-borrowed.rs
src/test/compile-fail/regions-ret-borrowed.rs
+1
-1
src/test/compile-fail/regions-return-ref-to-upvar-issue-17403.rs
...t/compile-fail/regions-return-ref-to-upvar-issue-17403.rs
+0
-7
src/test/compile-fail/regions-steal-closure.rs
src/test/compile-fail/regions-steal-closure.rs
+7
-5
src/test/compile-fail/type-arg-out-of-scope.rs
src/test/compile-fail/type-arg-out-of-scope.rs
+1
-1
未找到文件。
src/test/compile-fail/access-mode-in-closures.rs
浏览文件 @
7d5b0454
...
...
@@ -11,7 +11,7 @@
struct
sty
(
Vec
<
int
>
);
fn
unpack
(
_u
npack
:
|
v
:
&
sty
|
->
Vec
<
int
>
)
{}
fn
unpack
<
F
>
(
_u
npack
:
F
)
where
F
:
FnOnce
(
&
sty
)
->
Vec
<
int
>
{}
fn
main
()
{
let
_
foo
=
unpack
(|
s
|
{
...
...
src/test/compile-fail/assign-to-method.rs
浏览文件 @
7d5b0454
...
...
@@ -27,5 +27,5 @@ fn cat(in_x : uint, in_y : int) -> cat {
fn
main
()
{
let
nyan
:
cat
=
cat
(
52u
,
99
);
nyan
.speak
=
||
println!
(
"meow"
);
//~ ERROR attempted to take value of method
nyan
.speak
=
|
&
:
|
println!
(
"meow"
);
//~ ERROR attempted to take value of method
}
src/test/compile-fail/block-coerce-no-2.rs
已删除
100644 → 0
浏览文件 @
ca17d081
// Copyright 2012 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.
// Make sure that fn-to-block coercion isn't incorrectly lifted over
// other tycons.
fn
main
()
{
fn
f
(
f
:
fn
(
fn
(
fn
())))
{
}
fn
g
(
f
:
fn
(||))
{
}
f
(
g
);
//~^ ERROR mismatched types: expected `fn(fn(fn()))`
}
src/test/compile-fail/block-coerce-no.rs
已删除
100644 → 0
浏览文件 @
ca17d081
// Copyright 2012 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.
// Make sure that fn-to-block coercion isn't incorrectly lifted over
// other tycons.
fn
coerce
(
b
:
||)
->
extern
fn
()
{
fn
lol
(
f
:
extern
fn
(
v
:
||)
->
extern
fn
(),
g
:
||)
->
extern
fn
()
{
return
f
(
g
);
}
fn
fn_id
(
f
:
extern
fn
())
->
extern
fn
()
{
return
f
}
return
lol
(
fn_id
,
b
);
//~^ ERROR mismatched types
}
fn
main
()
{
let
i
=
8
i
;
let
f
=
coerce
(||
println!
(
"{}"
,
i
)
);
f
();
}
src/test/compile-fail/borrowck-assign-comp-idx.rs
浏览文件 @
7d5b0454
...
...
@@ -24,7 +24,7 @@ fn a() {
println!
(
"{}"
,
*
q
);
}
fn
borrow
(
_
x
:
&
[
int
],
_
f
:
||
)
{}
fn
borrow
<
F
>
(
_
x
:
&
[
int
],
_
f
:
F
)
where
F
:
FnOnce
(
)
{}
fn
b
()
{
// here we alias the mutable vector into an imm slice and try to
...
...
src/test/compile-fail/borrowck-autoref-3261.rs
浏览文件 @
7d5b0454
...
...
@@ -13,7 +13,7 @@ enum Either<T, U> { Left(T), Right(U) }
struct
X
(
Either
<
(
uint
,
uint
),
fn
()
>
);
impl
X
{
pub
fn
with
(
&
self
,
blk
:
|
x
:
&
Either
<
(
uint
,
uint
),
fn
()
>
|
)
{
pub
fn
with
<
F
>
(
&
self
,
blk
:
F
)
where
F
:
FnOnce
(
&
Either
<
(
uint
,
uint
),
fn
()
>
)
{
let
X
(
ref
e
)
=
*
self
;
blk
(
e
)
}
...
...
@@ -25,7 +25,7 @@ fn main() {
|
opt
|
{
//~ ERROR cannot borrow `x` as mutable more than once at a time
match
opt
{
&
Either
::
Right
(
ref
f
)
=>
{
x
=
X
(
Either
::
Left
((
0
,
0
)));
x
=
X
(
Either
::
Left
((
0
,
0
)));
(
*
f
)()
},
_
=>
panic!
()
...
...
src/test/compile-fail/borrowck-block-unint.rs
浏览文件 @
7d5b0454
...
...
@@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
fn
force
(
f
:
||
)
{
f
();
}
fn
force
<
F
>
(
f
:
F
)
where
F
:
FnOnce
(
)
{
f
();
}
fn
main
()
{
let
x
:
int
;
force
(||
{
//~ ERROR capture of possibly uninitialized variable: `x`
...
...
src/test/compile-fail/borrowck-call-is-borrow-issue-12224.rs
浏览文件 @
7d5b0454
...
...
@@ -10,53 +10,54 @@
// Ensure that invoking a closure counts as a unique immutable borrow
#![feature(unboxed_closures)]
type
Fn
<
'a
>
=
||:
'a
;
type
Fn
<
'a
>
=
Box
<
FnMut
()
+
'a
>
;
struct
Test
<
'a
>
{
f
:
||:
'a
f
:
Box
<
FnMut
()
+
'a
>
}
fn
call
(
f
:
|
Fn
|
)
{
f
(||
{
//~^ ERROR: c
losure requires unique access to `f` but it is already borrowed
f
(||
{})
fn
call
<
F
>
(
mut
f
:
F
)
where
F
:
FnMut
(
Fn
)
{
f
(
box
||
{
//~^ ERROR: c
annot borrow `f` as mutable more than once
f
(
box
||
{})
});
}
fn
test1
()
{
call
(|
a
|
{
a
(
);
call
(|
mut
a
|
{
a
.call_mut
(()
);
});
}
fn
test2
(
f
:
&
||
)
{
(
*
f
)();
//~ ERROR: c
losure invocation in a `&` referenc
e
fn
test2
<
F
>
(
f
:
&
F
)
where
F
:
FnMut
(
)
{
(
*
f
)();
//~ ERROR: c
annot borrow immutable dereference of `&`-pointer `*f` as mutabl
e
}
fn
test3
(
f
:
&
mut
||
)
{
fn
test3
<
F
>
(
f
:
&
mut
F
)
where
F
:
FnMut
(
)
{
(
*
f
)();
}
fn
test4
(
f
:
&
Test
)
{
(
f
.f
)()
//~ ERROR: closure invocation in a `&` referenc
e
f
.f
.call_mut
(())
//~ ERROR: cannot borrow immutable dereference of `Box` `*f.f` as mutabl
e
}
fn
test5
(
f
:
&
mut
Test
)
{
(
f
.f
)(
)
f
.f
.call_mut
(()
)
}
fn
test6
()
{
let
f
=
|
|
{};
(||
{
let
mut
f
=
|
&
mut
:
|
{};
(|
&
mut
:
|
{
f
();
})();
}
fn
test7
()
{
fn
foo
(
_
:
|
g
:
|
int
|,
b
:
int
|
)
{}
let
f
=
|
g
:
|
int
|
,
b
:
int
|
{};
f
(
|
a
|
{
//~ ERROR: cannot borrow `f` as immutable because previous closur
e
fn
foo
<
F
>
(
_
:
F
)
where
F
:
FnMut
(
Box
<
FnMut
(
int
)
>
,
int
)
{}
let
mut
f
=
|
&
mut
:
g
:
Box
<
FnMut
(
int
)
>
,
b
:
int
|
{};
f
(
box
|
a
|
{
//~ ERROR: cannot borrow `f` as immutable because it is also borrowed as mutabl
e
foo
(
f
);
//~ ERROR: cannot move out of captured outer variable
},
3
);
}
...
...
src/test/compile-fail/borrowck-closures-mut-and-imm.rs
浏览文件 @
7d5b0454
...
...
@@ -22,37 +22,37 @@ fn set(x: &mut int) {
fn
a
()
{
let
mut
x
=
3
i
;
let
c1
=
||
x
=
4
;
let
c2
=
||
x
*
5
;
//~ ERROR cannot borrow `x`
let
c1
=
|
&
mut
:
|
x
=
4
;
let
c2
=
|
&
mut
:
|
x
*
5
;
//~ ERROR cannot borrow `x`
}
fn
b
()
{
let
mut
x
=
3
i
;
let
c1
=
||
set
(
&
mut
x
);
let
c2
=
||
get
(
&
x
);
//~ ERROR cannot borrow `x`
let
c1
=
|
&
mut
:
|
set
(
&
mut
x
);
let
c2
=
|
&
mut
:
|
get
(
&
x
);
//~ ERROR cannot borrow `x`
}
fn
c
()
{
let
mut
x
=
3
i
;
let
c1
=
||
set
(
&
mut
x
);
let
c2
=
||
x
*
5
;
//~ ERROR cannot borrow `x`
let
c1
=
|
&
mut
:
|
set
(
&
mut
x
);
let
c2
=
|
&
mut
:
|
x
*
5
;
//~ ERROR cannot borrow `x`
}
fn
d
()
{
let
mut
x
=
3
i
;
let
c2
=
||
x
*
5
;
let
c2
=
|
&
mut
:
|
x
*
5
;
x
=
5
;
//~ ERROR cannot assign
}
fn
e
()
{
let
mut
x
=
3
i
;
let
c1
=
||
get
(
&
x
);
let
c1
=
|
&
mut
:
|
get
(
&
x
);
x
=
5
;
//~ ERROR cannot assign
}
fn
f
()
{
let
mut
x
=
box
3
i
;
let
c1
=
||
get
(
&*
x
);
let
c1
=
|
&
mut
:
|
get
(
&*
x
);
*
x
=
5
;
//~ ERROR cannot assign
}
...
...
@@ -62,7 +62,7 @@ struct Foo {
}
let
mut
x
=
box
Foo
{
f
:
box
3
};
let
c1
=
||
get
(
&*
x
.f
);
let
c1
=
|
&
mut
:
|
get
(
&*
x
.f
);
*
x
.f
=
5
;
//~ ERROR cannot assign to `*x.f`
}
...
...
@@ -72,8 +72,8 @@ struct Foo {
}
let
mut
x
=
box
Foo
{
f
:
box
3
};
let
c1
=
||
get
(
&*
x
.f
);
let
c2
=
||
*
x
.f
=
5
;
//~ ERROR cannot borrow `x` as mutable
let
c1
=
|
&
mut
:
|
get
(
&*
x
.f
);
let
c2
=
|
&
mut
:
|
*
x
.f
=
5
;
//~ ERROR cannot borrow `x` as mutable
}
fn
main
()
{
...
...
src/test/compile-fail/borrowck-closures-mut-of-imm.rs
浏览文件 @
7d5b0454
...
...
@@ -20,9 +20,9 @@ fn set(x: &mut int) {
}
fn
a
(
x
:
&
int
)
{
let
c1
=
||
set
(
&
mut
*
x
);
let
c1
=
|
&
mut
:
|
set
(
&
mut
*
x
);
//~^ ERROR cannot borrow
let
c2
=
||
set
(
&
mut
*
x
);
let
c2
=
|
&
mut
:
|
set
(
&
mut
*
x
);
//~^ ERROR cannot borrow
//~| ERROR closure requires unique access
}
...
...
src/test/compile-fail/borrowck-closures-two-mut.rs
浏览文件 @
7d5b0454
...
...
@@ -15,8 +15,8 @@
fn
a
()
{
let
mut
x
=
3
i
;
let
c1
=
||
x
=
4
;
let
c2
=
||
x
=
5
;
//~ ERROR cannot borrow `x` as mutable more than once
let
c1
=
|
&
mut
:
|
x
=
4
;
let
c2
=
|
&
mut
:
|
x
=
5
;
//~ ERROR cannot borrow `x` as mutable more than once
}
fn
set
(
x
:
&
mut
int
)
{
...
...
@@ -25,20 +25,20 @@ fn set(x: &mut int) {
fn
b
()
{
let
mut
x
=
3
i
;
let
c1
=
||
set
(
&
mut
x
);
let
c2
=
||
set
(
&
mut
x
);
//~ ERROR cannot borrow `x` as mutable more than once
let
c1
=
|
&
mut
:
|
set
(
&
mut
x
);
let
c2
=
|
&
mut
:
|
set
(
&
mut
x
);
//~ ERROR cannot borrow `x` as mutable more than once
}
fn
c
()
{
let
mut
x
=
3
i
;
let
c1
=
||
x
=
5
;
let
c2
=
||
set
(
&
mut
x
);
//~ ERROR cannot borrow `x` as mutable more than once
let
c1
=
|
&
mut
:
|
x
=
5
;
let
c2
=
|
&
mut
:
|
set
(
&
mut
x
);
//~ ERROR cannot borrow `x` as mutable more than once
}
fn
d
()
{
let
mut
x
=
3
i
;
let
c1
=
||
x
=
5
;
let
c2
=
|
|
{
let
_
y
=
|
|
set
(
&
mut
x
);
};
// (nested closure)
let
c1
=
|
&
mut
:
|
x
=
5
;
let
c2
=
|
&
mut
:|
{
let
_
y
=
|
&
mut
:
|
set
(
&
mut
x
);
};
// (nested closure)
//~^ ERROR cannot borrow `x` as mutable more than once
}
...
...
@@ -48,8 +48,8 @@ struct Foo {
}
let
mut
x
=
box
Foo
{
f
:
box
3
};
let
c1
=
||
set
(
&
mut
*
x
.f
);
let
c2
=
||
set
(
&
mut
*
x
.f
);
let
c1
=
|
&
mut
:
|
set
(
&
mut
*
x
.f
);
let
c2
=
|
&
mut
:
|
set
(
&
mut
*
x
.f
);
//~^ ERROR cannot borrow `x` as mutable more than once
}
...
...
src/test/compile-fail/borrowck-closures-unique-imm.rs
浏览文件 @
7d5b0454
...
...
@@ -16,7 +16,7 @@ pub fn main() {
let
mut
this
=
&
mut
Foo
{
x
:
1
,
};
let
r
=
|
|
{
let
mut
r
=
|
&
mut
:
|
{
let
p
=
&
this
.x
;
&
mut
this
.x
;
//~ ERROR cannot borrow
};
...
...
src/test/compile-fail/borrowck-closures-unique.rs
浏览文件 @
7d5b0454
...
...
@@ -23,27 +23,27 @@ fn set(x: &mut int) -> int {
}
fn
a
(
x
:
&
mut
int
)
{
let
c1
=
||
get
(
x
);
let
c2
=
||
get
(
x
);
let
c1
=
|
&
mut
:
|
get
(
x
);
let
c2
=
|
&
mut
:
|
get
(
x
);
}
fn
b
(
x
:
&
mut
int
)
{
let
c1
=
||
get
(
x
);
let
c2
=
||
set
(
x
);
//~ ERROR closure requires unique access to `x`
let
c1
=
|
&
mut
:
|
get
(
x
);
let
c2
=
|
&
mut
:
|
set
(
x
);
//~ ERROR closure requires unique access to `x`
}
fn
c
(
x
:
&
mut
int
)
{
let
c1
=
||
get
(
x
);
let
c2
=
||
{
get
(
x
);
set
(
x
);
};
//~ ERROR closure requires unique access to `x`
let
c1
=
|
&
mut
:
|
get
(
x
);
let
c2
=
|
&
mut
:
|
{
get
(
x
);
set
(
x
);
};
//~ ERROR closure requires unique access to `x`
}
fn
d
(
x
:
&
mut
int
)
{
let
c1
=
||
set
(
x
);
let
c2
=
||
set
(
x
);
//~ ERROR closure requires unique access to `x`
let
c1
=
|
&
mut
:
|
set
(
x
);
let
c2
=
|
&
mut
:
|
set
(
x
);
//~ ERROR closure requires unique access to `x`
}
fn
e
(
x
:
&
mut
int
)
{
let
c1
:
||
=
|
|
x
=
panic!
();
//~ ERROR closure cannot assign to immutable local variable
let
c1
=
|
&
mut
:
|
x
=
panic!
();
//~ ERROR closure cannot assign to immutable local variable
}
fn
main
()
{
...
...
src/test/compile-fail/borrowck-closures-use-after-free.rs
浏览文件 @
7d5b0454
...
...
@@ -25,7 +25,7 @@ fn drop(&mut self) {
fn
main
()
{
let
mut
ptr
=
box
Foo
{
x
:
0
};
let
test
=
|
foo
:
&
Foo
|
{
let
mut
test
=
|
&
mut
:
foo
:
&
Foo
|
{
ptr
=
box
Foo
{
x
:
ptr
.x
+
1
};
};
test
(
&*
ptr
);
//~ ERROR cannot borrow `*ptr`
...
...
src/test/compile-fail/borrowck-init-in-called-fn-expr.rs
浏览文件 @
7d5b0454
...
...
@@ -9,7 +9,7 @@
// except according to those terms.
fn
main
()
{
let
j
:
||
->
int
=
||
{
let
j
=
|
&
:|
->
int
{
let
i
:
int
;
i
//~ ERROR use of possibly uninitialized variable: `i`
};
...
...
src/test/compile-fail/borrowck-init-in-fn-expr.rs
浏览文件 @
7d5b0454
...
...
@@ -9,7 +9,7 @@
// except according to those terms.
fn
main
()
{
let
f
:
||
->
int
=
||
{
let
f
=
|
&
:|
->
int
{
let
i
:
int
;
i
//~ ERROR use of possibly uninitialized variable: `i`
};
...
...
src/test/compile-fail/borrowck-insert-during-each.rs
浏览文件 @
7d5b0454
...
...
@@ -16,7 +16,7 @@ struct Foo {
}
impl
Foo
{
pub
fn
foo
(
&
mut
self
,
fun
:
|
&
int
|
)
{
pub
fn
foo
<
F
>
(
&
mut
self
,
mut
fun
:
F
)
where
F
:
FnMut
(
&
int
)
{
for
f
in
self
.n
.iter
()
{
fun
(
f
);
}
...
...
src/test/compile-fail/borrowck-lend-flow-if.rs
浏览文件 @
7d5b0454
...
...
@@ -18,7 +18,7 @@
fn
borrow
(
_
v
:
&
int
)
{}
fn
borrow_mut
(
_
v
:
&
mut
int
)
{}
fn
cond
()
->
bool
{
panic!
()
}
fn
for_func
(
_
f
:
||
->
bool
)
{
panic!
()
}
fn
for_func
<
F
>
(
_
f
:
F
)
where
F
:
FnOnce
()
->
bool
{
panic!
()
}
fn
produce
<
T
>
()
->
T
{
panic!
();
}
fn
inc
(
v
:
&
mut
Box
<
int
>
)
{
...
...
src/test/compile-fail/borrowck-lend-flow-loop.rs
浏览文件 @
7d5b0454
...
...
@@ -112,7 +112,9 @@ fn while_aliased_mut_cond(cond: bool, cond2: bool) {
}
}
fn
loop_break_pops_scopes
<
'r
>
(
_
v
:
&
'r
mut
[
uint
],
f
:
|
&
'r
mut
uint
|
->
bool
)
{
fn
loop_break_pops_scopes
<
'r
,
F
>
(
_
v
:
&
'r
mut
[
uint
],
mut
f
:
F
)
where
F
:
FnMut
(
&
'r
mut
uint
)
->
bool
,
{
// Here we check that when you break out of an inner loop, the
// borrows that go out of scope as you exit the inner loop are
// removed from the bitset.
...
...
@@ -128,7 +130,7 @@ fn loop_break_pops_scopes<'r>(_v: &'r mut [uint], f: |&'r mut uint| -> bool) {
}
}
fn
loop_loop_pops_scopes
<
'r
>
(
_
v
:
&
'r
mut
[
uint
],
f
:
|
&
'r
mut
uint
|
->
bool
)
{
fn
loop_loop_pops_scopes
<
'r
,
F
>
(
_
v
:
&
'r
mut
[
uint
],
mut
f
:
F
)
where
F
:
FnMut
(
&
'r
mut
uint
)
->
bool
{
// Similar to `loop_break_pops_scopes` but for the `loop` keyword
while
cond
()
{
...
...
src/test/compile-fail/borrowck-lend-flow.rs
浏览文件 @
7d5b0454
...
...
@@ -18,7 +18,7 @@
fn
borrow
(
_
v
:
&
int
)
{}
fn
borrow_mut
(
_
v
:
&
mut
int
)
{}
fn
cond
()
->
bool
{
panic!
()
}
fn
for_func
(
_
f
:
||
->
bool
)
{
panic!
()
}
fn
for_func
<
F
>
(
_
f
:
F
)
where
F
:
FnOnce
()
->
bool
{
panic!
()
}
fn
produce
<
T
>
()
->
T
{
panic!
();
}
fn
inc
(
v
:
&
mut
Box
<
int
>
)
{
...
...
src/test/compile-fail/borrowck-loan-blocks-move-cc.rs
浏览文件 @
7d5b0454
...
...
@@ -10,7 +10,7 @@
use
std
::
thread
::
Thread
;
fn
borrow
(
v
:
&
int
,
f
:
|
x
:
&
int
|
)
{
fn
borrow
<
F
>
(
v
:
&
int
,
f
:
F
)
where
F
:
FnOnce
(
&
int
)
{
f
(
v
);
}
...
...
src/test/compile-fail/borrowck-loan-blocks-mut-uniq.rs
浏览文件 @
7d5b0454
...
...
@@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
fn
borrow
(
v
:
&
int
,
f
:
|
x
:
&
int
|
)
{
fn
borrow
<
F
>
(
v
:
&
int
,
f
:
F
)
where
F
:
FnOnce
(
&
int
)
{
f
(
v
);
}
...
...
src/test/compile-fail/borrowck-loan-rcvr.rs
浏览文件 @
7d5b0454
...
...
@@ -13,14 +13,14 @@ struct point { x: int, y: int }
trait
methods
{
fn
impurem
(
&
self
);
fn
blockm
(
&
self
,
f
:
||
);
fn
blockm
<
F
>
(
&
self
,
f
:
F
)
where
F
:
FnOnce
(
);
}
impl
methods
for
point
{
fn
impurem
(
&
self
)
{
}
fn
blockm
(
&
self
,
f
:
||
)
{
f
()
}
fn
blockm
<
F
>
(
&
self
,
f
:
F
)
where
F
:
FnOnce
(
)
{
f
()
}
}
fn
a
()
{
...
...
src/test/compile-fail/borrowck-loan-vec-content.rs
浏览文件 @
7d5b0454
...
...
@@ -12,7 +12,7 @@
// (locally rooted) mutable, unique vector, and that we then prevent
// modifications to the contents.
fn
takes_imm_elt
(
_
v
:
&
int
,
f
:
||
)
{
fn
takes_imm_elt
<
F
>
(
_
v
:
&
int
,
f
:
F
)
where
F
:
FnOnce
(
)
{
f
();
}
...
...
src/test/compile-fail/borrowck-move-by-capture.rs
浏览文件 @
7d5b0454
...
...
@@ -10,7 +10,7 @@
pub
fn
main
()
{
let
bar
=
box
3
;
let
_
g
=
||
{
let
_
g
=
|
&
mut
:
|
{
let
_
h
=
move
|:|
->
int
{
*
bar
};
//~ ERROR cannot move out of captured outer variable
};
}
src/test/compile-fail/borrowck-move-in-irrefut-pat.rs
浏览文件 @
7d5b0454
...
...
@@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
fn
with
(
f
:
|
&
String
|
)
{}
fn
with
<
F
>
(
f
:
F
)
where
F
:
FnOnce
(
&
String
)
{}
fn
arg_item
(
&
_
x
:
&
String
)
{}
//~^ ERROR cannot move out of dereference of `&`-pointer
...
...
src/test/compile-fail/borrowck-report-with-custom-diagnostic.rs
浏览文件 @
7d5b0454
...
...
@@ -32,7 +32,7 @@ fn foo() {
fn
bar
()
{
// Original borrow ends at end of closure
||
{
|
&
:
|
{
let
mut
x
=
1u
;
let
y
=
&
mut
x
;
let
z
=
&
mut
x
;
//~ ERROR cannot borrow
...
...
src/test/compile-fail/break-outside-loop.rs
浏览文件 @
7d5b0454
...
...
@@ -14,7 +14,7 @@ struct Foo {
fn
cond
()
->
bool
{
true
}
fn
foo
(
_
:
||
)
{}
fn
foo
<
F
>
(
_
:
F
)
where
F
:
FnOnce
(
)
{}
fn
main
()
{
let
pth
=
break
;
//~ ERROR: `break` outside of loop
...
...
src/test/compile-fail/closure-bounds-cant-promote-superkind-in-struct.rs
浏览文件 @
7d5b0454
...
...
@@ -8,12 +8,13 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
struct
X
{
field
:
||:
'static
+
Send
,
struct
X
<
F
>
where
F
:
FnOnce
()
+
'static
+
Send
{
field
:
F
,
}
fn
foo
(
blk
:
||:
'static
)
->
X
{
return
X
{
field
:
blk
};
//~ ERROR expected bounds `Send`
fn
foo
<
F
>
(
blk
:
F
)
->
X
<
F
>
where
F
:
FnOnce
()
+
'static
{
//~^ ERROR the trait `core::kinds::Send` is not implemented for the type
return
X
{
field
:
blk
};
}
fn
main
()
{
...
...
src/test/compile-fail/closure-bounds-not-builtin.rs
已删除
100644 → 0
浏览文件 @
ca17d081
// Copyright 2014 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.
trait
Foo
{}
fn
take
(
f
:
||:
Foo
)
{
//~^ ERROR only the builtin traits can be used as closure or object bounds
}
fn
main
()
{}
src/test/compile-fail/closure-bounds-static-cant-capture-borrowed.rs
浏览文件 @
7d5b0454
...
...
@@ -8,13 +8,12 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
fn
bar
(
blk
:
||:
'static
)
{
fn
bar
<
F
>
(
blk
:
F
)
where
F
:
FnOnce
()
+
'static
{
}
fn
foo
(
x
:
&
())
{
bar
(||
{
//~ ERROR cannot infer an appropriate lifetime
let
_
=
x
;
//~^ ERROR captured variable `x` does not outlive
})
}
...
...
src/test/compile-fail/closure-bounds-subtype.rs
浏览文件 @
7d5b0454
...
...
@@ -9,19 +9,19 @@
// except according to those terms.
fn
take_any
(
_
:
||
)
{
fn
take_any
<
F
>
(
_
:
F
)
where
F
:
FnOnce
(
)
{
}
fn
take_const_owned
(
_
:
||:
Sync
+
Send
)
{
fn
take_const_owned
<
F
>
(
_
:
F
)
where
F
:
FnOnce
()
+
Sync
+
Send
{
}
fn
give_any
(
f
:
||
)
{
fn
give_any
<
F
>
(
f
:
F
)
where
F
:
FnOnce
(
)
{
take_any
(
f
);
}
fn
give_owned
(
f
:
||:
Send
)
{
fn
give_owned
<
F
>
(
f
:
F
)
where
F
:
FnOnce
()
+
Send
{
take_any
(
f
);
take_const_owned
(
f
);
//~ ERROR
expected bounds `Send+Sync`, found bounds `Send`
take_const_owned
(
f
);
//~ ERROR
the trait `core::kinds::Sync` is not implemented for the type
}
fn
main
()
{}
src/test/compile-fail/closure-reform-bad.rs
浏览文件 @
7d5b0454
...
...
@@ -17,7 +17,7 @@ fn call_bare(f: fn(&str)) {
fn
main
()
{
let
string
=
"world!"
;
let
f
:
|
&
str
|
=
|
s
|
println!
(
"{}{}"
,
s
,
string
);
let
f
=
|
&
:
s
:
&
str
|
println!
(
"{}{}"
,
s
,
string
);
call_bare
(
f
)
//~ ERROR mismatched types
}
src/test/compile-fail/closure-that-fails.rs
已删除
100644 → 0
浏览文件 @
ca17d081
// Copyright 2014 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.
fn
foo
(
f
:
||
->
!
)
{}
fn
main
()
{
// Type inference didn't use to be able to handle this:
foo
(||
panic!
());
foo
(||
->
!
panic!
());
foo
(||
22
i
);
//~ ERROR computation may converge in a function marked as diverging
foo
(||
->
!
22
i
);
//~ ERROR computation may converge in a function marked as diverging
let
x
=
||
->
!
1
i
;
//~ ERROR computation may converge in a function marked as diverging
}
src/test/compile-fail/coerce-bare-fn-to-closure-and-proc.rs
已删除
100644 → 0
浏览文件 @
ca17d081
// Copyright 2014 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.
// Test that coercions from fn item types are ok, but not fn pointer
// types to closures/procs are not allowed.
fn
foo
()
{}
fn
fn_item_type
()
{
let
f
=
foo
;
let
f_closure
:
||
=
f
;
}
fn
fn_pointer_type
()
{
let
f
=
foo
as
fn
();
let
f_closure
:
||
=
f
;
//~^ ERROR: mismatched types
}
fn
main
()
{
}
src/test/compile-fail/dead-code-closure-bang.rs
浏览文件 @
7d5b0454
...
...
@@ -8,10 +8,12 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// ignore-test FIXME(#20574)
#![deny(unreachable_code)]
fn
main
()
{
let
x
:
||
->
!
=
|
|
panic!
();
let
x
=
|:
|
panic!
();
x
();
std
::
io
::
println
(
"Foo bar"
);
//~ ERROR: unreachable statement
}
src/test/compile-fail/extern-wrong-value-type.rs
浏览文件 @
7d5b0454
...
...
@@ -11,8 +11,10 @@
extern
fn
f
()
{
}
fn
is_fn
<
F
>
(
_
:
F
)
where
F
:
Fn
()
{}
fn
main
()
{
// extern functions are extern "C" fn
let
_
x
:
extern
"C"
fn
()
=
f
;
// OK
let
_
x
:
||
=
f
;
//~ ERROR mismatched types
is_fn
(
f
);
//~ ERROR the trait `core::ops::Fn()` is not implemented for the type `extern "C" fn()
}
src/test/compile-fail/fn-variance-1.rs
浏览文件 @
7d5b0454
...
...
@@ -12,7 +12,7 @@ fn takes_imm(x: &int) { }
fn
takes_mut
(
x
:
&
mut
int
)
{
}
fn
apply
<
T
>
(
t
:
T
,
f
:
|
T
|
)
{
fn
apply
<
T
,
F
>
(
t
:
T
,
f
:
F
)
where
F
:
FnOnce
(
T
)
{
f
(
t
)
}
...
...
src/test/compile-fail/immut-function-arguments.rs
浏览文件 @
7d5b0454
...
...
@@ -14,7 +14,7 @@ fn f(y: Box<int>) {
}
fn
g
()
{
let
_
frob
:
|
Box
<
int
>
|
=
|
q
|
{
*
q
=
2
;
};
//~ ERROR cannot assign
let
_
frob
=
|
&
:
q
:
Box
<
int
>
|
{
*
q
=
2
;
};
//~ ERROR cannot assign
}
...
...
src/test/compile-fail/issue-10291.rs
浏览文件 @
7d5b0454
...
...
@@ -9,7 +9,7 @@
// except according to those terms.
fn
test
<
'x
>
(
x
:
&
'x
int
)
{
drop
::
<
for
<
'z
>
|
&
'z
int
|
->
&
'z
int
>
(
|
z
|
{
drop
::
<
Box
<
for
<
'z
>
FnMut
(
&
'z
int
)
->
&
'z
int
>>
(
box
|
z
|
{
x
//~^ ERROR cannot infer an appropriate lifetime
});
...
...
src/test/compile-fail/issue-11192.rs
浏览文件 @
7d5b0454
...
...
@@ -20,7 +20,7 @@ fn drop(&mut self) {
fn
main
()
{
let
mut
ptr
=
box
Foo
{
x
:
0
};
let
test
=
|
foo
:
&
Foo
|
{
let
mut
test
=
|
&
mut
:
foo
:
&
Foo
|
{
println!
(
"access {}"
,
foo
.x
);
ptr
=
box
Foo
{
x
:
ptr
.x
+
1
};
println!
(
"access {}"
,
foo
.x
);
...
...
src/test/compile-fail/issue-11873.rs
浏览文件 @
7d5b0454
...
...
@@ -10,7 +10,7 @@
fn
main
()
{
let
mut
v
=
vec!
(
1
i
);
let
f
=
|
|
v
.push
(
2
i
);
let
mut
f
=
|
&
mut
:
|
v
.push
(
2
i
);
let
_
w
=
v
;
//~ ERROR: cannot move out of `v`
f
();
...
...
src/test/compile-fail/issue-14182.rs
浏览文件 @
7d5b0454
...
...
@@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// ignore-test FIXME(japari) remove test
struct
Foo
{
f
:
for
<
'b
>
|
&
'b
int
|:
'b
->
&
'b
int
//~ ERROR use of undeclared lifetime name `'b`
...
...
src/test/compile-fail/issue-16939.rs
浏览文件 @
7d5b0454
...
...
@@ -14,7 +14,7 @@
// wrong arity.
fn
_
foo
<
F
:
Fn
()
>
(
f
:
F
)
{
|
t
|
f
(
t
);
//~ ERROR E0057
|
&
:
t
|
f
(
t
);
//~ ERROR E0057
}
fn
main
()
{}
src/test/compile-fail/issue-17636.rs
已删除
100644 → 0
浏览文件 @
ca17d081
// Copyright 2014 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.
trait
MyItem
<
T
>
{}
impl
<
T
>
MyItem
<
T
>
for
T
{}
pub
fn
build_archive
<
'a
,
I
:
MyItem
<&
'a
(|
&
uint
|:
'a
)
>>
(
files
:
I
)
{}
fn
main
()
{
build_archive
(
&
(|
_
|
{
}));
//~^ ERROR not implemented
}
src/test/compile-fail/issue-17651.rs
浏览文件 @
7d5b0454
...
...
@@ -12,7 +12,7 @@
// and rejected.
fn
main
()
{
(||
box
*
[
0u
]
.as_slice
())();
(|
&
:
|
box
*
[
0u
]
.as_slice
())();
//~^ ERROR cannot move out of dereference
//~^^ ERROR cannot move a value of type [uint]
}
src/test/compile-fail/issue-18343.rs
浏览文件 @
7d5b0454
...
...
@@ -8,12 +8,12 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
struct
Obj
<
'a
>
{
closure
:
||:
'a
->
u32
struct
Obj
<
F
>
where
F
:
FnMut
()
->
u32
{
closure
:
F
,
}
fn
main
()
{
let
o
=
Obj
{
closure
:
||
42
};
o
.closure
();
//~ ERROR
type `Obj<'_>`
does not implement any method in scope named `closure`
o
.closure
();
//~ ERROR does not implement any method in scope named `closure`
//~^ NOTE use `(s.closure)(...)` if you meant to call the function stored in the `closure` field
}
src/test/compile-fail/issue-18345.rs
已删除
100644 → 0
浏览文件 @
ca17d081
// Copyright 2014 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.
type
Step
<
's
,
R
,
T
>
=
|
R
,
T
|:
's
->
R
;
type
Transducer
<
't
,
R
,
T
,
U
>
=
|
Step
<
't
,
R
,
U
>
|:
't
->
Step
<
't
,
R
,
T
>
;
fn
mapping
<
'f
,
R
,
T
,
U
>
(
f
:
|
T
|:
'f
->
U
)
->
&
'f
Transducer
<
'f
,
R
,
T
,
U
>
{
|
step
|
|
r
,
x
|
step
(
r
,
f
(
x
))
//~^ ERROR the type of this value must be known in this context
}
fn
main
()
{}
src/test/compile-fail/issue-18783.rs
浏览文件 @
7d5b0454
...
...
@@ -13,8 +13,8 @@
fn
main
()
{
let
c
=
RefCell
::
new
(
vec!
[]);
let
mut
y
=
1u
;
c
.push
(||
y
=
0
);
c
.push
(||
y
=
0
);
c
.push
(
box
||
y
=
0
);
c
.push
(
box
||
y
=
0
);
//~^ ERROR cannot borrow `y` as mutable more than once at a time
}
...
...
@@ -22,16 +22,16 @@ fn ufcs() {
let
c
=
RefCell
::
new
(
vec!
[]);
let
mut
y
=
1u
;
Push
::
push
(
&
c
,
||
y
=
0
);
Push
::
push
(
&
c
,
||
y
=
0
);
Push
::
push
(
&
c
,
box
||
y
=
0
);
Push
::
push
(
&
c
,
box
||
y
=
0
);
}
trait
Push
<
'c
>
{
fn
push
<
'f
:
'c
>
(
&
self
,
push
:
||:
'f
->
()
);
fn
push
<
'f
:
'c
>
(
&
self
,
push
:
Box
<
FnMut
()
+
'f
>
);
}
impl
<
'c
>
Push
<
'c
>
for
RefCell
<
Vec
<
||:
'c
>>
{
fn
push
<
'f
:
'c
>
(
&
self
,
fun
:
||:
'f
->
()
)
{
impl
<
'c
>
Push
<
'c
>
for
RefCell
<
Vec
<
Box
<
FnMut
()
+
'c
>
>>
{
fn
push
<
'f
:
'c
>
(
&
self
,
fun
:
Box
<
FnMut
()
+
'f
>
)
{
self
.borrow_mut
()
.push
(
fun
)
}
}
src/test/compile-fail/issue-19009.rs
已删除
100644 → 0
浏览文件 @
ca17d081
// Copyright 2014 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.
#![feature(lang_items)]
#![no_std]
#![crate_type=
"rlib"
]
#[lang=
"sized"
]
pub
trait
Sized
for
Sized
?
{}
fn
ice
(
f
:
for
<
's
>
||
:
's
//~ ERROR use of undeclared lifetime name `'s`
)
{}
fn
main
()
{
ice
(||{})
}
src/test/compile-fail/issue-19141.rs
已删除
100644 → 0
浏览文件 @
ca17d081
// Copyright 2014 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.
fn
main
()
{
let
n
=
0u
;
let
f
=
move
||
n
+=
1
;
//~error boxed closures can't capture by value
}
src/test/compile-fail/issue-20193.rs
已删除
100644 → 0
浏览文件 @
ca17d081
// Copyright 2014 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.
fn
foo
(
t
:
&
mut
int
){
println!
(
"{}"
,
t
);
}
fn
main
()
{
let
test
=
10
;
let
h
=
move
||
{
//~error boxed closures can't capture by value
let
mut
r
=
&
mut
test
.clone
();
foo
(
r
);
};
h
();
}
src/test/compile-fail/issue-20228-1.rs
已删除
100644 → 0
浏览文件 @
ca17d081
// Copyright 2014 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.
struct
S
;
impl
S
{
fn
foo
(
&
self
)
{
let
_
=
move
||
{
self
};
//~error boxed closures can't capture by value
}
}
fn
main
()
{
}
src/test/compile-fail/issue-20228-2.rs
已删除
100644 → 0
浏览文件 @
ca17d081
// Copyright 2014 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.
struct
S
;
impl
S
{
fn
foo
(
&
self
)
{
let
_
=
move
||
{
self
.foo
()
};
//~error boxed closures can't capture by value
}
}
fn
main
()
{
}
src/test/compile-fail/issue-2149.rs
浏览文件 @
7d5b0454
...
...
@@ -9,17 +9,17 @@
// except according to those terms.
trait
vec_monad
<
A
>
{
fn
bind
<
B
>
(
&
self
,
f
:
|
A
|
->
Vec
<
B
>
)
;
fn
bind
<
B
,
F
>
(
&
self
,
f
:
F
)
where
F
:
FnMut
(
A
)
->
Vec
<
B
>
;
}
impl
<
A
>
vec_monad
<
A
>
for
Vec
<
A
>
{
fn
bind
<
B
>
(
&
self
,
f
:
|
A
|
->
Vec
<
B
>
)
{
fn
bind
<
B
,
F
>
(
&
self
,
mut
f
:
F
)
where
F
:
FnMut
(
A
)
->
Vec
<
B
>
{
let
mut
r
=
panic!
();
for
elt
in
self
.iter
()
{
r
=
r
+
f
(
*
elt
);
}
//~^ ERROR the type of this value must be known
}
}
fn
main
()
{
[
"hi"
]
.bind
(|
x
|
[
x
]
);
[
"hi"
]
.bind
(|
&
mut
:
x
|
[
x
]
);
//~^ ERROR type `[&str; 1]` does not implement any method in scope named `bind`
}
src/test/compile-fail/issue-3044.rs
浏览文件 @
7d5b0454
...
...
@@ -11,7 +11,7 @@
fn
main
()
{
let
needlesArr
:
Vec
<
char
>
=
vec!
(
'a'
,
'f'
);
needlesArr
.iter
()
.fold
(|
x
,
y
|
{
needlesArr
.iter
()
.fold
(|
&
:
x
,
y
|
{
});
//~^^ ERROR this function takes 2 parameters but 1 parameter was supplied
//
...
...
src/test/compile-fail/issue-3563.rs
浏览文件 @
7d5b0454
...
...
@@ -9,8 +9,9 @@
// except according to those terms.
trait
A
{
fn
a
(
&
self
)
{
||
self
.b
()
//~ ERROR type `&Self` does not implement any method in scope named `b`
}
fn
a
(
&
self
)
{
|
&
:|
self
.b
()
//~ ERROR type `&Self` does not implement any method in scope named `b`
//~^ ERROR expected (), found closure
}
}
fn
main
()
{}
src/test/compile-fail/issue-4335.rs
浏览文件 @
7d5b0454
...
...
@@ -8,13 +8,15 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(unboxed_closures)]
fn
id
<
T
>
(
t
:
T
)
->
T
{
t
}
fn
f
<
'r
,
T
>
(
v
:
&
'r
T
)
->
||:
'r
->
T
{
id
(
|
|
*
v
)
//~ ERROR cannot infer
fn
f
<
'r
,
T
>
(
v
:
&
'r
T
)
->
Box
<
FnMut
()
->
T
+
'r
>
{
id
(
box
|
&
mut
:
|
*
v
)
//~ ERROR cannot infer
}
fn
main
()
{
let
v
=
&
5
i
;
println!
(
"{}"
,
f
(
v
)
(
));
println!
(
"{}"
,
f
(
v
)
.call_mut
(()
));
}
src/test/compile-fail/issue-4523.rs
已删除
100644 → 0
浏览文件 @
ca17d081
// 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.
fn
foopy
()
{}
static
f
:
||:
'static
=
foopy
;
fn
main
()
{
f
();
//~ ERROR closure invocation in a static location
}
src/test/compile-fail/issue-5216.rs
浏览文件 @
7d5b0454
...
...
@@ -9,12 +9,12 @@
// except according to those terms.
fn
f
()
{
}
struct
S
(
||
);
//~ ERROR explicit lifetime bound required
struct
S
(
Box
<
FnMut
()
>
);
//~ ERROR explicit lifetime bound required
pub
static
C
:
S
=
S
(
f
);
fn
g
()
{
}
type
T
=
||
;
//~ ERROR explicit lifetime bound required
type
T
=
Box
<
FnMut
()
>
;
//~ ERROR explicit lifetime bound required
pub
static
D
:
T
=
g
;
fn
main
()
{}
src/test/compile-fail/issue-5239-1.rs
浏览文件 @
7d5b0454
...
...
@@ -11,6 +11,6 @@
// Regression test for issue #5239
fn
main
()
{
let
x
:
|
int
|
->
int
=
|
ref
x
|
{
x
+=
1
;
};
let
x
=
|
&
:
ref
x
:
int
|
->
int
{
x
+=
1
;
};
//~^ ERROR binary assignment operation `+=` cannot be applied to type `&int`
}
src/test/compile-fail/issue-6801.rs
浏览文件 @
7d5b0454
...
...
@@ -17,13 +17,13 @@ fn twice(x: Box<uint>) -> uint {
*
x
*
2
}
fn
invoke
(
f
:
||
->
uint
)
{
fn
invoke
<
F
>
(
f
:
F
)
where
F
:
FnOnce
()
->
uint
{
f
();
}
fn
main
()
{
let
x
:
Box
<
uint
>
=
box
9
;
let
sq
:
||
->
uint
=
|
|
{
*
x
*
*
x
};
let
sq
=
|:
|
{
*
x
*
*
x
};
twice
(
x
);
//~ ERROR: cannot move out of
invoke
(
sq
);
...
...
src/test/compile-fail/issue-7573.rs
浏览文件 @
7d5b0454
...
...
@@ -25,7 +25,7 @@ fn new(s: &str) -> CrateId {
pub
fn
remove_package_from_database
()
{
let
mut
lines_to_use
:
Vec
<&
CrateId
>
=
Vec
::
new
();
let
push_id
=
|
installed_id
:
&
CrateId
|
{
let
push_id
=
|
&
mut
:
installed_id
:
&
CrateId
|
{
lines_to_use
.push
(
installed_id
);
//~^ ERROR cannot infer an appropriate lifetime for automatic coercion due to
// conflicting requirements
...
...
@@ -38,7 +38,7 @@ pub fn remove_package_from_database() {
}
pub
fn
list_database
(
f
:
|
&
CrateId
|
)
{
pub
fn
list_database
<
F
>
(
mut
f
:
F
)
where
F
:
FnMut
(
&
CrateId
)
{
let
stuff
=
[
"foo"
,
"bar"
];
for
l
in
stuff
.iter
()
{
...
...
src/test/compile-fail/kindck-copy.rs
浏览文件 @
7d5b0454
...
...
@@ -57,9 +57,6 @@ fn test<'a,T,U:Copy>(_: &'a int) {
// mutable object types are not ok
assert_copy
::
<&
'a
mut
(
Dummy
+
Copy
)
>
();
//~ ERROR `core::kinds::Copy` is not implemented
// closures are like an `&mut` object
assert_copy
::
<
||
>
();
//~ ERROR `core::kinds::Copy` is not implemented
// unsafe ptrs are ok
assert_copy
::
<*
const
int
>
();
assert_copy
::
<*
const
&
'a
mut
int
>
();
...
...
src/test/compile-fail/kindck-send-object.rs
浏览文件 @
7d5b0454
...
...
@@ -27,14 +27,9 @@ fn box_object_with_no_bound_not_ok<'a>() {
assert_send
::
<
Box
<
Dummy
>>
();
//~ ERROR the trait `core::kinds::Send` is not implemented
}
fn
closure_with_no_bound_not_ok
<
'a
>
()
{
assert_send
::
<
||:
'static
>
();
//~ ERROR the trait `core::kinds::Send` is not implemented
}
fn
object_with_send_bound_ok
()
{
assert_send
::
<&
'static
(
Dummy
+
Send
)
>
();
assert_send
::
<
Box
<
Dummy
+
Send
>>
();
assert_send
::
<
||:
Send
>
;
}
fn
main
()
{
}
src/test/compile-fail/lint-unused-mut-variables.rs
浏览文件 @
7d5b0454
...
...
@@ -35,7 +35,7 @@ fn main() {
_
=>
{}
}
let
x
=
|
mut
y
:
int
|
10
i
;
//~ ERROR: variable does not need to be mutable
let
x
=
|
&
:
mut
y
:
int
|
10
i
;
//~ ERROR: variable does not need to be mutable
fn
what
(
mut
foo
:
int
)
{}
//~ ERROR: variable does not need to be mutable
// positive cases
...
...
@@ -65,7 +65,7 @@ fn what(mut foo: int) {} //~ ERROR: variable does not need to be mutable
_
=>
{}
}
let
x
=
|
mut
y
:
int
|
y
=
32
i
;
let
x
=
|
&
mut
:
mut
y
:
int
|
y
=
32
i
;
fn
nothing
(
mut
foo
:
int
)
{
foo
=
37
i
;
}
// leading underscore should avoid the warning, just like the
...
...
@@ -73,7 +73,7 @@ fn what(mut foo: int) {} //~ ERROR: variable does not need to be mutable
let
mut
_
allowed
=
1
i
;
}
fn
callback
(
f
:
||
)
{}
fn
callback
<
F
>
(
f
:
F
)
where
F
:
FnOnce
(
)
{}
// make sure the lint attribute can be turned off
#[allow(unused_mut)]
...
...
src/test/compile-fail/lint-unused-unsafe.rs
浏览文件 @
7d5b0454
...
...
@@ -20,7 +20,7 @@ mod foo {
}
}
fn
callback
<
T
>
(
_
f
:
||
->
T
)
->
T
{
panic!
()
}
fn
callback
<
T
,
F
>
(
_
f
:
F
)
->
T
where
F
:
FnOnce
(
)
->
T
{
panic!
()
}
unsafe
fn
unsf
()
{}
fn
bad1
()
{
unsafe
{}
}
//~ ERROR: unnecessary `unsafe` block
...
...
src/test/compile-fail/liveness-closure-require-ret.rs
浏览文件 @
7d5b0454
...
...
@@ -8,5 +8,5 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
fn
force
(
f
:
||
->
int
)
->
int
{
f
()
}
fn
force
<
F
>
(
f
:
F
)
->
int
where
F
:
FnOnce
(
)
->
int
{
f
()
}
fn
main
()
{
println!
(
"{}"
,
force
(||
{}));
}
//~ ERROR mismatched types
src/test/compile-fail/moves-based-on-type-block-bad.rs
浏览文件 @
7d5b0454
...
...
@@ -20,7 +20,7 @@ enum E {
Baz
}
fn
f
(
s
:
&
S
,
g
:
|
&
S
|
)
{
fn
f
<
G
>
(
s
:
&
S
,
g
:
G
)
where
G
:
FnOnce
(
&
S
)
{
g
(
s
)
}
...
...
src/test/compile-fail/moves-based-on-type-move-out-of-closure-env-issue-1965.rs
浏览文件 @
7d5b0454
...
...
@@ -14,5 +14,5 @@ fn test(_x: Box<uint>) {}
fn
main
()
{
let
i
=
box
3
;
let
_
f
=
||
test
(
i
);
//~ ERROR cannot move out
let
_
f
=
|
&
:
|
test
(
i
);
//~ ERROR cannot move out
}
src/test/compile-fail/moves-based-on-type-no-recursive-stack-closure.rs
浏览文件 @
7d5b0454
...
...
@@ -12,11 +12,13 @@
// bound must be noncopyable. For details see
// http://smallcultfollowing.com/babysteps/blog/2013/04/30/the-case-of-the-recurring-closure/
#![feature(unboxed_closures)]
struct
R
<
'a
>
{
// This struct is needed to create the
// otherwise infinite type of a fn that
// accepts itself as argument:
c
:
|
&
mut
R
,
bool
|:
'a
c
:
Box
<
FnMut
(
&
mut
R
,
bool
)
+
'a
>
}
fn
innocent_looking_victim
()
{
...
...
@@ -27,8 +29,8 @@ fn innocent_looking_victim() {
}
else
{
match
x
{
Some
(
ref
msg
)
=>
{
(
f
.c
)(
f
,
true
);
//~^ ERROR: cannot borrow `*f` as mutable
becaus
e
f
.c
.call_mut
((
f
,
true
)
);
//~^ ERROR: cannot borrow `*f` as mutable
more than once at a tim
e
println!
(
"{}"
,
msg
);
},
None
=>
panic!
(
"oops"
),
...
...
@@ -37,8 +39,8 @@ fn innocent_looking_victim() {
})
}
fn
conspirator
(
f
:
|
&
mut
R
,
bool
|
)
{
let
mut
r
=
R
{
c
:
f
};
fn
conspirator
<
F
>
(
mut
f
:
F
)
where
F
:
FnMut
(
&
mut
R
,
bool
)
{
let
mut
r
=
R
{
c
:
box
f
};
f
(
&
mut
r
,
false
)
//~ ERROR use of moved value
}
...
...
src/test/compile-fail/pptypedef.rs
浏览文件 @
7d5b0454
...
...
@@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
fn
let_in
<
T
>
(
x
:
T
,
f
:
|
T
|
)
{}
fn
let_in
<
T
,
F
>
(
x
:
T
,
f
:
F
)
where
F
:
FnOnce
(
T
)
{}
fn
main
()
{
let_in
(
3u
,
|
i
|
{
assert
!
(
i
==
3
i
);
});
...
...
src/test/compile-fail/refutable-pattern-in-fn-arg.rs
浏览文件 @
7d5b0454
...
...
@@ -9,7 +9,7 @@
// except according to those terms.
fn
main
()
{
let
f
=
|
3
:
int
|
println!
(
"hello"
);
let
f
=
|
&
:
3
:
int
|
println!
(
"hello"
);
//~^ ERROR refutable pattern in function argument: `_` not covered
f
(
4
);
}
src/test/compile-fail/region-bound-on-closure-outlives-call.rs
浏览文件 @
7d5b0454
...
...
@@ -8,8 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
fn
call_rec
(
f
:
|
uint
|
->
uint
)
->
uint
{
(|
x
|
f
(
x
))(
call_rec
(
f
))
//~ ERROR cannot move out of `f`
fn
call_rec
<
F
>
(
mut
f
:
F
)
->
uint
where
F
:
FnMut
(
uint
)
->
uint
{
(|
&
mut
:
x
|
f
(
x
))(
call_rec
(
f
))
//~ ERROR cannot move out of `f`
}
fn
main
()
{}
...
...
src/test/compile-fail/regionck-closure-lifetimes.rs
已删除
100644 → 0
浏览文件 @
ca17d081
// 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.
fn
env
<
'a
>
(
blk
:
|
p
:
||:
'a
|)
{
// Test that the closure here cannot be assigned
// the lifetime `'a`, which outlives the current
// block.
let
mut
state
=
0
i
;
let
statep
=
&
mut
state
;
blk
(||
*
statep
=
1
i
);
//~ ERROR captured variable `statep` does not outlive
}
fn
no_env_no_for
<
'a
>
(
blk
:
|
p
:
|||:
'a
)
{
// Test that a closure with no free variables CAN
// outlive the block in which it is created.
blk
(||
())
}
fn
repeating_loop
()
{
// Test that the closure cannot be created within `loop` loop and
// called without, even though the state that it closes over is
// external to the loop.
let
closure
;
let
state
=
0
i
;
loop
{
closure
=
||
state
;
//~ ERROR cannot infer
break
;
}
closure
();
}
fn
repeating_while
()
{
// Test that the closure cannot be created within `while` loop and
// called without, even though the state that it closes over is
// external to the loop.
let
closure
;
let
state
=
0
i
;
while
true
{
closure
=
||
state
;
//~ ERROR cannot infer
break
;
}
closure
();
}
fn
main
()
{}
src/test/compile-fail/regions-addr-of-upvar-self.rs
浏览文件 @
7d5b0454
...
...
@@ -16,7 +16,7 @@ struct dog {
impl
dog
{
pub
fn
chase_cat
(
&
mut
self
)
{
let
_
f
=
||
{
let
_
f
=
|
&
:
|
{
let
p
:
&
'static
mut
uint
=
&
mut
self
.food
;
//~ ERROR cannot infer
*
p
=
3u
;
};
...
...
src/test/compile-fail/regions-bounded-by-send.rs
浏览文件 @
7d5b0454
...
...
@@ -69,11 +69,6 @@ fn object_with_send_bound_not_ok<'a>() {
//~^ ERROR declared lifetime bound not satisfied
}
fn
closure_with_lifetime_not_ok
<
'a
>
()
{
assert_send
::
<
||:
'a
>
();
//~^ ERROR not implemented
}
// unsafe pointers are ok unless they point at unsendable things
struct
UniqueUnsafePtr
(
Unique
<*
const
int
>
);
...
...
src/test/compile-fail/regions-creating-enums.rs
浏览文件 @
7d5b0454
...
...
@@ -27,14 +27,14 @@ fn compute(x: &ast) -> uint {
}
}
fn
map_nums
<
'a
,
'b
>
(
x
:
&
ast
,
f
:
|
uint
|
->
uint
)
->
&
'a
ast
<
'b
>
{
fn
map_nums
<
'a
,
'b
,
F
>
(
x
:
&
ast
,
f
:
&
mut
F
)
->
&
'a
ast
<
'b
>
where
F
:
FnMut
(
uint
)
->
uint
{
match
*
x
{
ast
::
num
(
x
)
=>
{
return
&
ast
::
num
(
f
(
x
));
//~ ERROR borrowed value does not live long enough
return
&
ast
::
num
(
(
*
f
)
(
x
));
//~ ERROR borrowed value does not live long enough
}
ast
::
add
(
x
,
y
)
=>
{
let
m_x
=
map_nums
(
x
,
|
z
|
f
(
z
)
);
let
m_y
=
map_nums
(
y
,
|
z
|
f
(
z
)
);
let
m_x
=
map_nums
(
x
,
f
);
let
m_y
=
map_nums
(
y
,
f
);
return
&
ast
::
add
(
m_x
,
m_y
);
//~ ERROR borrowed value does not live long enough
}
}
...
...
src/test/compile-fail/regions-escape-bound-fn-2.rs
浏览文件 @
7d5b0454
...
...
@@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
fn
with_int
(
f
:
|
x
:
&
int
|
)
{
fn
with_int
<
F
>
(
f
:
F
)
where
F
:
FnOnce
(
&
int
)
{
let
x
=
3
;
f
(
&
x
);
}
...
...
src/test/compile-fail/regions-escape-bound-fn.rs
浏览文件 @
7d5b0454
...
...
@@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
fn
with_int
(
f
:
|
x
:
&
int
|
)
{
fn
with_int
<
F
>
(
f
:
F
)
where
F
:
FnOnce
(
&
int
)
{
let
x
=
3
;
f
(
&
x
);
}
...
...
src/test/compile-fail/regions-escape-method.rs
浏览文件 @
7d5b0454
...
...
@@ -16,7 +16,7 @@
struct
S
;
impl
S
{
fn
f
<
B
>
(
&
self
,
_
:
|
&
i32
|
->
B
)
{
fn
f
<
B
,
F
>
(
&
self
,
_
:
F
)
where
F
:
FnOnce
(
&
i32
)
->
B
{
}
}
...
...
src/test/compile-fail/regions-escape-via-trait-or-not.rs
浏览文件 @
7d5b0454
...
...
@@ -20,7 +20,7 @@ fn get(self) -> int {
}
}
fn
with
<
R
:
Deref
>
(
f
:
|
x
:
&
int
|
->
R
)
->
int
{
fn
with
<
R
:
Deref
,
F
>
(
f
:
F
)
->
int
where
F
:
FnOnce
(
&
int
)
->
R
{
f
(
&
3
)
.get
()
}
...
...
src/test/compile-fail/regions-fn-subtyping.rs
已删除
100644 → 0
浏览文件 @
ca17d081
// Copyright 2012 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.
fn
of
<
'a
,
T
>
()
->
|
T
|:
'a
{
panic!
();
}
fn
subtype
<
T
>
(
x
:
|
T
|)
{
panic!
();
}
fn
test_fn
<
'x
,
'y
,
'z
,
T
>
(
_
x
:
&
'x
T
,
_
y
:
&
'y
T
,
_
z
:
&
'z
T
)
{
// Here, x, y, and z are free. Other letters
// are bound. Note that the arrangement
// subtype::<T1>(of::<T2>()) will typecheck
// iff T1 <: T2.
subtype
::
<
for
<
'a
>
|
&
'a
T
|
>
(
of
::
<
for
<
'a
>
|
&
'a
T
|
>
());
subtype
::
<
for
<
'a
>
|
&
'a
T
|
>
(
of
::
<
for
<
'b
>
|
&
'b
T
|
>
());
subtype
::
<
for
<
'b
>
|
&
'b
T
|
>
(
of
::
<
|
&
'x
T
|
>
());
subtype
::
<
|
&
'x
T
|
>
(
of
::
<
for
<
'b
>
|
&
'b
T
|
>
());
//~ ERROR mismatched types
subtype
::
<
for
<
'a
,
'b
>
|
&
'a
T
,
&
'b
T
|
>
(
of
::
<
for
<
'a
>
|
&
'a
T
,
&
'a
T
|
>
());
subtype
::
<
for
<
'a
>
|
&
'a
T
,
&
'a
T
|
>
(
of
::
<
for
<
'a
,
'b
>
|
&
'a
T
,
&
'b
T
|
>
());
//~ ERROR mismatched types
subtype
::
<
for
<
'a
,
'b
>
|
&
'a
T
,
&
'b
T
|
>
(
of
::
<
|
&
'x
T
,
&
'y
T
|
>
());
subtype
::
<
|
&
'x
T
,
&
'y
T
|
>
(
of
::
<
for
<
'a
,
'b
>
|
&
'a
T
,
&
'b
T
|
>
());
//~ ERROR mismatched types
}
fn
main
()
{}
src/test/compile-fail/regions-fns.rs
已删除
100644 → 0
浏览文件 @
ca17d081
// Copyright 2012 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.
// Before fn subtyping was properly implemented,
// we reported errors in this case:
fn
not_ok
<
'b
>
(
a
:
&
uint
,
b
:
&
'b
uint
)
{
let
mut
g
:
|
x
:
&
uint
|
=
|
x
:
&
'b
uint
|
{};
//~^ ERROR mismatched types
g
(
a
);
}
fn
main
()
{
}
src/test/compile-fail/regions-free-region-ordering-callee.rs
浏览文件 @
7d5b0454
...
...
@@ -30,7 +30,7 @@ fn ordering3<'a, 'b>(x: &'a uint, y: &'b uint) -> &'a &'b uint {
panic!
();
}
fn
ordering4
<
'a
,
'b
>
(
a
:
&
'a
uint
,
b
:
&
'b
uint
,
x
:
|
&
'a
&
'b
uint
|
)
{
fn
ordering4
<
'a
,
'b
,
F
>
(
a
:
&
'a
uint
,
b
:
&
'b
uint
,
x
:
F
)
where
F
:
FnOnce
(
&
'a
&
'b
uint
)
{
// Do not infer ordering from closure argument types.
let
z
:
Option
<&
'a
&
'b
uint
>
=
None
;
//~^ ERROR reference has a longer lifetime than the data it references
...
...
src/test/compile-fail/regions-freevar.rs
已删除
100644 → 0
浏览文件 @
ca17d081
// Copyright 2012 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.
fn
wants_static_fn
(
_
x
:
||:
'static
)
{}
fn
main
()
{
let
i
=
3
i
;
wants_static_fn
(||
{
println!
(
"i={}"
,
i
);
//~ ERROR captured variable `i` does not outlive
})
}
src/test/compile-fail/regions-infer-at-fn-not-param.rs
浏览文件 @
7d5b0454
...
...
@@ -9,15 +9,15 @@
// except according to those terms.
struct
parameterized1
<
'a
>
{
g
:
||:
'a
g
:
Box
<
FnMut
()
+
'a
>
}
struct
not_parameterized1
{
g
:
||:
'static
g
:
Box
<
FnMut
()
+
'static
>
}
struct
not_parameterized2
{
g
:
||:
'static
g
:
Box
<
FnMut
()
+
'static
>
}
fn
take1
<
'a
>
(
p
:
parameterized1
)
->
parameterized1
<
'a
>
{
p
}
...
...
src/test/compile-fail/regions-infer-borrow-scope-within-loop.rs
浏览文件 @
7d5b0454
...
...
@@ -11,7 +11,10 @@
fn
borrow
<
T
>
(
x
:
&
T
)
->
&
T
{
x
}
fn
foo
(
cond
:
||
->
bool
,
make_box
:
||
->
Box
<
int
>
)
{
fn
foo
<
C
,
M
>
(
mut
cond
:
C
,
mut
make_box
:
M
)
where
C
:
FnMut
()
->
bool
,
M
:
FnMut
()
->
Box
<
int
>
,
{
let
mut
y
:
&
int
;
loop
{
let
x
=
make_box
();
...
...
src/test/compile-fail/regions-infer-call-3.rs
浏览文件 @
7d5b0454
...
...
@@ -10,7 +10,7 @@
fn
select
<
'r
>
(
x
:
&
'r
int
,
y
:
&
'r
int
)
->
&
'r
int
{
x
}
fn
with
<
T
>
(
f
:
|
x
:
&
int
|
->
T
)
->
T
{
fn
with
<
T
,
F
>
(
f
:
F
)
->
T
where
F
:
FnOnce
(
&
int
)
->
T
{
f
(
&
20
)
}
...
...
src/test/compile-fail/regions-infer-invariance-due-to-mutability-3.rs
浏览文件 @
7d5b0454
...
...
@@ -10,7 +10,7 @@
struct
invariant
<
'a
>
{
f
:
|
x
:
&
mut
&
'a
int
|:
'static
f
:
Box
<
FnOnce
(
&
mut
&
'a
int
)
+
'static
>
,
}
fn
to_same_lifetime
<
'r
>
(
bi
:
invariant
<
'r
>
)
{
...
...
src/test/compile-fail/regions-infer-invariance-due-to-mutability-4.rs
浏览文件 @
7d5b0454
...
...
@@ -10,7 +10,7 @@
struct
invariant
<
'a
>
{
f
:
||:
'static
->
&
mut
&
'a
int
f
:
Box
<
for
<
'b
>
FnOnce
()
->
&
'b
mut
&
'a
int
+
'static
>
,
}
fn
to_same_lifetime
<
'r
>
(
bi
:
invariant
<
'r
>
)
{
...
...
src/test/compile-fail/regions-infer-not-param.rs
浏览文件 @
7d5b0454
...
...
@@ -14,12 +14,12 @@ struct direct<'a> {
struct
indirect1
{
// Here the lifetime parameter of direct is bound by the fn()
g
:
|
direct
|:
'static
g
:
Box
<
FnOnce
(
direct
)
+
'static
>
}
struct
indirect2
<
'a
>
{
// But here it is set to 'a
g
:
|
direct
<
'a
>
|:
'static
g
:
Box
<
FnOnce
(
direct
<
'a
>
)
+
'static
>
}
fn
take_direct
<
'a
,
'b
>
(
p
:
direct
<
'a
>
)
->
direct
<
'b
>
{
p
}
//~ ERROR mismatched types
...
...
src/test/compile-fail/regions-name-undeclared.rs
浏览文件 @
7d5b0454
...
...
@@ -43,19 +43,16 @@ fn f(a: &'a int) { } //~ ERROR undeclared lifetime
// &'a CAN be declared on functions and used then:
fn
g
<
'a
>
(
a
:
&
'a
int
)
{
}
// OK
fn
h
(
a
:
for
<
'a
>
|
&
'a
int
|)
{
}
// OK
// But not in the bound of a closure, it's not in scope *there*
fn
i
(
a
:
for
<
'a
>
|
&
int
|:
'a
)
{
}
//~ ERROR undeclared lifetime
fn
h
(
a
:
Box
<
for
<
'a
>
FnOnce
(
&
'a
int
)
>
)
{
}
// OK
}
// Test nesting of lifetimes in fn type declarations
fn
fn_types
(
a
:
&
'a
int
,
//~ ERROR undeclared lifetime
b
:
for
<
'a
>
|
a
:
&
'a
int
,
b
:
&
'b
int
,
//~ ERROR undeclared lifetime
c
:
for
<
'b
>
|
a
:
&
'a
int
,
b
:
&
'b
int
|
,
d
:
&
'b
int
|
,
//~ ERROR undeclared lifetime
b
:
Box
<
for
<
'a
>
FnOnce
(
&
'a
int
,
&
'b
int
,
//~ ERROR undeclared lifetime
Box
<
for
<
'b
>
FnOnce
(
&
'a
int
,
&
'b
int
)
>
,
&
'b
int
)
>
,
//~ ERROR undeclared lifetime
c
:
&
'a
int
)
//~ ERROR undeclared lifetime
{
}
...
...
src/test/compile-fail/regions-nested-fns-2.rs
浏览文件 @
7d5b0454
...
...
@@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
fn
ignore
(
_
f
:
for
<
'z
>
|
&
'z
int
|
->
&
'z
int
)
{}
fn
ignore
<
F
>
(
_
f
:
F
)
where
F
:
for
<
'z
>
FnOnce
(
&
'z
int
)
->
&
'z
int
{}
fn
nested
()
{
let
y
=
3
;
...
...
src/test/compile-fail/regions-nested-fns.rs
浏览文件 @
7d5b0454
...
...
@@ -14,13 +14,13 @@ fn nested<'x>(x: &'x int) {
let
y
=
3
;
let
mut
ay
=
&
y
;
ignore
::
<
for
<
'z
>
|
&
'z
int
|
>
(
|
z
|
{
ignore
::
<
Box
<
for
<
'z
>
FnMut
(
&
'z
int
)
>>
(
box
|
z
|
{
ay
=
x
;
//~ ERROR cannot infer
ay
=
&
y
;
ay
=
z
;
});
ignore
::
<
for
<
'z
>
|
&
'z
int
|
->
&
'z
int
>
(
|
z
|
{
ignore
::
<
Box
<
for
<
'z
>
FnMut
(
&
'z
int
)
->
&
'z
int
>>
(
box
|
z
|
{
if
false
{
return
x
;
}
//~ ERROR cannot infer an appropriate lifetime for automatic
if
false
{
return
ay
;
}
return
z
;
...
...
src/test/compile-fail/regions-ref-in-fn-arg.rs
浏览文件 @
7d5b0454
...
...
@@ -13,7 +13,7 @@ fn arg_item(box ref x: Box<int>) -> &'static int {
x
//~^ ERROR borrowed value does not live long enough
}
fn
with
<
R
>
(
f
:
|
Box
<
int
>
|
->
R
)
->
R
{
f
(
box
3
)
}
fn
with
<
R
,
F
>
(
f
:
F
)
->
R
where
F
:
FnOnce
(
Box
<
int
>
)
->
R
{
f
(
box
3
)
}
fn
arg_closure
()
->
&
'static
int
{
with
(|
box
ref
x
|
x
)
//~ ERROR borrowed value does not live long enough
...
...
src/test/compile-fail/regions-ret-borrowed-1.rs
浏览文件 @
7d5b0454
...
...
@@ -12,7 +12,7 @@
// some point regions-ret-borrowed reported an error but this file did
// not, due to special hardcoding around the anonymous region.
fn
with
<
R
>
(
f
:
for
<
'a
>
|
x
:
&
'a
int
|
->
R
)
->
R
{
fn
with
<
R
,
F
>
(
f
:
F
)
->
R
where
F
:
for
<
'a
>
FnOnce
(
&
'a
int
)
->
R
{
f
(
&
3
)
}
...
...
src/test/compile-fail/regions-ret-borrowed.rs
浏览文件 @
7d5b0454
...
...
@@ -15,7 +15,7 @@
// used to successfully compile because we failed to account for the
// fact that fn(x: &int) rebound the region &.
fn
with
<
R
>
(
f
:
|
x
:
&
int
|
->
R
)
->
R
{
fn
with
<
R
,
F
>
(
f
:
F
)
->
R
where
F
:
FnOnce
(
&
int
)
->
R
{
f
(
&
3
)
}
...
...
src/test/compile-fail/regions-return-ref-to-upvar-issue-17403.rs
浏览文件 @
7d5b0454
...
...
@@ -20,11 +20,4 @@ fn main() {
let
x
=
f
();
let
y
=
f
();
}
// Boxed closure case
{
let
mut
x
=
0u
;
let
f
=
||
&
mut
x
;
//~ ERROR cannot infer
let
x
=
f
();
let
y
=
f
();
}
}
src/test/compile-fail/regions-steal-closure.rs
浏览文件 @
7d5b0454
...
...
@@ -8,18 +8,20 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(unboxed_closures)]
struct
closure_box
<
'a
>
{
cl
:
||:
'a
cl
:
Box
<
FnMut
()
+
'a
>
,
}
fn
box_it
<
'r
>
(
x
:
||:
'r
)
->
closure_box
<
'r
>
{
fn
box_it
<
'r
>
(
x
:
Box
<
FnMut
()
+
'r
>
)
->
closure_box
<
'r
>
{
closure_box
{
cl
:
x
}
}
fn
main
()
{
let
cl_box
=
{
let
mut
i
=
3
;
box_it
(||
i
+=
1
)
//~ ERROR cannot infer
let
mut
i
=
3
i
;
box_it
(
box
||
i
+=
1
)
//~ ERROR cannot infer
};
(
cl_box
.cl
)(
);
cl_box
.cl
.call_mut
(()
);
}
src/test/compile-fail/type-arg-out-of-scope.rs
浏览文件 @
7d5b0454
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录