Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
fa43f6a7
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,发现更多精彩内容 >>
提交
fa43f6a7
编写于
4月 17, 2014
作者:
F
Flavio Percoco
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Update tests and move other tests around
上级
bea94993
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
283 addition
and
1 deletion
+283
-1
src/test/compile-fail/borrowck-managed-pointer-deref-scope.rs
...test/compile-fail/borrowck-managed-pointer-deref-scope.rs
+33
-0
src/test/compile-fail/regions-infer-borrow-scope-too-big.rs
src/test/compile-fail/regions-infer-borrow-scope-too-big.rs
+28
-0
src/test/compile-fail/regions-infer-borrow-scope-within-loop.rs
...st/compile-fail/regions-infer-borrow-scope-within-loop.rs
+30
-0
src/test/compile-fail/struct-field-assignability.rs
src/test/compile-fail/struct-field-assignability.rs
+1
-1
src/test/run-pass/borrowck-preserve-box-in-field.rs
src/test/run-pass/borrowck-preserve-box-in-field.rs
+37
-0
src/test/run-pass/borrowck-preserve-box-in-uniq.rs
src/test/run-pass/borrowck-preserve-box-in-uniq.rs
+37
-0
src/test/run-pass/borrowck-preserve-box.rs
src/test/run-pass/borrowck-preserve-box.rs
+35
-0
src/test/run-pass/borrowck-preserve-cond-box.rs
src/test/run-pass/borrowck-preserve-cond-box.rs
+45
-0
src/test/run-pass/borrowck-preserve-expl-deref.rs
src/test/run-pass/borrowck-preserve-expl-deref.rs
+37
-0
未找到文件。
src/test/compile-fail/borrowck-managed-pointer-deref-scope.rs
0 → 100644
浏览文件 @
fa43f6a7
// 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.
// Verify that managed pointers scope is treated like ownoed pointers.
// regresion test for #11586
#![feature(managed_boxes)]
fn
foo
<
'a
>
(
x
:
&
'a
@
int
)
->
&
'a
int
{
match
x
{
&
ref
y
=>
{
&**
y
// Do not expect an error here
}
}
}
fn
bar
()
{
let
a
=
3
;
let
mut
y
=
&
a
;
if
true
{
let
x
=
@
3
;
y
=
&*
x
;
//~ ERROR `*x` does not live long enough
}
}
fn
main
()
{}
src/test/compile-fail/regions-infer-borrow-scope-too-big.rs
0 → 100644
浏览文件 @
fa43f6a7
// 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.
#![feature(managed_boxes)]
struct
point
{
x
:
int
,
y
:
int
,
}
fn
x_coord
<
'r
>
(
p
:
&
'r
point
)
->
&
'r
int
{
return
&
p
.x
;
}
fn
foo
(
p
:
@
point
)
->
&
int
{
let
xc
=
x_coord
(
p
);
//~ ERROR `*p` does not live long enough
assert_eq!
(
*
xc
,
3
);
return
xc
;
}
fn
main
()
{}
src/test/compile-fail/regions-infer-borrow-scope-within-loop.rs
0 → 100644
浏览文件 @
fa43f6a7
// 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.
#![feature(managed_boxes)]
fn
borrow
<
'r
,
T
>
(
x
:
&
'r
T
)
->
&
'r
T
{
x
}
fn
foo
(
cond
:
||
->
bool
,
make_box
:
||
->
@
int
)
{
let
mut
y
:
&
int
;
loop
{
let
x
=
make_box
();
// Here we complain because the resulting region
// of this borrow is the fn body as a whole.
y
=
borrow
(
x
);
//~ ERROR `*x` does not live long enough
assert_eq!
(
*
x
,
*
y
);
if
cond
()
{
break
;
}
}
assert
!
(
*
y
!=
0
);
}
fn
main
()
{}
src/test/
run-pass
/struct-field-assignability.rs
→
src/test/
compile-fail
/struct-field-assignability.rs
浏览文件 @
fa43f6a7
...
...
@@ -15,6 +15,6 @@ struct Foo<'a> {
}
pub
fn
main
()
{
let
f
=
Foo
{
x
:
@
3
};
let
f
=
Foo
{
x
:
@
3
};
//~ ERROR borrowed value does not live long enough
assert_eq!
(
*
f
.x
,
3
);
}
src/test/run-pass/borrowck-preserve-box-in-field.rs
0 → 100644
浏览文件 @
fa43f6a7
// ignore-pretty
// Copyright 2012-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.
// exec-env:RUST_POISON_ON_FREE=1
#![feature(managed_boxes)]
fn
borrow
(
x
:
&
int
,
f
:
|
x
:
&
int
|)
{
let
before
=
*
x
;
f
(
x
);
let
after
=
*
x
;
assert_eq!
(
before
,
after
);
}
struct
F
{
f
:
~
int
}
pub
fn
main
()
{
let
mut
x
=
@
F
{
f
:
~
3
};
borrow
(
x
.f
,
|
b_x
|
{
assert_eq!
(
*
b_x
,
3
);
assert_eq!
(
&
(
*
x
.f
)
as
*
int
,
&
(
*
b_x
)
as
*
int
);
x
=
@
F
{
f
:
~
4
};
println!
(
"&*b_x = {:p}"
,
&
(
*
b_x
));
assert_eq!
(
*
b_x
,
3
);
assert
!
(
&
(
*
x
.f
)
as
*
int
!=
&
(
*
b_x
)
as
*
int
);
})
}
src/test/run-pass/borrowck-preserve-box-in-uniq.rs
0 → 100644
浏览文件 @
fa43f6a7
// ignore-pretty
// Copyright 2012-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.
// exec-env:RUST_POISON_ON_FREE=1
#![feature(managed_boxes)]
fn
borrow
(
x
:
&
int
,
f
:
|
x
:
&
int
|)
{
let
before
=
*
x
;
f
(
x
);
let
after
=
*
x
;
assert_eq!
(
before
,
after
);
}
struct
F
{
f
:
~
int
}
pub
fn
main
()
{
let
mut
x
=
~@
F
{
f
:
~
3
};
borrow
(
x
.f
,
|
b_x
|
{
assert_eq!
(
*
b_x
,
3
);
assert_eq!
(
&
(
*
x
.f
)
as
*
int
,
&
(
*
b_x
)
as
*
int
);
*
x
=
@
F
{
f
:
~
4
};
println!
(
"&*b_x = {:p}"
,
&
(
*
b_x
));
assert_eq!
(
*
b_x
,
3
);
assert
!
(
&
(
*
x
.f
)
as
*
int
!=
&
(
*
b_x
)
as
*
int
);
})
}
src/test/run-pass/borrowck-preserve-box.rs
0 → 100644
浏览文件 @
fa43f6a7
// ignore-pretty
// Copyright 2012-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.
// exec-env:RUST_POISON_ON_FREE=1
#![feature(managed_boxes)]
fn
borrow
(
x
:
&
int
,
f
:
|
x
:
&
int
|)
{
let
before
=
*
x
;
f
(
x
);
let
after
=
*
x
;
assert_eq!
(
before
,
after
);
}
pub
fn
main
()
{
let
mut
x
=
@
3
;
borrow
(
x
,
|
b_x
|
{
assert_eq!
(
*
b_x
,
3
);
assert_eq!
(
&
(
*
x
)
as
*
int
,
&
(
*
b_x
)
as
*
int
);
x
=
@
22
;
println!
(
"&*b_x = {:p}"
,
&
(
*
b_x
));
assert_eq!
(
*
b_x
,
3
);
assert
!
(
&
(
*
x
)
as
*
int
!=
&
(
*
b_x
)
as
*
int
);
})
}
src/test/run-pass/borrowck-preserve-cond-box.rs
0 → 100644
浏览文件 @
fa43f6a7
// 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.
// exec-env:RUST_POISON_ON_FREE=1
#![feature(managed_boxes)]
fn
testfn
(
cond
:
bool
)
{
let
mut
x
=
@
3
;
let
mut
y
=
@
4
;
// borrow x and y
let
r_x
=
&*
x
;
let
r_y
=
&*
y
;
let
mut
r
=
r_x
;
let
mut
exp
=
3
;
if
cond
{
r
=
r_y
;
exp
=
4
;
}
println!
(
"*r = {}, exp = {}"
,
*
r
,
exp
);
assert_eq!
(
*
r
,
exp
);
x
=
@
5
;
y
=
@
6
;
println!
(
"*r = {}, exp = {}"
,
*
r
,
exp
);
assert_eq!
(
*
r
,
exp
);
assert_eq!
(
x
,
@
5
);
assert_eq!
(
y
,
@
6
);
}
pub
fn
main
()
{
testfn
(
true
);
testfn
(
false
);
}
src/test/run-pass/borrowck-preserve-expl-deref.rs
0 → 100644
浏览文件 @
fa43f6a7
// ignore-pretty
// Copyright 2012-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.
// exec-env:RUST_POISON_ON_FREE=1
#![feature(managed_boxes)]
fn
borrow
(
x
:
&
int
,
f
:
|
x
:
&
int
|)
{
let
before
=
*
x
;
f
(
x
);
let
after
=
*
x
;
assert_eq!
(
before
,
after
);
}
struct
F
{
f
:
~
int
}
pub
fn
main
()
{
let
mut
x
=
@
F
{
f
:
~
3
};
borrow
((
*
x
)
.f
,
|
b_x
|
{
assert_eq!
(
*
b_x
,
3
);
assert_eq!
(
&
(
*
x
.f
)
as
*
int
,
&
(
*
b_x
)
as
*
int
);
x
=
@
F
{
f
:
~
4
};
println!
(
"&*b_x = {:p}"
,
&
(
*
b_x
));
assert_eq!
(
*
b_x
,
3
);
assert
!
(
&
(
*
x
.f
)
as
*
int
!=
&
(
*
b_x
)
as
*
int
);
})
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录