Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
6d4907a7
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,发现更多精彩内容 >>
提交
6d4907a7
编写于
1月 25, 2013
作者:
T
Tim Chevalier
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
testsuite: Eliminate uses of structural records from most run-pass tests
Except the pipes tests (that needs a snapshot)
上级
413be829
变更
119
展开全部
隐藏空白更改
内联
并排
Showing
119 changed file
with
600 addition
and
432 deletion
+600
-432
src/test/auxiliary/cci_nested_lib.rs
src/test/auxiliary/cci_nested_lib.rs
+4
-3
src/test/auxiliary/crateresolve5-1.rs
src/test/auxiliary/crateresolve5-1.rs
+4
-2
src/test/auxiliary/crateresolve5-2.rs
src/test/auxiliary/crateresolve5-2.rs
+3
-2
src/test/run-pass/alias-uninit-value.rs
src/test/run-pass/alias-uninit-value.rs
+3
-3
src/test/run-pass/alignment-gep-tup-like-2.rs
src/test/run-pass/alignment-gep-tup-like-2.rs
+7
-7
src/test/run-pass/alloca-from-derived-tydesc.rs
src/test/run-pass/alloca-from-derived-tydesc.rs
+2
-2
src/test/run-pass/alt-implicit-copy-unique.rs
src/test/run-pass/alt-implicit-copy-unique.rs
+4
-2
src/test/run-pass/alt-naked-record-expr.rs
src/test/run-pass/alt-naked-record-expr.rs
+3
-1
src/test/run-pass/alt-naked-record.rs
src/test/run-pass/alt-naked-record.rs
+3
-1
src/test/run-pass/alt-ref-binding-mut.rs
src/test/run-pass/alt-ref-binding-mut.rs
+5
-5
src/test/run-pass/argument-passing.rs
src/test/run-pass/argument-passing.rs
+4
-2
src/test/run-pass/auto-instantiate.rs
src/test/run-pass/auto-instantiate.rs
+6
-2
src/test/run-pass/borrowck-binding-mutbl.rs
src/test/run-pass/borrowck-binding-mutbl.rs
+4
-2
src/test/run-pass/borrowck-mut-uniq.rs
src/test/run-pass/borrowck-mut-uniq.rs
+4
-4
src/test/run-pass/borrowck-preserve-box-in-discr.rs
src/test/run-pass/borrowck-preserve-box-in-discr.rs
+5
-3
src/test/run-pass/borrowck-preserve-box-in-field.rs
src/test/run-pass/borrowck-preserve-box-in-field.rs
+4
-2
src/test/run-pass/borrowck-preserve-box-in-pat.rs
src/test/run-pass/borrowck-preserve-box-in-pat.rs
+5
-3
src/test/run-pass/borrowck-preserve-box-in-uniq.rs
src/test/run-pass/borrowck-preserve-box-in-uniq.rs
+4
-2
src/test/run-pass/borrowck-preserve-expl-deref.rs
src/test/run-pass/borrowck-preserve-expl-deref.rs
+4
-2
src/test/run-pass/borrowck-root-while-cond-2.rs
src/test/run-pass/borrowck-root-while-cond-2.rs
+4
-1
src/test/run-pass/borrowck-root-while-cond.rs
src/test/run-pass/borrowck-root-while-cond.rs
+3
-1
src/test/run-pass/box-pattern.rs
src/test/run-pass/box-pattern.rs
+4
-4
src/test/run-pass/box-unbox.rs
src/test/run-pass/box-unbox.rs
+3
-3
src/test/run-pass/const-bound.rs
src/test/run-pass/const-bound.rs
+3
-1
src/test/run-pass/const-fields-and-indexing.rs
src/test/run-pass/const-fields-and-indexing.rs
+8
-3
src/test/run-pass/const-rec-and-tup.rs
src/test/run-pass/const-rec-and-tup.rs
+8
-6
src/test/run-pass/const-region-ptrs.rs
src/test/run-pass/const-region-ptrs.rs
+3
-1
src/test/run-pass/crateresolve5.rs
src/test/run-pass/crateresolve5.rs
+2
-2
src/test/run-pass/early-vtbl-resolution.rs
src/test/run-pass/early-vtbl-resolution.rs
+3
-1
src/test/run-pass/explicit-self-generic.rs
src/test/run-pass/explicit-self-generic.rs
+4
-4
src/test/run-pass/explicit-self.rs
src/test/run-pass/explicit-self.rs
+13
-11
src/test/run-pass/expr-alt-generic.rs
src/test/run-pass/expr-alt-generic.rs
+3
-3
src/test/run-pass/expr-alt-struct.rs
src/test/run-pass/expr-alt-struct.rs
+4
-2
src/test/run-pass/expr-block-generic.rs
src/test/run-pass/expr-block-generic.rs
+3
-3
src/test/run-pass/expr-block-slot.rs
src/test/run-pass/expr-block-slot.rs
+6
-2
src/test/run-pass/expr-block.rs
src/test/run-pass/expr-block.rs
+3
-1
src/test/run-pass/expr-copy.rs
src/test/run-pass/expr-copy.rs
+4
-2
src/test/run-pass/expr-if-generic.rs
src/test/run-pass/expr-if-generic.rs
+3
-3
src/test/run-pass/expr-if-struct.rs
src/test/run-pass/expr-if-struct.rs
+5
-2
src/test/run-pass/exterior.rs
src/test/run-pass/exterior.rs
+4
-4
src/test/run-pass/fixed_length_vec_glue.rs
src/test/run-pass/fixed_length_vec_glue.rs
+3
-1
src/test/run-pass/for-destruct.rs
src/test/run-pass/for-destruct.rs
+3
-1
src/test/run-pass/generic-box.rs
src/test/run-pass/generic-box.rs
+4
-2
src/test/run-pass/generic-derived-type.rs
src/test/run-pass/generic-derived-type.rs
+5
-4
src/test/run-pass/generic-drop-glue.rs
src/test/run-pass/generic-drop-glue.rs
+2
-1
src/test/run-pass/generic-exterior-box.rs
src/test/run-pass/generic-exterior-box.rs
+3
-3
src/test/run-pass/generic-exterior-unique.rs
src/test/run-pass/generic-exterior-unique.rs
+3
-3
src/test/run-pass/generic-fn.rs
src/test/run-pass/generic-fn.rs
+4
-4
src/test/run-pass/generic-tag-values.rs
src/test/run-pass/generic-tag-values.rs
+3
-1
src/test/run-pass/generic-type.rs
src/test/run-pass/generic-type.rs
+2
-2
src/test/run-pass/generic-unique.rs
src/test/run-pass/generic-unique.rs
+3
-2
src/test/run-pass/guards.rs
src/test/run-pass/guards.rs
+5
-3
src/test/run-pass/infer-with-expected.rs
src/test/run-pass/infer-with-expected.rs
+6
-3
src/test/run-pass/init-res-into-things.rs
src/test/run-pass/init-res-into-things.rs
+4
-2
src/test/run-pass/instantiable.rs
src/test/run-pass/instantiable.rs
+4
-2
src/test/run-pass/issue-1112.rs
src/test/run-pass/issue-1112.rs
+4
-4
src/test/run-pass/issue-1989.rs
src/test/run-pass/issue-1989.rs
+5
-5
src/test/run-pass/issue-2463.rs
src/test/run-pass/issue-2463.rs
+5
-3
src/test/run-pass/issue-2633.rs
src/test/run-pass/issue-2633.rs
+3
-3
src/test/run-pass/issue-2718.rs
src/test/run-pass/issue-2718.rs
+7
-1
src/test/run-pass/issue-2989.rs
src/test/run-pass/issue-2989.rs
+4
-2
src/test/run-pass/issue-980.rs
src/test/run-pass/issue-980.rs
+4
-4
src/test/run-pass/lambda-infer-unresolved.rs
src/test/run-pass/lambda-infer-unresolved.rs
+5
-1
src/test/run-pass/large-records.rs
src/test/run-pass/large-records.rs
+6
-5
src/test/run-pass/last-use-in-cap-clause.rs
src/test/run-pass/last-use-in-cap-clause.rs
+3
-1
src/test/run-pass/last-use-is-capture.rs
src/test/run-pass/last-use-is-capture.rs
+3
-1
src/test/run-pass/let-destruct-fresh-mem.rs
src/test/run-pass/let-destruct-fresh-mem.rs
+5
-2
src/test/run-pass/let-destruct.rs
src/test/run-pass/let-destruct.rs
+3
-1
src/test/run-pass/log-linearized.rs
src/test/run-pass/log-linearized.rs
+5
-3
src/test/run-pass/morestack4.rs
src/test/run-pass/morestack4.rs
+5
-5
src/test/run-pass/move-1-unique.rs
src/test/run-pass/move-1-unique.rs
+5
-4
src/test/run-pass/move-1.rs
src/test/run-pass/move-1.rs
+6
-4
src/test/run-pass/move-2-unique.rs
src/test/run-pass/move-2-unique.rs
+2
-1
src/test/run-pass/move-2.rs
src/test/run-pass/move-2.rs
+2
-1
src/test/run-pass/move-3-unique.rs
src/test/run-pass/move-3-unique.rs
+6
-4
src/test/run-pass/move-3.rs
src/test/run-pass/move-3.rs
+6
-4
src/test/run-pass/move-4-unique.rs
src/test/run-pass/move-4-unique.rs
+4
-2
src/test/run-pass/move-4.rs
src/test/run-pass/move-4.rs
+8
-2
src/test/run-pass/mutable-vec-drop.rs
src/test/run-pass/mutable-vec-drop.rs
+4
-2
src/test/run-pass/nested-exhaustive-alt.rs
src/test/run-pass/nested-exhaustive-alt.rs
+7
-5
src/test/run-pass/nested-patterns.rs
src/test/run-pass/nested-patterns.rs
+10
-5
src/test/run-pass/newtype.rs
src/test/run-pass/newtype.rs
+4
-2
src/test/run-pass/output-slot-variants.rs
src/test/run-pass/output-slot-variants.rs
+10
-9
src/test/run-pass/pass-by-copy.rs
src/test/run-pass/pass-by-copy.rs
+5
-3
src/test/run-pass/pure-fmt.rs
src/test/run-pass/pure-fmt.rs
+5
-2
src/test/run-pass/pure-sum.rs
src/test/run-pass/pure-sum.rs
+4
-2
src/test/run-pass/readalias.rs
src/test/run-pass/readalias.rs
+3
-3
src/test/run-pass/rec-align-u32.rs
src/test/run-pass/rec-align-u32.rs
+10
-10
src/test/run-pass/rec-align-u64.rs
src/test/run-pass/rec-align-u64.rs
+13
-13
src/test/run-pass/rec-auto.rs
src/test/run-pass/rec-auto.rs
+4
-1
src/test/run-pass/rec-extend.rs
src/test/run-pass/rec-extend.rs
+4
-4
src/test/run-pass/rec-tup.rs
src/test/run-pass/rec-tup.rs
+5
-5
src/test/run-pass/rec.rs
src/test/run-pass/rec.rs
+4
-4
src/test/run-pass/record-pat.rs
src/test/run-pass/record-pat.rs
+6
-6
src/test/run-pass/reflect-visit-data.rs
src/test/run-pass/reflect-visit-data.rs
+13
-9
src/test/run-pass/regions-infer-borrow-scope.rs
src/test/run-pass/regions-infer-borrow-scope.rs
+3
-3
src/test/run-pass/regions-mock-trans-impls.rs
src/test/run-pass/regions-mock-trans-impls.rs
+15
-15
src/test/run-pass/regions-mock-trans.rs
src/test/run-pass/regions-mock-trans.rs
+16
-16
src/test/run-pass/regions-self-impls.rs
src/test/run-pass/regions-self-impls.rs
+3
-3
src/test/run-pass/regions-trait.rs
src/test/run-pass/regions-trait.rs
+8
-8
src/test/run-pass/resource-cycle.rs
src/test/run-pass/resource-cycle.rs
+6
-4
src/test/run-pass/resource-cycle2.rs
src/test/run-pass/resource-cycle2.rs
+12
-10
src/test/run-pass/resource-cycle3.rs
src/test/run-pass/resource-cycle3.rs
+16
-14
src/test/run-pass/resource-generic.rs
src/test/run-pass/resource-generic.rs
+5
-3
src/test/run-pass/rt-circular-buffer.rs
src/test/run-pass/rt-circular-buffer.rs
+8
-8
src/test/run-pass/sendfn-generic-fn.rs
src/test/run-pass/sendfn-generic-fn.rs
+6
-6
src/test/run-pass/shape_intrinsic_tag_then_rec.rs
src/test/run-pass/shape_intrinsic_tag_then_rec.rs
+13
-11
src/test/run-pass/struct-return.rs
src/test/run-pass/struct-return.rs
+6
-6
src/test/run-pass/task-comm-16.rs
src/test/run-pass/task-comm-16.rs
+3
-3
src/test/run-pass/trait-cast.rs
src/test/run-pass/trait-cast.rs
+5
-5
src/test/run-pass/type-namespace.rs
src/test/run-pass/type-namespace.rs
+3
-3
src/test/run-pass/uniq-cc-generic.rs
src/test/run-pass/uniq-cc-generic.rs
+5
-5
src/test/run-pass/uniq-cc.rs
src/test/run-pass/uniq-cc.rs
+5
-5
src/test/run-pass/unique-autoderef-field.rs
src/test/run-pass/unique-autoderef-field.rs
+3
-1
src/test/run-pass/unique-destructure.rs
src/test/run-pass/unique-destructure.rs
+3
-1
src/test/run-pass/unique-pat-2.rs
src/test/run-pass/unique-pat-2.rs
+5
-4
src/test/run-pass/unique-rec.rs
src/test/run-pass/unique-rec.rs
+2
-1
src/test/run-pass/vec-drop.rs
src/test/run-pass/vec-drop.rs
+4
-2
src/test/run-pass/writealias.rs
src/test/run-pass/writealias.rs
+3
-3
未找到文件。
src/test/auxiliary/cci_nested_lib.rs
浏览文件 @
6d4907a7
...
...
@@ -13,11 +13,12 @@
use
dvec
::
DVec
;
type
entry
<
A
,
B
>
=
{
key
:
A
,
value
:
B
};
struct
alist
<
A
,
B
>
{
eq_fn
:
fn
@
(
A
,
A
)
->
bool
,
data
:
DVec
<
entry
<
A
,
B
>>
}
struct
Entry
<
A
,
B
>
{
key
:
A
,
value
:
B
}
struct
alist
<
A
,
B
>
{
eq_fn
:
fn
@
(
A
,
A
)
->
bool
,
data
:
DVec
<
Entry
<
A
,
B
>>
}
fn
alist_add
<
A
:
Copy
,
B
:
Copy
>
(
lst
:
alist
<
A
,
B
>
,
k
:
A
,
v
:
B
)
{
lst
.data
.push
({
key
:
k
,
value
:
v
});
lst
.data
.push
(
Entry
{
key
:
k
,
value
:
v
});
}
fn
alist_get
<
A
:
Copy
,
B
:
Copy
>
(
lst
:
alist
<
A
,
B
>
,
k
:
A
)
->
B
{
...
...
src/test/auxiliary/crateresolve5-1.rs
浏览文件 @
6d4907a7
...
...
@@ -14,8 +14,10 @@
#[crate_type
=
"lib"
]
;
#[legacy_exports]
;
fn
structural
()
->
{
name
:
~
str
,
val
:
int
}
{
{
name
:
~
"crateresolve5"
,
val
:
10
}
struct
NameVal
{
name
:
~
str
,
val
:
int
}
fn
struct_nameval
()
->
NameVal
{
NameVal
{
name
:
~
"crateresolve5"
,
val
:
10
}
}
enum
e
{
...
...
src/test/auxiliary/crateresolve5-2.rs
浏览文件 @
6d4907a7
...
...
@@ -14,8 +14,9 @@
#[crate_type
=
"lib"
]
;
#[legacy_exports]
;
fn
structural
()
->
{
name
:
~
str
,
val
:
int
}
{
{
name
:
~
"crateresolve5"
,
val
:
10
}
struct
NameVal
{
name
:
~
str
,
val
:
int
}
fn
struct_nameval
()
->
NameVal
{
NameVal
{
name
:
~
"crateresolve5"
,
val
:
10
}
}
enum
e
{
...
...
src/test/run-pass/alias-uninit-value.rs
浏览文件 @
6d4907a7
...
...
@@ -14,10 +14,10 @@
enum
sty
{
ty_nil
,
}
type
raw_t
=
{
struct_
:
sty
,
cname
:
Option
<~
str
>
,
hash
:
uint
};
struct
RawT
{
struct_
:
sty
,
cname
:
Option
<~
str
>
,
hash
:
uint
}
fn
mk_raw_ty
(
st
:
sty
,
cname
:
Option
<~
str
>
)
->
raw_t
{
return
{
struct_
:
st
,
cname
:
cname
,
hash
:
0u
};
fn
mk_raw_ty
(
st
:
sty
,
cname
:
Option
<~
str
>
)
->
RawT
{
return
RawT
{
struct_
:
st
,
cname
:
cname
,
hash
:
0u
};
}
fn
main
()
{
mk_raw_ty
(
ty_nil
,
None
::
<~
str
>
);
}
src/test/run-pass/alignment-gep-tup-like-2.rs
浏览文件 @
6d4907a7
...
...
@@ -8,18 +8,18 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
type
pair
<
A
,
B
>
=
{
struct
Pair
<
A
,
B
>
{
a
:
A
,
b
:
B
}
;
}
enum
rec
<
A
>
=
_
r
ec
<
A
>
;
type
_
rec
<
A
>
=
{
enum
RecEnum
<
A
>
=
R
ec
<
A
>
;
struct
Rec
<
A
>
{
val
:
A
,
mut
rec
:
Option
<@
rec
<
A
>>
}
;
mut
rec
:
Option
<@
RecEnum
<
A
>>
}
fn
make_cycle
<
A
:
Copy
>
(
a
:
A
)
{
let
g
:
@
rec
<
A
>
=
@
rec
(
{
val
:
a
,
mut
rec
:
None
});
let
g
:
@
RecEnum
<
A
>
=
@
RecEnum
(
Rec
{
val
:
a
,
mut
rec
:
None
});
g
.rec
=
Some
(
g
);
}
...
...
src/test/run-pass/alloca-from-derived-tydesc.rs
浏览文件 @
6d4907a7
...
...
@@ -10,8 +10,8 @@
enum
option
<
T
>
{
some
(
T
),
none
,
}
type
r
<
T
>
=
{
mut
v
:
~
[
option
<
T
>
]};
struct
R
<
T
>
{
mut
v
:
~
[
option
<
T
>
]}
fn
f
<
T
>
()
->
~
[
T
]
{
return
~
[];
}
fn
main
()
{
let
r
:
r
<
int
>
=
{
mut
v
:
~
[]};
r
.v
=
f
();
}
fn
main
()
{
let
r
:
R
<
int
>
=
R
{
mut
v
:
~
[]};
r
.v
=
f
();
}
src/test/run-pass/alt-implicit-copy-unique.rs
浏览文件 @
6d4907a7
...
...
@@ -8,10 +8,12 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
struct
Pair
{
mut
a
:
~
int
,
mut
b
:
~
int
}
fn
main
()
{
let
x
=
~
{
mut
a
:
~
10
,
b
:
~
20
};
let
x
=
~
Pair
{
mut
a
:
~
10
,
b
:
~
20
};
match
x
{
~
{
a
:
ref
mut
a
,
b
:
ref
b
}
=>
{
~
Pair
{
a
:
ref
mut
a
,
b
:
ref
b
}
=>
{
assert
**
a
==
10
;
*
a
=
~
30
;
assert
**
a
==
30
;
}
}
...
...
src/test/run-pass/alt-naked-record-expr.rs
浏览文件 @
6d4907a7
...
...
@@ -8,9 +8,11 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
struct
X
{
x
:
int
}
fn
main
()
{
let
x
=
match
0
{
_
=>
{
_
=>
X
{
x
:
0
}
.x
};
...
...
src/test/run-pass/alt-naked-record.rs
浏览文件 @
6d4907a7
...
...
@@ -8,9 +8,11 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
struct
X
{
x
:
int
}
fn
main
()
{
let
x
=
match
0
{
_
=>
{
_
=>
X
{
x
:
0
}
};
...
...
src/test/run-pass/alt-ref-binding-mut.rs
浏览文件 @
6d4907a7
...
...
@@ -8,18 +8,18 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
type
rec
=
{
struct
Rec
{
f
:
int
}
;
}
fn
destructure
(
x
:
&
mut
r
ec
)
{
fn
destructure
(
x
:
&
mut
R
ec
)
{
match
*
x
{
{
f
:
ref
mut
f
}
=>
*
f
+=
1
Rec
{
f
:
ref
mut
f
}
=>
*
f
+=
1
}
}
fn
main
()
{
let
mut
v
=
{
f
:
22
};
let
mut
v
=
Rec
{
f
:
22
};
destructure
(
&
mut
v
);
assert
v
.f
==
23
;
}
src/test/run-pass/argument-passing.rs
浏览文件 @
6d4907a7
...
...
@@ -11,7 +11,9 @@
// xfail-fast
#[legacy_modes]
;
fn
f1
(
a
:
{
mut
x
:
int
},
b
:
&
mut
int
,
-
c
:
int
)
->
int
{
struct
X
{
mut
x
:
int
}
fn
f1
(
a
:
X
,
b
:
&
mut
int
,
-
c
:
int
)
->
int
{
let
r
=
a
.x
+
*
b
+
c
;
a
.x
=
0
;
*
b
=
10
;
...
...
@@ -21,7 +23,7 @@ fn f1(a: {mut x: int}, b: &mut int, -c: int) -> int {
fn
f2
(
a
:
int
,
f
:
fn
(
int
))
->
int
{
f
(
1
);
return
a
;
}
fn
main
()
{
let
mut
a
=
{
mut
x
:
1
},
b
=
2
,
c
=
3
;
let
mut
a
=
X
{
mut
x
:
1
},
b
=
2
,
c
=
3
;
assert
(
f1
(
a
,
&
mut
b
,
move
c
)
==
6
);
assert
(
a
.x
==
0
);
assert
(
b
==
10
);
...
...
src/test/run-pass/auto-instantiate.rs
浏览文件 @
6d4907a7
...
...
@@ -12,9 +12,13 @@
// -*- rust -*-
fn
f
<
T
:
Copy
,
U
:
Copy
>
(
x
:
T
,
y
:
U
)
->
{
a
:
T
,
b
:
U
}
{
return
{
a
:
x
,
b
:
y
};
}
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
main
()
{
log
(
debug
,
f
({
x
:
3
,
y
:
4
,
z
:
5
},
4
)
.a.x
);
log
(
debug
,
f
(
Triple
{
x
:
3
,
y
:
4
,
z
:
5
},
4
)
.a.x
);
log
(
debug
,
f
(
5
,
6
)
.a
);
}
src/test/run-pass/borrowck-binding-mutbl.rs
浏览文件 @
6d4907a7
...
...
@@ -8,14 +8,16 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
struct
F
{
mut
f
:
~
[
int
]
}
fn
impure
(
_
v
:
&
[
int
])
{
}
fn
main
()
{
let
x
=
{
mut
f
:
~
[
3
]};
let
x
=
F
{
f
:
~
[
3
]};
match
x
{
{
f
:
ref
mut
v
}
=>
{
F
{
f
:
ref
mut
v
}
=>
{
impure
(
*
v
);
}
}
...
...
src/test/run-pass/borrowck-mut-uniq.rs
浏览文件 @
6d4907a7
...
...
@@ -8,9 +8,9 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
type
ints
=
{
sum
:
~
int
,
values
:
~
[
int
]};
struct
Ints
{
sum
:
~
int
,
values
:
~
[
int
]}
fn
add_int
(
x
:
&
mut
i
nts
,
v
:
int
)
{
fn
add_int
(
x
:
&
mut
I
nts
,
v
:
int
)
{
*
x
.sum
+=
v
;
let
mut
values
=
~
[];
x
.values
<->
values
;
...
...
@@ -18,13 +18,13 @@ fn add_int(x: &mut ints, v: int) {
x
.values
<->
values
;
}
fn
iter_ints
(
x
:
&
i
nts
,
f
:
fn
(
x
:
&
int
)
->
bool
)
{
fn
iter_ints
(
x
:
&
I
nts
,
f
:
fn
(
x
:
&
int
)
->
bool
)
{
let
l
=
x
.values
.len
();
uint
::
range
(
0
,
l
,
|
i
|
f
(
&
x
.values
[
i
]))
}
fn
main
()
{
let
mut
ints
=
~
{
sum
:
~
0
,
values
:
~
[]};
let
mut
ints
=
~
Ints
{
sum
:
~
0
,
values
:
~
[]};
add_int
(
ints
,
22
);
add_int
(
ints
,
44
);
...
...
src/test/run-pass/borrowck-preserve-box-in-discr.rs
浏览文件 @
6d4907a7
...
...
@@ -10,14 +10,16 @@
// exec-env:RUST_POISON_ON_FREE=1
struct
F
{
f
:
~
int
}
fn
main
()
{
let
mut
x
=
@
{
f
:
~
3
};
let
mut
x
=
@
F
{
f
:
~
3
};
match
x
{
@
{
f
:
ref
b_x
}
=>
{
@
F
{
f
:
ref
b_x
}
=>
{
assert
**
b_x
==
3
;
assert
ptr
::
addr_of
(
&
(
*
x
.f
))
==
ptr
::
addr_of
(
&
(
**
b_x
));
x
=
@
{
f
:
~
4
};
x
=
@
F
{
f
:
~
4
};
debug!
(
"ptr::addr_of(*b_x) = %x"
,
ptr
::
addr_of
(
&
(
**
b_x
))
as
uint
);
assert
**
b_x
==
3
;
...
...
src/test/run-pass/borrowck-preserve-box-in-field.rs
浏览文件 @
6d4907a7
...
...
@@ -17,12 +17,14 @@ fn borrow(x: &int, f: fn(x: &int)) {
assert
before
==
after
;
}
struct
F
{
f
:
~
int
}
fn
main
()
{
let
mut
x
=
@
{
f
:
~
3
};
let
mut
x
=
@
F
{
f
:
~
3
};
do
borrow
(
x
.f
)
|
b_x
|
{
assert
*
b_x
==
3
;
assert
ptr
::
addr_of
(
&
(
*
x
.f
))
==
ptr
::
addr_of
(
&
(
*
b_x
));
x
=
@
{
f
:
~
4
};
x
=
@
F
{
f
:
~
4
};
debug!
(
"ptr::addr_of(*b_x) = %x"
,
ptr
::
addr_of
(
&
(
*
b_x
))
as
uint
);
assert
*
b_x
==
3
;
...
...
src/test/run-pass/borrowck-preserve-box-in-pat.rs
浏览文件 @
6d4907a7
...
...
@@ -10,14 +10,16 @@
// exec-env:RUST_POISON_ON_FREE=1
struct
F
{
f
:
~
int
}
fn
main
()
{
let
mut
x
=
@
mut
@
{
f
:
~
3
};
let
mut
x
=
@
mut
@
F
{
f
:
~
3
};
match
x
{
@@
{
f
:
ref
b_x
}
=>
{
@@
F
{
f
:
ref
b_x
}
=>
{
assert
**
b_x
==
3
;
assert
ptr
::
addr_of
(
&
(
x
.f
))
==
ptr
::
addr_of
(
b_x
);
*
x
=
@
{
f
:
~
4
};
*
x
=
@
F
{
f
:
~
4
};
debug!
(
"ptr::addr_of(*b_x) = %x"
,
ptr
::
addr_of
(
&
(
**
b_x
))
as
uint
);
assert
**
b_x
==
3
;
...
...
src/test/run-pass/borrowck-preserve-box-in-uniq.rs
浏览文件 @
6d4907a7
...
...
@@ -17,12 +17,14 @@ fn borrow(x: &int, f: fn(x: &int)) {
assert
before
==
after
;
}
struct
F
{
f
:
~
int
}
fn
main
()
{
let
mut
x
=
~
mut
@
{
f
:
~
3
};
let
mut
x
=
~
mut
@
F
{
f
:
~
3
};
do
borrow
(
x
.f
)
|
b_x
|
{
assert
*
b_x
==
3
;
assert
ptr
::
addr_of
(
&
(
*
x
.f
))
==
ptr
::
addr_of
(
&
(
*
b_x
));
*
x
=
@
{
f
:
~
4
};
*
x
=
@
F
{
f
:
~
4
};
debug!
(
"ptr::addr_of(*b_x) = %x"
,
ptr
::
addr_of
(
&
(
*
b_x
))
as
uint
);
assert
*
b_x
==
3
;
...
...
src/test/run-pass/borrowck-preserve-expl-deref.rs
浏览文件 @
6d4907a7
...
...
@@ -17,12 +17,14 @@ fn borrow(x: &int, f: fn(x: &int)) {
assert
before
==
after
;
}
struct
F
{
f
:
~
int
}
fn
main
()
{
let
mut
x
=
@
{
f
:
~
3
};
let
mut
x
=
@
F
{
f
:
~
3
};
do
borrow
((
*
x
)
.f
)
|
b_x
|
{
assert
*
b_x
==
3
;
assert
ptr
::
addr_of
(
&
(
*
x
.f
))
==
ptr
::
addr_of
(
&
(
*
b_x
));
x
=
@
{
f
:
~
4
};
x
=
@
F
{
f
:
~
4
};
debug!
(
"ptr::addr_of(*b_x) = %x"
,
ptr
::
addr_of
(
&
(
*
b_x
))
as
uint
);
assert
*
b_x
==
3
;
...
...
src/test/run-pass/borrowck-root-while-cond-2.rs
浏览文件 @
6d4907a7
...
...
@@ -8,7 +8,10 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
struct
F
{
mut
f
:
@
G
}
struct
G
{
g
:
~
[
int
]
}
fn
main
()
{
let
rec
=
@
{
mut
f
:
@
{
g
:
~
[
1
,
2
,
3
]}};
let
rec
=
@
F
{
mut
f
:
@
G
{
g
:
~
[
1
,
2
,
3
]}};
while
rec
.f.g
.len
()
==
23
{}
}
src/test/run-pass/borrowck-root-while-cond.rs
浏览文件 @
6d4907a7
...
...
@@ -10,7 +10,9 @@
fn
borrow
<
T
>
(
x
:
&
r
/
T
)
->
&
r
/
T
{
x
}
struct
Rec
{
mut
f
:
@
int
}
fn
main
()
{
let
rec
=
@
{
mut
f
:
@
22
};
let
rec
=
@
Rec
{
mut
f
:
@
22
};
while
*
borrow
(
rec
.f
)
==
23
{}
}
src/test/run-pass/box-pattern.rs
浏览文件 @
6d4907a7
...
...
@@ -8,12 +8,12 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
type
foo
=
{
a
:
int
,
b
:
uint
};
enum
bar
{
u
(
@
f
oo
),
w
(
int
),
}
struct
Foo
{
a
:
int
,
b
:
uint
}
enum
bar
{
u
(
@
F
oo
),
w
(
int
),
}
fn
main
()
{
assert
(
match
u
(
@
{
a
:
10
,
b
:
40u
})
{
u
(
@
{
a
:
a
,
b
:
b
})
=>
{
a
+
(
b
as
int
)
}
assert
(
match
u
(
@
Foo
{
a
:
10
,
b
:
40u
})
{
u
(
@
Foo
{
a
:
a
,
b
:
b
})
=>
{
a
+
(
b
as
int
)
}
_
=>
{
66
}
}
==
50
);
}
src/test/run-pass/box-unbox.rs
浏览文件 @
6d4907a7
...
...
@@ -10,13 +10,13 @@
type
box
<
T
:
Copy
>
=
{
c
:
@
T
};
struct
Box
<
T
:
Copy
>
{
c
:
@
T
}
fn
unbox
<
T
:
Copy
>
(
b
:
b
ox
<
T
>
)
->
T
{
return
*
b
.c
;
}
fn
unbox
<
T
:
Copy
>
(
b
:
B
ox
<
T
>
)
->
T
{
return
*
b
.c
;
}
fn
main
()
{
let
foo
:
int
=
17
;
let
bfoo
:
box
<
int
>
=
{
c
:
@
foo
};
let
bfoo
:
Box
<
int
>
=
Box
{
c
:
@
foo
};
debug!
(
"see what's in our box"
);
assert
(
unbox
::
<
int
>
(
bfoo
)
==
foo
);
}
src/test/run-pass/const-bound.rs
浏览文件 @
6d4907a7
...
...
@@ -14,11 +14,13 @@
fn
foo
<
T
:
Copy
Const
>
(
x
:
T
)
->
T
{
x
}
struct
F
{
field
:
int
}
fn
main
()
{
foo
(
1
);
foo
(
~
"hi"
);
foo
(
~
[
1
,
2
,
3
]);
foo
({
field
:
42
});
foo
(
F
{
field
:
42
});
foo
((
1
,
2u
));
foo
(
@
1
);
foo
(
~
1
);
...
...
src/test/run-pass/const-fields-and-indexing.rs
浏览文件 @
6d4907a7
...
...
@@ -13,11 +13,16 @@
const
y
:
&
[
int
]
=
&
[
1
,
2
,
3
,
4
];
const
q
:
int
=
y
[
2
];
const
s
:
{
a
:
int
,
b
:
int
}
=
{
a
:
10
,
b
:
20
};
struct
S
{
a
:
int
,
b
:
int
}
const
s
:
S
=
S
{
a
:
10
,
b
:
20
};
const
t
:
int
=
s
.b
;
const
k
:
{
a
:
int
,
b
:
int
,
c
:
{
d
:
int
,
e
:
int
}}
=
{
a
:
10
,
b
:
20
,
c
:
{
d
:
30
,
e
:
40
}};
struct
K
{
a
:
int
,
b
:
int
,
c
:
D
}
struct
D
{
d
:
int
,
e
:
int
}
const
k
:
K
=
K
{
a
:
10
,
b
:
20
,
c
:
D
{
d
:
30
,
e
:
40
}};
const
m
:
int
=
k
.c.e
;
fn
main
()
{
...
...
src/test/run-pass/const-rec-and-tup.rs
浏览文件 @
6d4907a7
...
...
@@ -8,13 +8,15 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
struct
Pair
{
a
:
float
,
b
:
float
}
struct
AnotherPair
{
x
:
(
i64
,
i64
),
y
:
Pair
}
const
x
:
(
i32
,
i32
)
=
(
0xfeedf00dd
,
0xca11ab1e
);
const
y
:
{
x
:
(
i64
,
i64
),
y
:
{
a
:
float
,
b
:
float
}
}
=
{
x
:
(
0xf0f0f0f0_f0f0f0f0
,
0xabababab_abababab
),
y
:
{
a
:
3.14159265358979323846
,
b
:
2.7182818284590452354
}
};
const
y
:
AnotherPair
=
AnotherPair
{
x
:
(
0xf0f0f0f0_f0f0f0f0
,
0xabababab_abababab
),
y
:
Pair
{
a
:
3.14159265358979323846
,
b
:
2.7182818284590452354
}};
fn
main
()
{
let
(
p
,
_
)
=
y
.x
;
...
...
src/test/run-pass/const-region-ptrs.rs
浏览文件 @
6d4907a7
...
...
@@ -9,9 +9,11 @@
// except according to those terms.
struct
Pair
{
a
:
int
,
b
:
&
int
}
const
x
:
&
int
=
&
10
;
const
y
:
&
{
a
:
int
,
b
:
&
int
}
=
&
{
a
:
15
,
b
:
x
};
const
y
:
&
Pair
=
&
Pair
{
a
:
15
,
b
:
x
};
fn
main
()
{
io
::
println
(
fmt!
(
"x = %?"
,
*
x
));
...
...
src/test/run-pass/crateresolve5.rs
浏览文件 @
6d4907a7
...
...
@@ -17,8 +17,8 @@
fn
main
()
{
// Structural types can be used between two versions of the same crate
assert
cr5_1
::
struct
ural
()
.name
==
cr5_2
::
structur
al
()
.name
;
assert
cr5_1
::
struct
ural
()
.val
==
cr5_2
::
structur
al
()
.val
;
assert
cr5_1
::
struct
_nameval
()
.name
==
cr5_2
::
struct_namev
al
()
.name
;
assert
cr5_1
::
struct
_nameval
()
.val
==
cr5_2
::
struct_namev
al
()
.val
;
// Make sure these are actually two different crates
assert
cr5_1
::
f
()
==
10
&&
cr5_2
::
f
()
==
20
;
}
src/test/run-pass/early-vtbl-resolution.rs
浏览文件 @
6d4907a7
...
...
@@ -17,9 +17,11 @@ fn foo() -> Option<A> { None }
}
fn
foo_func
<
A
,
B
:
thing
<
A
>>
(
x
:
B
)
->
Option
<
A
>
{
x
.foo
()
}
struct
A
{
a
:
int
}
fn
main
()
{
for
iter
::
eachi
(
&
(
Some
({
a
:
0
})))
|
i
,
a
|
{
for
iter
::
eachi
(
&
(
Some
(
A
{
a
:
0
})))
|
i
,
a
|
{
debug!
(
"%u %d"
,
i
,
a
.a
);
}
...
...
src/test/run-pass/explicit-self-generic.rs
浏览文件 @
6d4907a7
...
...
@@ -18,14 +18,14 @@
type
HashFn
<
K
>
=
pure
fn
~
(
K
)
->
uint
;
type
EqFn
<
K
>
=
pure
fn
~
(
K
,
K
)
->
bool
;
struct
LM
{
resize_at
:
uint
,
size
:
uint
}
enum
LinearMap
<
K
,
V
>
{
LinearMap_
({
resize_at
:
uint
,
size
:
uint
})
LinearMap_
(
LM
)
}
fn
linear_map
<
K
,
V
>
()
->
LinearMap
<
K
,
V
>
{
LinearMap_
({
LinearMap_
(
LM
{
resize_at
:
32
,
size
:
0
})
}
...
...
src/test/run-pass/explicit-self.rs
浏览文件 @
6d4907a7
...
...
@@ -11,11 +11,11 @@
const
tau
:
float
=
2.0
*
3.14159265358979323
;
type
point
=
{
x
:
float
,
y
:
float
};
type
size
=
{
w
:
float
,
h
:
float
};
struct
Point
{
x
:
float
,
y
:
float
}
struct
Size
{
w
:
float
,
h
:
float
}
enum
shape
{
circle
(
p
oint
,
float
),
rectangle
(
point
,
s
ize
)
circle
(
P
oint
,
float
),
rectangle
(
Point
,
S
ize
)
}
...
...
@@ -37,16 +37,18 @@ fn select<T>(&self, threshold: float,
fn
select_based_on_unit_circle
<
T
>
(
threshold
:
float
,
a
:
&
r
/
T
,
b
:
&
r
/
T
)
->
&
r
/
T
{
let
shape
=
&
circle
({
x
:
0.0
,
y
:
0.0
},
1.0
);
let
shape
=
&
circle
(
Point
{
x
:
0.0
,
y
:
0.0
},
1.0
);
shape
.select
(
threshold
,
a
,
b
)
}
struct
thing
{
x
:
{
mut
a
:
@
int
}
x
:
A
}
fn
thing
(
x
:
{
mut
a
:
@
int
})
->
thing
{
struct
A
{
mut
a
:
@
int
}
fn
thing
(
x
:
A
)
->
thing
{
thing
{
x
:
copy
x
}
...
...
@@ -56,7 +58,7 @@ impl thing {
fn
foo
(
@
self
)
->
int
{
*
self
.x.a
}
fn
bar
(
~
self
)
->
int
{
*
self
.x.a
}
fn
quux
(
&
self
)
->
int
{
*
self
.x.a
}
fn
baz
(
&
self
)
->
&
self
/
{
mut
a
:
@
int
}
{
&
self
.x
}
fn
baz
(
&
self
)
->
&
self
/
A
{
&
self
.x
}
fn
spam
(
self
)
->
int
{
*
self
.x.a
}
}
...
...
@@ -65,14 +67,14 @@ impl thing: Nus { fn f(&self) {} }
fn
main
()
{
let
x
=
@
thing
({
mut
a
:
@
10
});
let
x
=
@
thing
(
A
{
mut
a
:
@
10
});
assert
x
.foo
()
==
10
;
assert
x
.quux
()
==
10
;
let
y
=
~
thing
({
mut
a
:
@
10
});
let
y
=
~
thing
(
A
{
mut
a
:
@
10
});
assert
(
copy
y
)
.bar
()
==
10
;
assert
y
.quux
()
==
10
;
let
z
=
thing
({
mut
a
:
@
11
});
let
z
=
thing
(
A
{
mut
a
:
@
11
});
assert
z
.spam
()
==
11
;
}
src/test/run-pass/expr-alt-generic.rs
浏览文件 @
6d4907a7
...
...
@@ -24,13 +24,13 @@ fn test_bool() {
test_generic
::
<
bool
>
(
true
,
compare_bool
);
}
type
t
=
{
a
:
int
,
b
:
int
};
struct
Pair
{
a
:
int
,
b
:
int
}
fn
test_rec
()
{
fn
compare_rec
(
t1
:
t
,
t2
:
t
)
->
bool
{
fn
compare_rec
(
t1
:
Pair
,
t2
:
Pair
)
->
bool
{
t1
.a
==
t2
.a
&&
t1
.b
==
t2
.b
}
test_generic
::
<
t
>
(
{
a
:
1
,
b
:
2
},
compare_rec
);
test_generic
::
<
Pair
>
(
Pair
{
a
:
1
,
b
:
2
},
compare_rec
);
}
fn
main
()
{
test_bool
();
test_rec
();
}
src/test/run-pass/expr-alt-struct.rs
浏览文件 @
6d4907a7
...
...
@@ -13,9 +13,11 @@
// -*- rust -*-
// Tests for match as expressions resulting in structural types
// Tests for match as expressions resulting in struct types
struct
R
{
i
:
int
}
fn
test_rec
()
{
let
rs
=
match
true
{
true
=>
{
i
:
100
},
_
=>
fail
};
let
rs
=
match
true
{
true
=>
R
{
i
:
100
},
_
=>
fail
};
assert
(
rs
.i
==
100
);
}
...
...
src/test/run-pass/expr-block-generic.rs
浏览文件 @
6d4907a7
...
...
@@ -26,13 +26,13 @@ fn test_bool() {
test_generic
::
<
bool
>
(
true
,
compare_bool
);
}
type
t
=
{
a
:
int
,
b
:
int
};
struct
Pair
{
a
:
int
,
b
:
int
}
fn
test_rec
()
{
fn
compare_rec
(
t1
:
t
,
t2
:
t
)
->
bool
{
fn
compare_rec
(
t1
:
Pair
,
t2
:
Pair
)
->
bool
{
t1
.a
==
t2
.a
&&
t1
.b
==
t2
.b
}
test_generic
::
<
t
>
(
{
a
:
1
,
b
:
2
},
compare_rec
);
test_generic
::
<
Pair
>
(
Pair
{
a
:
1
,
b
:
2
},
compare_rec
);
}
fn
main
()
{
test_bool
();
test_rec
();
}
src/test/run-pass/expr-block-slot.rs
浏览文件 @
6d4907a7
...
...
@@ -9,9 +9,13 @@
// except according to those terms.
// Regression test for issue #377
struct
A
{
a
:
int
}
struct
V
{
v
:
int
}
fn
main
()
{
let
a
=
{
let
b
=
{
a
:
3
};
b
};
let
a
=
{
let
b
=
A
{
a
:
3
};
b
};
assert
(
a
.a
==
3
);
let
c
=
{
let
d
=
{
v
:
3
};
d
};
let
c
=
{
let
d
=
V
{
v
:
3
};
d
};
assert
(
c
.v
==
3
);
}
src/test/run-pass/expr-block.rs
浏览文件 @
6d4907a7
...
...
@@ -16,7 +16,9 @@
// Tests for standalone blocks as expressions
fn
test_basic
()
{
let
rs
:
bool
=
{
true
};
assert
(
rs
);
}
fn
test_rec
()
{
let
rs
=
{
{
v1
:
10
,
v2
:
20
}
};
assert
(
rs
.v2
==
20
);
}
struct
RS
{
v1
:
int
,
v2
:
int
}
fn
test_rec
()
{
let
rs
=
{
RS
{
v1
:
10
,
v2
:
20
}
};
assert
(
rs
.v2
==
20
);
}
fn
test_filled_with_stuff
()
{
let
rs
=
{
let
mut
a
=
0
;
while
a
<
10
{
a
+=
1
;
}
a
};
...
...
src/test/run-pass/expr-copy.rs
浏览文件 @
6d4907a7
...
...
@@ -11,12 +11,14 @@
// xfail-fast
#[legacy_modes]
;
fn
f
(
arg
:
{
mut
a
:
int
}
)
{
fn
f
(
arg
:
A
)
{
arg
.a
=
100
;
}
struct
A
{
mut
a
:
int
}
fn
main
()
{
let
x
=
{
mut
a
:
10
};
let
x
=
A
{
a
:
10
};
f
(
x
);
assert
x
.a
==
100
;
x
.a
=
20
;
...
...
src/test/run-pass/expr-if-generic.rs
浏览文件 @
6d4907a7
...
...
@@ -25,13 +25,13 @@ fn test_bool() {
test_generic
::
<
bool
>
(
true
,
false
,
compare_bool
);
}
type
t
=
{
a
:
int
,
b
:
int
};
struct
Pair
{
a
:
int
,
b
:
int
}
fn
test_rec
()
{
fn
compare_rec
(
t1
:
t
,
t2
:
t
)
->
bool
{
fn
compare_rec
(
t1
:
Pair
,
t2
:
Pair
)
->
bool
{
t1
.a
==
t2
.a
&&
t1
.b
==
t2
.b
}
test_generic
::
<
t
>
({
a
:
1
,
b
:
2
},
{
a
:
2
,
b
:
3
},
compare_rec
);
test_generic
::
<
Pair
>
(
Pair
{
a
:
1
,
b
:
2
},
Pair
{
a
:
2
,
b
:
3
},
compare_rec
);
}
fn
main
()
{
test_bool
();
test_rec
();
}
src/test/run-pass/expr-if-struct.rs
浏览文件 @
6d4907a7
...
...
@@ -13,9 +13,12 @@
// -*- rust -*-
// Tests for if as expressions returning structural types
// Tests for if as expressions returning nominal types
struct
I
{
i
:
int
}
fn
test_rec
()
{
let
rs
=
if
true
{
{
i
:
100
}
}
else
{
{
i
:
101
}
};
let
rs
=
if
true
{
I
{
i
:
100
}
}
else
{
I
{
i
:
101
}
};
assert
(
rs
.i
==
100
);
}
...
...
src/test/run-pass/exterior.rs
浏览文件 @
6d4907a7
...
...
@@ -12,13 +12,13 @@
// -*- rust -*-
type
point
=
{
x
:
int
,
y
:
int
,
mut
z
:
int
};
struct
Point
{
x
:
int
,
y
:
int
,
mut
z
:
int
}
fn
f
(
p
:
@
p
oint
)
{
assert
(
p
.z
==
12
);
p
.z
=
13
;
assert
(
p
.z
==
13
);
}
fn
f
(
p
:
@
P
oint
)
{
assert
(
p
.z
==
12
);
p
.z
=
13
;
assert
(
p
.z
==
13
);
}
fn
main
()
{
let
a
:
point
=
{
x
:
10
,
y
:
11
,
mut
z
:
12
};
let
b
:
@
p
oint
=
@
copy
a
;
let
a
:
Point
=
Point
{
x
:
10
,
y
:
11
,
mut
z
:
12
};
let
b
:
@
P
oint
=
@
copy
a
;
assert
(
b
.z
==
12
);
f
(
b
);
assert
(
a
.z
==
12
);
...
...
src/test/run-pass/fixed_length_vec_glue.rs
浏览文件 @
6d4907a7
...
...
@@ -8,9 +8,11 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
struct
Struc
{
a
:
u8
,
b
:
[
int
*
3
],
c
:
int
}
fn
main
()
{
let
arr
=
[
1
,
2
,
3
];
let
struc
=
{
a
:
13u8
,
b
:
arr
,
c
:
42
};
let
struc
=
Struc
{
a
:
13u8
,
b
:
arr
,
c
:
42
};
let
s
=
sys
::
log_str
(
&
struc
);
assert
(
s
==
~
"{a: 13, b: [1, 2, 3], c: 42}"
);
}
src/test/run-pass/for-destruct.rs
浏览文件 @
6d4907a7
...
...
@@ -8,8 +8,10 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
struct
Pair
{
x
:
int
,
y
:
int
}
fn
main
()
{
for
vec
::
each
(
~
[
{
x
:
10
,
y
:
20
},
{
x
:
30
,
y
:
0
}])
|
elt
|
{
for
vec
::
each
(
~
[
Pair
{
x
:
10
,
y
:
20
},
Pair
{
x
:
30
,
y
:
0
}])
|
elt
|
{
assert
(
elt
.x
+
elt
.y
==
30
);
}
}
src/test/run-pass/generic-box.rs
浏览文件 @
6d4907a7
...
...
@@ -10,9 +10,11 @@
fn
box
<
T
:
Copy
>
(
x
:
{
x
:
T
,
y
:
T
,
z
:
T
})
->
@
{
x
:
T
,
y
:
T
,
z
:
T
}
{
return
@
x
;
}
fn
box
<
T
:
Copy
>
(
x
:
Box
<
T
>
)
->
@
Box
<
T
>
{
return
@
x
;
}
struct
Box
<
T
>
{
x
:
T
,
y
:
T
,
z
:
T
}
fn
main
()
{
let
x
:
@
{
x
:
int
,
y
:
int
,
z
:
int
}
=
box
::
<
int
>
(
{
x
:
1
,
y
:
2
,
z
:
3
});
let
x
:
@
Box
<
int
>
=
box
::
<
int
>
(
Box
{
x
:
1
,
y
:
2
,
z
:
3
});
assert
(
x
.y
==
2
);
}
src/test/run-pass/generic-derived-type.rs
浏览文件 @
6d4907a7
...
...
@@ -12,11 +12,12 @@
fn
g
<
X
:
Copy
>
(
x
:
X
)
->
X
{
return
x
;
}
fn
f
<
T
:
Copy
>
(
t
:
T
)
->
{
a
:
T
,
b
:
T
}
{
type
pair
=
{
a
:
T
,
b
:
T
};
struct
Pair
<
T
>
{
a
:
T
,
b
:
T
}
let
x
:
pair
=
{
a
:
t
,
b
:
t
};
return
g
::
<
pair
>
(
x
);
fn
f
<
T
:
Copy
>
(
t
:
T
)
->
Pair
<
T
>
{
let
x
:
Pair
<
T
>
=
Pair
{
a
:
t
,
b
:
t
};
return
g
::
<
Pair
<
T
>>
(
x
);
}
fn
main
()
{
...
...
src/test/run-pass/generic-drop-glue.rs
浏览文件 @
6d4907a7
...
...
@@ -9,7 +9,8 @@
// except according to those terms.
struct
Pair
{
x
:
@
int
,
y
:
@
int
}
fn
f
<
T
:
Copy
>
(
t
:
T
)
{
let
t1
:
T
=
t
;
}
fn
main
()
{
let
x
=
{
x
:
@
10
,
y
:
@
12
};
f
(
x
);
}
fn
main
()
{
let
x
=
Pair
{
x
:
@
10
,
y
:
@
12
};
f
(
x
);
}
src/test/run-pass/generic-exterior-box.rs
浏览文件 @
6d4907a7
...
...
@@ -10,12 +10,12 @@
type
recbox
<
T
:
Copy
>
=
{
x
:
@
T
};
struct
Recbox
<
T
:
Copy
>
{
x
:
@
T
}
fn
reclift
<
T
:
Copy
>
(
t
:
T
)
->
recbox
<
T
>
{
return
{
x
:
@
t
};
}
fn
reclift
<
T
:
Copy
>
(
t
:
T
)
->
Recbox
<
T
>
{
return
Recbox
{
x
:
@
t
};
}
fn
main
()
{
let
foo
:
int
=
17
;
let
rbfoo
:
r
ecbox
<
int
>
=
reclift
::
<
int
>
(
foo
);
let
rbfoo
:
R
ecbox
<
int
>
=
reclift
::
<
int
>
(
foo
);
assert
(
*
rbfoo
.x
==
foo
);
}
src/test/run-pass/generic-exterior-unique.rs
浏览文件 @
6d4907a7
...
...
@@ -8,12 +8,12 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
type
recbox
<
T
:
Copy
>
=
{
x
:
~
T
};
struct
Recbox
<
T
:
Copy
>
{
x
:
~
T
}
fn
reclift
<
T
:
Copy
>
(
t
:
T
)
->
recbox
<
T
>
{
return
{
x
:
~
t
};
}
fn
reclift
<
T
:
Copy
>
(
t
:
T
)
->
Recbox
<
T
>
{
return
Recbox
{
x
:
~
t
};
}
fn
main
()
{
let
foo
:
int
=
17
;
let
rbfoo
:
r
ecbox
<
int
>
=
reclift
::
<
int
>
(
foo
);
let
rbfoo
:
R
ecbox
<
int
>
=
reclift
::
<
int
>
(
foo
);
assert
(
*
rbfoo
.x
==
foo
);
}
src/test/run-pass/generic-fn.rs
浏览文件 @
6d4907a7
...
...
@@ -14,22 +14,22 @@
// -*- rust -*-
fn
id
<
T
:
Copy
>
(
x
:
T
)
->
T
{
return
x
;
}
type
triple
=
{
x
:
int
,
y
:
int
,
z
:
int
};
struct
Triple
{
x
:
int
,
y
:
int
,
z
:
int
}
fn
main
()
{
let
mut
x
=
62
;
let
mut
y
=
63
;
let
a
=
'a'
;
let
mut
b
=
'b'
;
let
p
:
triple
=
{
x
:
65
,
y
:
66
,
z
:
67
};
let
mut
q
:
triple
=
{
x
:
68
,
y
:
69
,
z
:
70
};
let
p
:
Triple
=
Triple
{
x
:
65
,
y
:
66
,
z
:
67
};
let
mut
q
:
Triple
=
Triple
{
x
:
68
,
y
:
69
,
z
:
70
};
y
=
id
::
<
int
>
(
x
);
log
(
debug
,
y
);
assert
(
x
==
y
);
b
=
id
::
<
char
>
(
a
);
log
(
debug
,
b
);
assert
(
a
==
b
);
q
=
id
::
<
t
riple
>
(
p
);
q
=
id
::
<
T
riple
>
(
p
);
x
=
p
.z
;
y
=
q
.z
;
log
(
debug
,
y
);
...
...
src/test/run-pass/generic-tag-values.rs
浏览文件 @
6d4907a7
...
...
@@ -14,10 +14,12 @@
// -*- rust -*-
enum
noption
<
T
>
{
some
(
T
),
}
struct
Pair
{
x
:
int
,
y
:
int
}
fn
main
()
{
let
nop
:
noption
<
int
>
=
some
::
<
int
>
(
5
);
match
nop
{
some
::
<
int
>
(
n
)
=>
{
log
(
debug
,
n
);
assert
(
n
==
5
);
}
}
let
nop2
:
noption
<
{
x
:
int
,
y
:
int
}
>
=
some
(
{
x
:
17
,
y
:
42
});
let
nop2
:
noption
<
Pair
>
=
some
(
Pair
{
x
:
17
,
y
:
42
});
match
nop2
{
some
(
t
)
=>
{
log
(
debug
,
t
.x
);
...
...
src/test/run-pass/generic-type.rs
浏览文件 @
6d4907a7
...
...
@@ -10,10 +10,10 @@
type
pair
<
T
>
=
{
x
:
T
,
y
:
T
};
struct
Pair
<
T
>
{
x
:
T
,
y
:
T
}
fn
main
()
{
let
x
:
pair
<
int
>
=
{
x
:
10
,
y
:
12
};
let
x
:
Pair
<
int
>
=
Pair
{
x
:
10
,
y
:
12
};
assert
(
x
.x
==
10
);
assert
(
x
.y
==
12
);
}
src/test/run-pass/generic-unique.rs
浏览文件 @
6d4907a7
...
...
@@ -8,10 +8,11 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
struct
Triple
<
T
>
{
x
:
T
,
y
:
T
,
z
:
T
}
fn
box
<
T
:
Copy
>
(
x
:
{
x
:
T
,
y
:
T
,
z
:
T
})
->
~
{
x
:
T
,
y
:
T
,
z
:
T
}
{
return
~
x
;
}
fn
box
<
T
:
Copy
>
(
x
:
Triple
<
T
>
)
->
~
Triple
<
T
>
{
return
~
x
;
}
fn
main
()
{
let
x
:
~
{
x
:
int
,
y
:
int
,
z
:
int
}
=
box
::
<
int
>
(
{
x
:
1
,
y
:
2
,
z
:
3
});
let
x
:
~
Triple
<
int
>
=
box
::
<
int
>
(
Triple
{
x
:
1
,
y
:
2
,
z
:
3
});
assert
(
x
.y
==
2
);
}
src/test/run-pass/guards.rs
浏览文件 @
6d4907a7
...
...
@@ -8,16 +8,18 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
struct
Pair
{
x
:
int
,
y
:
int
}
fn
main
()
{
let
a
=
match
10
{
x
if
x
<
7
=>
{
1
}
x
if
x
<
11
=>
{
2
}
10
=>
{
3
}
_
=>
{
4
}
};
assert
(
a
==
2
);
let
b
=
match
{
x
:
10
,
y
:
20
}
{
match
Pair
{
x
:
10
,
y
:
20
}
{
x
if
x
.x
<
5
&&
x
.y
<
5
=>
{
1
}
{
x
:
x
,
y
:
y
}
if
x
==
10
&&
y
==
20
=>
{
2
}
{
x
:
x
,
y
:
y
}
=>
{
3
}
Pair
{
x
:
x
,
y
:
y
}
if
x
==
10
&&
y
==
20
=>
{
2
}
Pair
{
x
:
x
,
y
:
y
}
=>
{
3
}
};
assert
(
b
==
2
);
}
src/test/run-pass/infer-with-expected.rs
浏览文件 @
6d4907a7
...
...
@@ -13,10 +13,13 @@
// type must be known in this context' if the passing down doesn't
// happen.)
fn
eat_tup
(
_
r
:
~@
(
int
,
fn
@
({
x
:
int
,
y
:
int
})
->
int
))
{}
fn
eat_rec
(
_
r
:
@~
{
a
:
int
,
b
:
fn
@
({
x
:
int
,
y
:
int
})
->
int
})
{}
fn
eat_tup
(
_
r
:
~@
(
int
,
fn
@
(
Pair
)
->
int
))
{}
fn
eat_rec
(
_
r
:
@~
Rec
)
{}
struct
Rec
{
a
:
int
,
b
:
fn
(
Pair
)
->
int
}
struct
Pair
{
x
:
int
,
y
:
int
}
fn
main
()
{
eat_tup
(
~@
(
10
,
|
a
|
a
.x
));
eat_rec
(
@~
{
a
:
10
,
b
:
|
a
|
a
.x
});
eat_rec
(
@~
Rec
{
a
:
10
,
b
:
|
a
|
a
.x
});
}
src/test/run-pass/init-res-into-things.rs
浏览文件 @
6d4907a7
...
...
@@ -15,6 +15,8 @@ struct r {
i
:
@
mut
int
,
}
struct
Box
{
x
:
r
}
impl
r
:
Drop
{
fn
finalize
(
&
self
)
{
*
(
self
.i
)
=
*
(
self
.i
)
+
1
;
...
...
@@ -38,7 +40,7 @@ fn test_box() {
fn
test_rec
()
{
let
i
=
@
mut
0
;
{
let
a
=
move
{
x
:
r
(
i
)};
let
a
=
move
Box
{
x
:
r
(
i
)};
}
assert
*
i
==
1
;
}
...
...
@@ -74,7 +76,7 @@ fn test_unique() {
fn
test_box_rec
()
{
let
i
=
@
mut
0
;
{
let
a
=
move
@
{
let
a
=
move
@
Box
{
x
:
r
(
i
)
};
}
...
...
src/test/run-pass/instantiable.rs
浏览文件 @
6d4907a7
...
...
@@ -11,9 +11,11 @@
// check that we do not report a type like this as uninstantiable,
// even though it would be if the nxt field had type @foo:
enum
foo
=
{
x
:
uint
,
nxt
:
*
foo
};
enum
foo
=
X
;
struct
X
{
x
:
uint
,
nxt
:
*
foo
}
fn
main
()
{
let
x
=
foo
(
{
x
:
0u
,
nxt
:
ptr
::
null
()});
let
x
=
foo
(
X
{
x
:
0
,
nxt
:
ptr
::
null
()});
}
src/test/run-pass/issue-1112.rs
浏览文件 @
6d4907a7
...
...
@@ -11,7 +11,7 @@
// Issue #1112
// Alignment of interior pointers to dynamic-size types
type
x
<
T
>
=
{
struct
X
<
T
>
{
a
:
T
,
b
:
u8
,
c
:
bool
,
...
...
@@ -19,10 +19,10 @@
e
:
u16
,
f
:
u8
,
g
:
u8
}
;
}
fn
main
()
{
let
x
:
x
<
int
>
=
{
let
x
:
X
<
int
>
=
X
{
a
:
12345678
,
b
:
9u8
,
c
:
true
,
...
...
@@ -34,7 +34,7 @@ fn main() {
bar
(
x
);
}
fn
bar
<
T
>
(
x
:
x
<
T
>
)
{
fn
bar
<
T
>
(
x
:
X
<
T
>
)
{
assert
x
.b
==
9u8
;
assert
x
.c
==
true
;
assert
x
.d
==
10u8
;
...
...
src/test/run-pass/issue-1989.rs
浏览文件 @
6d4907a7
...
...
@@ -12,16 +12,16 @@
enum
maybe_pointy
{
none
,
p
(
@
p
ointy
)
p
(
@
P
ointy
)
}
type
pointy
=
{
struct
Pointy
{
mut
a
:
maybe_pointy
,
mut
f
:
fn
@
()
->
(),
}
;
}
fn
empty_pointy
()
->
@
p
ointy
{
return
@
{
fn
empty_pointy
()
->
@
P
ointy
{
return
@
Pointy
{
mut
a
:
none
,
mut
f
:
fn
@
()
->
(){},
}
...
...
src/test/run-pass/issue-2463.rs
浏览文件 @
6d4907a7
...
...
@@ -8,20 +8,22 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
struct
Pair
{
f
:
int
,
g
:
int
}
fn
main
()
{
let
x
=
{
let
x
=
Pair
{
f
:
0
,
g
:
0
,
};
let
y
=
{
let
y
=
Pair
{
f
:
1
,
g
:
1
,
..
x
};
let
z
=
{
let
z
=
Pair
{
f
:
1
,
..
x
};
...
...
src/test/run-pass/issue-2633.rs
浏览文件 @
6d4907a7
...
...
@@ -18,14 +18,14 @@ fn cat() -> cat {
}
}
type
kitty_info
=
{
kitty
:
cat
};
struct
KittyInfo
{
kitty
:
cat
}
// Code compiles and runs successfully if we add a + before the first arg
fn
nyan
(
kitty
:
cat
,
_
kitty_info
:
kitty_i
nfo
)
{
fn
nyan
(
kitty
:
cat
,
_
kitty_info
:
KittyI
nfo
)
{
(
kitty
.meow
)();
}
fn
main
()
{
let
mut
kitty
=
cat
();
nyan
(
copy
kitty
,
{
kitty
:
copy
kitty
});
nyan
(
copy
kitty
,
KittyInfo
{
kitty
:
copy
kitty
});
}
src/test/run-pass/issue-2718.rs
浏览文件 @
6d4907a7
...
...
@@ -14,6 +14,12 @@
pub
mod
pipes
{
use
core
::
cast
::{
forget
,
transmute
};
pub
struct
Stuff
<
T
>
{
mut
state
:
state
,
mut
blocked_task
:
Option
<
task
::
Task
>
,
mut
payload
:
Option
<
T
>
}
pub
enum
state
{
empty
,
full
,
...
...
@@ -36,7 +42,7 @@ pub impl state : cmp::Eq {
pub
fn
packet
<
T
:
Owned
>
()
->
*
packet
<
T
>
{
unsafe
{
let
p
:
*
packet
<
T
>
=
cast
::
transmute
(
~
{
let
p
:
*
packet
<
T
>
=
cast
::
transmute
(
~
Stuff
{
mut
state
:
empty
,
mut
blocked_task
:
None
::
<
task
::
Task
>
,
mut
payload
:
None
::
<
T
>
...
...
src/test/run-pass/issue-2989.rs
浏览文件 @
6d4907a7
...
...
@@ -22,7 +22,7 @@ fn to_bytes() -> ~[u8] {
// the position of this function is significant! - if it comes before methods
// then it works, if it comes after it then it doesnt!
fn
to_bools
(
bitv
:
{
storage
:
~
[
u64
]}
)
->
~
[
bool
]
{
fn
to_bools
(
bitv
:
Storage
)
->
~
[
bool
]
{
vec
::
from_fn
(
8
,
|
i
|
{
let
w
=
i
/
64
;
let
b
=
i
%
64
;
...
...
@@ -31,9 +31,11 @@ fn to_bools(bitv: {storage: ~[u64]}) -> ~[bool] {
})
}
struct
Storage
{
storage
:
~
[
u64
]
}
fn
main
()
{
let
bools
=
~
[
false
,
false
,
true
,
false
,
false
,
true
,
true
,
false
];
let
bools2
=
to_bools
({
storage
:
~
[
0b01100100
]});
let
bools2
=
to_bools
(
Storage
{
storage
:
~
[
0b01100100
]});
for
uint
::
range
(
0
,
8
)
|
i
|
{
io
::
println
(
fmt!
(
"%u => %u vs %u"
,
i
,
bools
[
i
]
as
uint
,
bools2
[
i
]
as
uint
));
...
...
src/test/run-pass/issue-980.rs
浏览文件 @
6d4907a7
...
...
@@ -10,14 +10,14 @@
enum
maybe_pointy
{
no_pointy
,
yes_pointy
(
@
p
ointy
),
yes_pointy
(
@
P
ointy
),
}
type
pointy
=
{
struct
Pointy
{
mut
x
:
maybe_pointy
}
;
}
fn
main
()
{
let
m
=
@
{
mut
x
:
no_pointy
};
let
m
=
@
Pointy
{
mut
x
:
no_pointy
};
m
.x
=
yes_pointy
(
m
);
}
src/test/run-pass/lambda-infer-unresolved.rs
浏览文件 @
6d4907a7
...
...
@@ -10,8 +10,12 @@
// This should typecheck even though the type of e is not fully
// resolved when we finish typechecking the fn@.
struct
Refs
{
mut
refs
:
~
[
int
],
n
:
int
}
fn
main
()
{
let
e
=
@
{
mut
refs
:
~
[],
n
:
0
};
let
e
=
@
Refs
{
mut
refs
:
~
[],
n
:
0
};
let
f
=
fn
@
()
{
log
(
error
,
e
.n
);
};
e
.refs
+=
~
[
1
];
}
src/test/run-pass/large-records.rs
浏览文件 @
6d4907a7
...
...
@@ -12,9 +12,8 @@
// -*- rust -*-
fn
f
()
{
let
foo
:
{
a
:
int
,
struct
Large
{
a
:
int
,
b
:
int
,
c
:
int
,
d
:
int
,
...
...
@@ -25,8 +24,10 @@ fn f() {
i
:
int
,
j
:
int
,
k
:
int
,
l
:
int
}
=
{
a
:
0
,
l
:
int
}
fn
f
()
{
let
foo
:
Large
=
Large
{
a
:
0
,
b
:
0
,
c
:
0
,
d
:
0
,
...
...
src/test/run-pass/last-use-in-cap-clause.rs
浏览文件 @
6d4907a7
...
...
@@ -10,9 +10,11 @@
// Make sure #1399 stays fixed
struct
A
{
a
:
~
int
}
fn
foo
()
->
fn
@
()
->
int
{
let
k
=
~
22
;
let
_u
=
{
a
:
copy
k
};
let
_u
=
A
{
a
:
copy
k
};
return
fn
@
(
move
k
)
->
int
{
22
};
}
...
...
src/test/run-pass/last-use-is-capture.rs
浏览文件 @
6d4907a7
...
...
@@ -10,9 +10,11 @@
// Make sure #1399 stays fixed
struct
A
{
a
:
~
int
}
fn
main
()
{
fn
invoke
(
f
:
fn
@
())
{
f
();
}
let
k
=
~
22
;
let
_u
=
{
a
:
copy
k
};
let
_u
=
A
{
a
:
copy
k
};
invoke
(||
log
(
error
,
copy
k
)
)
}
src/test/run-pass/let-destruct-fresh-mem.rs
浏览文件 @
6d4907a7
...
...
@@ -8,9 +8,12 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
struct
X
{
x
:
int
,
y
:
@
A
}
struct
A
{
a
:
int
}
fn
main
()
{
let
u
=
{
x
:
10
,
y
:
@
{
a
:
20
}};
let
mut
{
x
:
x
,
y
:
@
{
a
:
a
}}
=
u
;
let
u
=
X
{
x
:
10
,
y
:
@
A
{
a
:
20
}};
let
mut
X
{
x
:
x
,
y
:
@
A
{
a
:
a
}}
=
u
;
x
=
100
;
a
=
100
;
assert
(
x
==
100
);
...
...
src/test/run-pass/let-destruct.rs
浏览文件 @
6d4907a7
...
...
@@ -10,7 +10,9 @@
enum
xx
=
int
;
struct
X
{
x
:
xx
,
y
:
int
}
fn
main
()
{
let
@
{
x
:
xx
(
x
),
y
:
y
}
=
@
{
x
:
xx
(
10
),
y
:
20
};
let
@
X
{
x
:
xx
(
x
),
y
:
y
}
=
@
X
{
x
:
xx
(
10
),
y
:
20
};
assert
(
x
+
y
==
30
);
}
src/test/run-pass/log-linearized.rs
浏览文件 @
6d4907a7
...
...
@@ -15,11 +15,13 @@ enum option<T> {
some
(
T
),
}
type
smallintmap
<
T
>
=
@
{
mut
v
:
~
[
mut
option
<
T
>
]};
struct
Smallintmap
<
T
>
{
mut
v
:
~
[
mut
option
<
T
>
]}
fn
mk
<
T
>
()
->
smallintmap
<
T
>
{
struct
V
<
T
>
{
v
:
~
[
mut
option
<
T
>
]
}
fn
mk
<
T
>
()
->
@
Smallintmap
<
T
>
{
let
v
:
~
[
mut
option
<
T
>
]
=
~
[
mut
];
return
@
{
mut
v
:
move
v
};
return
@
Smallintmap
{
mut
v
:
move
v
};
}
fn
f
<
T
,
U
>
()
{
...
...
src/test/run-pass/morestack4.rs
浏览文件 @
6d4907a7
...
...
@@ -11,7 +11,7 @@
// This is testing for stack frames greater than 256 bytes,
// for which function prologues are generated differently
type
biggy
=
{
struct
Biggy
{
a00
:
u64
,
a01
:
u64
,
a02
:
u64
,
...
...
@@ -52,17 +52,17 @@
a37
:
u64
,
a38
:
u64
,
a39
:
u64
,
}
;
}
fn
getbig
(
i
:
b
iggy
)
{
fn
getbig
(
i
:
B
iggy
)
{
if
i
.a00
!=
0u64
{
getbig
({
a00
:
i
.a00
-
1u64
,
..
i
});
getbig
(
Biggy
{
a00
:
i
.a00
-
1u64
,
..
i
});
}
}
fn
main
()
{
getbig
({
getbig
(
Biggy
{
a00
:
10000u64
,
a01
:
10000u64
,
a02
:
10000u64
,
...
...
src/test/run-pass/move-1-unique.rs
浏览文件 @
6d4907a7
...
...
@@ -8,16 +8,17 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
struct
Triple
{
x
:
int
,
y
:
int
,
z
:
int
}
fn
test
(
x
:
bool
,
foo
:
~
{
x
:
int
,
y
:
int
,
z
:
int
}
)
->
int
{
fn
test
(
x
:
bool
,
foo
:
~
Triple
)
->
int
{
let
bar
=
foo
;
let
mut
y
:
~
{
x
:
int
,
y
:
int
,
z
:
int
}
;
if
x
{
y
=
move
bar
;
}
else
{
y
=
~
{
x
:
4
,
y
:
5
,
z
:
6
};
}
let
mut
y
:
~
Triple
;
if
x
{
y
=
move
bar
;
}
else
{
y
=
~
Triple
{
x
:
4
,
y
:
5
,
z
:
6
};
}
return
y
.y
;
}
fn
main
()
{
let
x
=
~
{
x
:
1
,
y
:
2
,
z
:
3
};
let
x
=
~
Triple
{
x
:
1
,
y
:
2
,
z
:
3
};
assert
(
test
(
true
,
x
)
==
2
);
assert
(
test
(
true
,
x
)
==
2
);
assert
(
test
(
true
,
x
)
==
2
);
...
...
src/test/run-pass/move-1.rs
浏览文件 @
6d4907a7
...
...
@@ -8,15 +8,17 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
fn
test
(
x
:
bool
,
foo
:
@
{
x
:
int
,
y
:
int
,
z
:
int
})
->
int
{
struct
Triple
{
x
:
int
,
y
:
int
,
z
:
int
}
fn
test
(
x
:
bool
,
foo
:
@
Triple
)
->
int
{
let
bar
=
foo
;
let
mut
y
:
@
{
x
:
int
,
y
:
int
,
z
:
int
}
;
if
x
{
y
=
move
bar
;
}
else
{
y
=
@
{
x
:
4
,
y
:
5
,
z
:
6
};
}
let
mut
y
:
@
Triple
;
if
x
{
y
=
move
bar
;
}
else
{
y
=
@
Triple
{
x
:
4
,
y
:
5
,
z
:
6
};
}
return
y
.y
;
}
fn
main
()
{
let
x
=
@
{
x
:
1
,
y
:
2
,
z
:
3
};
let
x
=
@
Triple
{
x
:
1
,
y
:
2
,
z
:
3
};
assert
(
test
(
true
,
x
)
==
2
);
assert
(
test
(
true
,
x
)
==
2
);
assert
(
test
(
true
,
x
)
==
2
);
...
...
src/test/run-pass/move-2-unique.rs
浏览文件 @
6d4907a7
...
...
@@ -9,5 +9,6 @@
// except according to those terms.
struct
X
{
x
:
int
,
y
:
int
,
z
:
int
}
fn
main
()
{
let
x
=
~
{
x
:
1
,
y
:
2
,
z
:
3
};
let
y
=
move
x
;
assert
(
y
.y
==
2
);
}
fn
main
()
{
let
x
=
~
X
{
x
:
1
,
y
:
2
,
z
:
3
};
let
y
=
move
x
;
assert
(
y
.y
==
2
);
}
src/test/run-pass/move-2.rs
浏览文件 @
6d4907a7
...
...
@@ -9,5 +9,6 @@
// except according to those terms.
struct
X
{
x
:
int
,
y
:
int
,
z
:
int
}
fn
main
()
{
let
x
=
@
{
x
:
1
,
y
:
2
,
z
:
3
};
let
y
=
move
x
;
assert
(
y
.y
==
2
);
}
fn
main
()
{
let
x
=
@
X
{
x
:
1
,
y
:
2
,
z
:
3
};
let
y
=
move
x
;
assert
(
y
.y
==
2
);
}
src/test/run-pass/move-3-unique.rs
浏览文件 @
6d4907a7
...
...
@@ -10,15 +10,17 @@
extern
mod
std
;
fn
test
(
x
:
bool
,
foo
:
~
{
x
:
int
,
y
:
int
,
z
:
int
})
->
int
{
struct
Triple
{
x
:
int
,
y
:
int
,
z
:
int
}
fn
test
(
x
:
bool
,
foo
:
~
Triple
)
->
int
{
let
bar
=
foo
;
let
mut
y
:
~
{
x
:
int
,
y
:
int
,
z
:
int
}
;
if
x
{
y
=
move
bar
;
}
else
{
y
=
~
{
x
:
4
,
y
:
5
,
z
:
6
};
}
let
mut
y
:
~
Triple
;
if
x
{
y
=
move
bar
;
}
else
{
y
=
~
Triple
{
x
:
4
,
y
:
5
,
z
:
6
};
}
return
y
.y
;
}
fn
main
()
{
let
x
=
~
{
x
:
1
,
y
:
2
,
z
:
3
};
let
x
=
~
Triple
{
x
:
1
,
y
:
2
,
z
:
3
};
for
uint
::
range
(
0u
,
10000u
)
|
_
i
|
{
assert
(
test
(
true
,
x
)
==
2
);
}
...
...
src/test/run-pass/move-3.rs
浏览文件 @
6d4907a7
...
...
@@ -10,15 +10,17 @@
extern
mod
std
;
fn
test
(
x
:
bool
,
foo
:
@
{
x
:
int
,
y
:
int
,
z
:
int
})
->
int
{
struct
Triple
{
x
:
int
,
y
:
int
,
z
:
int
}
fn
test
(
x
:
bool
,
foo
:
@
Triple
)
->
int
{
let
bar
=
foo
;
let
mut
y
:
@
{
x
:
int
,
y
:
int
,
z
:
int
}
;
if
x
{
y
=
move
bar
;
}
else
{
y
=
@
{
x
:
4
,
y
:
5
,
z
:
6
};
}
let
mut
y
:
@
Triple
;
if
x
{
y
=
move
bar
;
}
else
{
y
=
@
Triple
{
x
:
4
,
y
:
5
,
z
:
6
};
}
return
y
.y
;
}
fn
main
()
{
let
x
=
@
{
x
:
1
,
y
:
2
,
z
:
3
};
let
x
=
@
Triple
{
x
:
1
,
y
:
2
,
z
:
3
};
for
uint
::
range
(
0u
,
10000u
)
|
i
|
{
assert
(
test
(
true
,
x
)
==
2
);
}
...
...
src/test/run-pass/move-4-unique.rs
浏览文件 @
6d4907a7
...
...
@@ -10,7 +10,9 @@
extern
mod
std
;
fn
test
(
foo
:
~
{
a
:
int
,
b
:
int
,
c
:
int
})
->
~
{
a
:
int
,
b
:
int
,
c
:
int
}
{
struct
Triple
{
a
:
int
,
b
:
int
,
c
:
int
}
fn
test
(
foo
:
~
Triple
)
->
~
Triple
{
let
foo
=
foo
;
let
bar
=
move
foo
;
let
baz
=
move
bar
;
...
...
@@ -18,4 +20,4 @@ fn test(foo: ~{a: int, b: int, c: int}) -> ~{a: int, b: int, c: int} {
return
quux
;
}
fn
main
()
{
let
x
=
~
{
a
:
1
,
b
:
2
,
c
:
3
};
let
y
=
test
(
x
);
assert
(
y
.c
==
3
);
}
fn
main
()
{
let
x
=
~
Triple
{
a
:
1
,
b
:
2
,
c
:
3
};
let
y
=
test
(
x
);
assert
(
y
.c
==
3
);
}
src/test/run-pass/move-4.rs
浏览文件 @
6d4907a7
...
...
@@ -11,7 +11,9 @@
extern
mod
std
;
fn
test
(
foo
:
@
{
a
:
int
,
b
:
int
,
c
:
int
})
->
@
{
a
:
int
,
b
:
int
,
c
:
int
}
{
struct
Triple
{
a
:
int
,
b
:
int
,
c
:
int
}
fn
test
(
foo
:
@
Triple
)
->
@
Triple
{
let
foo
=
foo
;
let
bar
=
move
foo
;
let
baz
=
move
bar
;
...
...
@@ -19,4 +21,8 @@ fn test(foo: @{a: int, b: int, c: int}) -> @{a: int, b: int, c: int} {
return
quux
;
}
fn
main
()
{
let
x
=
@
{
a
:
1
,
b
:
2
,
c
:
3
};
let
y
=
test
(
x
);
assert
(
y
.c
==
3
);
}
fn
main
()
{
let
x
=
@
Triple
{
a
:
1
,
b
:
2
,
c
:
3
};
let
y
=
test
(
x
);
assert
(
y
.c
==
3
);
}
src/test/run-pass/mutable-vec-drop.rs
浏览文件 @
6d4907a7
...
...
@@ -9,8 +9,10 @@
// except according to those terms.
struct
Pair
{
a
:
int
,
b
:
int
}
fn
main
()
{
// This just tests whether the vec leaks its members.
let
pvec
:
~
[
mut
@
{
a
:
int
,
b
:
int
}
]
=
~
[
mut
@
{
a
:
1
,
b
:
2
},
@
{
a
:
3
,
b
:
4
},
@
{
a
:
5
,
b
:
6
}];
let
pvec
:
~
[
mut
@
Pair
]
=
~
[
mut
@
Pair
{
a
:
1
,
b
:
2
},
@
Pair
{
a
:
3
,
b
:
4
},
@
Pair
{
a
:
5
,
b
:
6
}];
}
src/test/run-pass/nested-exhaustive-alt.rs
浏览文件 @
6d4907a7
...
...
@@ -8,11 +8,13 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
struct
Foo
{
foo
:
bool
,
bar
:
Option
<
int
>
,
baz
:
int
}
fn
main
()
{
match
@
{
foo
:
true
,
bar
:
Some
(
10
),
baz
:
20
}
{
@
{
foo
:
true
,
bar
:
Some
(
_
),
_
}
=>
{}
@
{
foo
:
false
,
bar
:
None
,
_
}
=>
{}
@
{
foo
:
true
,
bar
:
None
,
_
}
=>
{}
@
{
foo
:
false
,
bar
:
Some
(
_
),
_
}
=>
{}
match
@
Foo
{
foo
:
true
,
bar
:
Some
(
10
),
baz
:
20
}
{
@
Foo
{
foo
:
true
,
bar
:
Some
(
_
),
_
}
=>
{}
@
Foo
{
foo
:
false
,
bar
:
None
,
_
}
=>
{}
@
Foo
{
foo
:
true
,
bar
:
None
,
_
}
=>
{}
@
Foo
{
foo
:
false
,
bar
:
Some
(
_
),
_
}
=>
{}
}
}
src/test/run-pass/nested-patterns.rs
浏览文件 @
6d4907a7
...
...
@@ -8,15 +8,20 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
struct
A
{
a
:
int
,
b
:
@
int
}
struct
B
{
a
:
int
,
b
:
C
}
struct
D
{
a
:
int
,
d
:
C
}
struct
C
{
mut
c
:
int
}
fn
main
()
{
match
{
a
:
10
,
b
:
@
20
}
{
x
@
{
a
,
b
:
@
20
}
=>
{
assert
x
.a
==
10
;
assert
a
==
10
;
}
{
b
,
_
}
=>
{
fail
;
}
match
A
{
a
:
10
,
b
:
@
20
}
{
x
@
A
{
a
,
b
:
@
20
}
=>
{
assert
x
.a
==
10
;
assert
a
==
10
;
}
A
{
b
,
_
}
=>
{
fail
;
}
}
let
x
@
{
b
,
_
}
=
{
a
:
10
,
b
:
{
mut
c
:
20
}};
let
x
@
B
{
b
,
_
}
=
B
{
a
:
10
,
b
:
C
{
mut
c
:
20
}};
x
.b.c
=
30
;
assert
b
.c
==
20
;
let
y
@
{
d
,
_
}
=
{
a
:
10
,
d
:
{
mut
c
:
20
}};
let
y
@
D
{
d
,
_
}
=
D
{
a
:
10
,
d
:
C
{
mut
c
:
20
}};
y
.d.c
=
30
;
assert
d
.c
==
20
;
}
src/test/run-pass/newtype.rs
浏览文件 @
6d4907a7
...
...
@@ -8,11 +8,13 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
enum
mytype
=
{
compute
:
extern
fn
(
mytype
)
->
int
,
val
:
int
};
enum
mytype
=
Mytype
;
struct
Mytype
{
compute
:
extern
fn
(
mytype
)
->
int
,
val
:
int
}
fn
compute
(
i
:
mytype
)
->
int
{
return
i
.val
+
20
;
}
fn
main
()
{
let
myval
=
mytype
({
compute
:
compute
,
val
:
30
});
let
myval
=
mytype
(
Mytype
{
compute
:
compute
,
val
:
30
});
assert
((
myval
.compute
)(
myval
)
==
50
);
}
src/test/run-pass/output-slot-variants.rs
浏览文件 @
6d4907a7
...
...
@@ -8,27 +8,28 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
struct
A
{
a
:
int
,
b
:
int
}
struct
Abox
{
a
:
@
int
,
b
:
@
int
}
fn
ret_int_i
()
->
int
{
return
10
;
}
fn
ret_ext_i
()
->
@
int
{
return
@
10
;
}
fn
ret_int_rec
()
->
{
a
:
int
,
b
:
int
}
{
return
{
a
:
10
,
b
:
10
};
}
fn
ret_int_rec
()
->
A
{
return
A
{
a
:
10
,
b
:
10
};
}
fn
ret_ext_rec
()
->
@
{
a
:
int
,
b
:
int
}
{
return
@
{
a
:
10
,
b
:
10
};
}
fn
ret_ext_rec
()
->
@
A
{
return
@
A
{
a
:
10
,
b
:
10
};
}
fn
ret_ext_mem
()
->
{
a
:
@
int
,
b
:
@
int
}
{
return
{
a
:
@
10
,
b
:
@
10
};
}
fn
ret_ext_mem
()
->
Abox
{
return
Abox
{
a
:
@
10
,
b
:
@
10
};
}
fn
ret_ext_ext_mem
()
->
@
{
a
:
@
int
,
b
:
@
int
}
{
return
@
{
a
:
@
10
,
b
:
@
10
};
}
fn
ret_ext_ext_mem
()
->
@
Abox
{
return
@
Abox
{
a
:
@
10
,
b
:
@
10
};
}
fn
main
()
{
let
mut
int_i
:
int
;
let
mut
ext_i
:
@
int
;
let
mut
int_rec
:
{
a
:
int
,
b
:
int
}
;
let
mut
ext_rec
:
@
{
a
:
int
,
b
:
int
}
;
let
mut
ext_mem
:
{
a
:
@
int
,
b
:
@
int
}
;
let
mut
ext_ext_mem
:
@
{
a
:
@
int
,
b
:
@
int
}
;
let
mut
int_rec
:
A
;
let
mut
ext_rec
:
@
A
;
let
mut
ext_mem
:
Abox
;
let
mut
ext_ext_mem
:
@
Abox
;
int_i
=
ret_int_i
();
// initializing
int_i
=
ret_int_i
();
// non-initializing
...
...
src/test/run-pass/pass-by-copy.rs
浏览文件 @
6d4907a7
...
...
@@ -8,11 +8,13 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
fn
magic
(
+
x
:
{
a
:
@
int
}
)
{
log
(
debug
,
x
);
}
fn
magic
(
+
x
:
A
)
{
log
(
debug
,
x
);
}
fn
magic2
(
+
x
:
@
int
)
{
log
(
debug
,
x
);
}
struct
A
{
a
:
@
int
}
fn
main
()
{
let
a
=
{
a
:
@
10
},
b
=
@
10
;
magic
(
a
);
magic
({
a
:
@
20
});
let
a
=
A
{
a
:
@
10
},
b
=
@
10
;
magic
(
a
);
magic
(
A
{
a
:
@
20
});
magic2
(
b
);
magic2
(
@
20
);
}
src/test/run-pass/pure-fmt.rs
浏览文件 @
6d4907a7
...
...
@@ -10,9 +10,12 @@
// Testing that calling fmt! (via debug!) doesn't complain about impure borrows
struct
Big
{
b
:
@~
str
,
c
:
uint
,
d
:
int
,
e
:
char
,
f
:
float
,
g
:
bool
}
pure
fn
foo
()
{
let
a
=
{
b
:
@
"hi"
,
let
a
=
Big
{
b
:
@
~
"hi"
,
c
:
0
,
d
:
1
,
e
:
'a'
,
...
...
src/test/run-pass/pure-sum.rs
浏览文件 @
6d4907a7
...
...
@@ -29,7 +29,7 @@
}
pure
fn
sums_to_using_rec
(
v
:
~
[
int
],
sum
:
int
)
->
bool
{
let
mut
i
=
0u
,
sum0
=
{
f
:
0
};
let
mut
i
=
0u
,
sum0
=
F
{
f
:
0
};
while
i
<
v
.len
()
{
sum0
.f
+=
v
[
i
];
i
+=
1u
;
...
...
@@ -37,8 +37,10 @@
return
sum0
.f
==
sum
;
}
struct
F
<
T
>
{
f
:
T
}
pure
fn
sums_to_using_uniq_rec
(
v
:
~
[
int
],
sum
:
int
)
->
bool
{
let
mut
i
=
0u
,
sum0
=
{
f
:
~
mut
0
};
let
mut
i
=
0u
,
sum0
=
F
{
f
:
~
mut
0
};
while
i
<
v
.len
()
{
*
sum0
.f
+=
v
[
i
];
i
+=
1u
;
...
...
src/test/run-pass/readalias.rs
浏览文件 @
6d4907a7
...
...
@@ -12,8 +12,8 @@
// -*- rust -*-
type
point
=
{
x
:
int
,
y
:
int
,
z
:
int
};
struct
Point
{
x
:
int
,
y
:
int
,
z
:
int
}
fn
f
(
p
:
p
oint
)
{
assert
(
p
.z
==
12
);
}
fn
f
(
p
:
P
oint
)
{
assert
(
p
.z
==
12
);
}
fn
main
()
{
let
x
:
point
=
{
x
:
10
,
y
:
11
,
z
:
12
};
f
(
x
);
}
fn
main
()
{
let
x
:
Point
=
Point
{
x
:
10
,
y
:
11
,
z
:
12
};
f
(
x
);
}
src/test/run-pass/rec-align-u32.rs
浏览文件 @
6d4907a7
...
...
@@ -18,16 +18,16 @@
}
// This is the type with the questionable alignment
type
inner
=
{
struct
Inner
{
c64
:
u32
}
;
}
// This is the type that contains the type with the
// questionable alignment, for testing
type
outer
=
{
struct
Outer
{
c8
:
u8
,
t
:
i
nner
}
;
t
:
I
nner
}
#[cfg(target_arch
=
"x86"
)]
...
...
@@ -46,21 +46,21 @@ fn size() -> uint { 8u }
fn
main
()
{
unsafe
{
let
x
=
{
c8
:
22u8
,
t
:
{
c64
:
44u32
}};
let
x
=
Outer
{
c8
:
22u8
,
t
:
Inner
{
c64
:
44u32
}};
// Send it through the shape code
let
y
=
fmt!
(
"%?"
,
x
);
debug!
(
"align inner = %?"
,
rusti
::
min_align_of
::
<
i
nner
>
());
debug!
(
"size outer = %?"
,
sys
::
size_of
::
<
o
uter
>
());
debug!
(
"align inner = %?"
,
rusti
::
min_align_of
::
<
I
nner
>
());
debug!
(
"size outer = %?"
,
sys
::
size_of
::
<
O
uter
>
());
debug!
(
"y = %s"
,
y
);
// per clang/gcc the alignment of `inner` is 4 on x86.
assert
rusti
::
min_align_of
::
<
i
nner
>
()
==
m
::
align
();
assert
rusti
::
min_align_of
::
<
I
nner
>
()
==
m
::
align
();
// per clang/gcc the size of `outer` should be 12
// because `inner`s alignment was 4.
assert
sys
::
size_of
::
<
o
uter
>
()
==
m
::
size
();
assert
sys
::
size_of
::
<
O
uter
>
()
==
m
::
size
();
assert
y
==
~
"{c8: 22, t: {c64: 44}}"
;
}
...
...
src/test/run-pass/rec-align-u64.rs
浏览文件 @
6d4907a7
...
...
@@ -18,16 +18,16 @@
}
// This is the type with the questionable alignment
type
inner
=
{
struct
Inner
{
c64
:
u64
}
;
}
// This is the type that contains the type with the
// questionable alignment, for testing
type
outer
=
{
struct
Outer
{
c8
:
u8
,
t
:
i
nner
}
;
t
:
I
nner
}
#[cfg(target_os
=
"linux"
)]
...
...
@@ -63,21 +63,21 @@ fn size() -> uint { 16u }
fn
main
()
{
unsafe
{
let
x
=
{
c8
:
22u8
,
t
:
{
c64
:
44u64
}};
let
x
=
Outer
{
c8
:
22u8
,
t
:
Inner
{
c64
:
44u64
}};
// Send it through the shape code
let
y
=
fmt!
(
"%?"
,
x
);
debug!
(
"align inner = %?"
,
rusti
::
min_align_of
::
<
i
nner
>
());
debug!
(
"size outer = %?"
,
sys
::
size_of
::
<
o
uter
>
());
debug!
(
"align inner = %?"
,
rusti
::
min_align_of
::
<
I
nner
>
());
debug!
(
"size outer = %?"
,
sys
::
size_of
::
<
O
uter
>
());
debug!
(
"y = %s"
,
y
);
// per clang/gcc the alignment of `
i
nner` is 4 on x86.
assert
rusti
::
min_align_of
::
<
i
nner
>
()
==
m
::
m
::
align
();
// per clang/gcc the alignment of `
I
nner` is 4 on x86.
assert
rusti
::
min_align_of
::
<
I
nner
>
()
==
m
::
m
::
align
();
// per clang/gcc the size of `
o
uter` should be 12
// because `
i
nner`s alignment was 4.
assert
sys
::
size_of
::
<
o
uter
>
()
==
m
::
m
::
size
();
// per clang/gcc the size of `
O
uter` should be 12
// because `
I
nner`s alignment was 4.
assert
sys
::
size_of
::
<
O
uter
>
()
==
m
::
m
::
size
();
assert
y
==
~
"{c8: 22, t: {c64: 44}}"
;
}
...
...
src/test/run-pass/rec-auto.rs
浏览文件 @
6d4907a7
...
...
@@ -14,8 +14,11 @@
// -*- rust -*-
// Issue #50.
struct
X
{
foo
:
~
str
,
bar
:
~
str
}
fn
main
()
{
let
x
=
{
foo
:
~
"hello"
,
bar
:
~
"world"
};
let
x
=
X
{
foo
:
~
"hello"
,
bar
:
~
"world"
};
log
(
debug
,
copy
x
.foo
);
log
(
debug
,
copy
x
.bar
);
}
src/test/run-pass/rec-extend.rs
浏览文件 @
6d4907a7
...
...
@@ -12,12 +12,12 @@
// -*- rust -*-
type
point
=
{
x
:
int
,
y
:
int
};
struct
Point
{
x
:
int
,
y
:
int
}
fn
main
()
{
let
origin
:
point
=
{
x
:
0
,
y
:
0
};
let
right
:
point
=
{
x
:
origin
.x
+
10
,
..
origin
};
let
up
:
point
=
{
y
:
origin
.y
+
10
,
..
origin
};
let
origin
:
Point
=
Point
{
x
:
0
,
y
:
0
};
let
right
:
Point
=
Point
{
x
:
origin
.x
+
10
,
..
origin
};
let
up
:
Point
=
Point
{
y
:
origin
.y
+
10
,
..
origin
};
assert
(
origin
.x
==
0
);
assert
(
origin
.y
==
0
);
assert
(
right
.x
==
10
);
...
...
src/test/run-pass/rec-tup.rs
浏览文件 @
6d4907a7
...
...
@@ -9,12 +9,12 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
type
point
=
{
x
:
int
,
y
:
int
};
struct
Point
{
x
:
int
,
y
:
int
}
type
rect
=
(
point
,
p
oint
);
type
rect
=
(
Point
,
P
oint
);
fn
fst
(
r
:
rect
)
->
p
oint
{
let
(
fst
,
_
)
=
r
;
return
fst
;
}
fn
snd
(
r
:
rect
)
->
p
oint
{
let
(
_
,
snd
)
=
r
;
return
snd
;
}
fn
fst
(
r
:
rect
)
->
P
oint
{
let
(
fst
,
_
)
=
r
;
return
fst
;
}
fn
snd
(
r
:
rect
)
->
P
oint
{
let
(
_
,
snd
)
=
r
;
return
snd
;
}
fn
f
(
r
:
rect
,
x1
:
int
,
y1
:
int
,
x2
:
int
,
y2
:
int
)
{
assert
(
fst
(
r
)
.x
==
x1
);
...
...
@@ -24,7 +24,7 @@ fn f(r: rect, x1: int, y1: int, x2: int, y2: int) {
}
fn
main
()
{
let
r
:
rect
=
(
{
x
:
10
,
y
:
20
},
{
x
:
11
,
y
:
22
});
let
r
:
rect
=
(
Point
{
x
:
10
,
y
:
20
},
Point
{
x
:
11
,
y
:
22
});
assert
(
fst
(
r
)
.x
==
10
);
assert
(
fst
(
r
)
.y
==
20
);
assert
(
snd
(
r
)
.x
==
11
);
...
...
src/test/run-pass/rec.rs
浏览文件 @
6d4907a7
...
...
@@ -12,9 +12,9 @@
// -*- rust -*-
type
rect
=
{
x
:
int
,
y
:
int
,
w
:
int
,
h
:
int
};
struct
Rect
{
x
:
int
,
y
:
int
,
w
:
int
,
h
:
int
}
fn
f
(
r
:
r
ect
,
x
:
int
,
y
:
int
,
w
:
int
,
h
:
int
)
{
fn
f
(
r
:
R
ect
,
x
:
int
,
y
:
int
,
w
:
int
,
h
:
int
)
{
assert
(
r
.x
==
x
);
assert
(
r
.y
==
y
);
assert
(
r
.w
==
w
);
...
...
@@ -22,12 +22,12 @@ fn f(r: rect, x: int, y: int, w: int, h: int) {
}
fn
main
()
{
let
r
:
rect
=
{
x
:
10
,
y
:
20
,
w
:
100
,
h
:
200
};
let
r
:
Rect
=
Rect
{
x
:
10
,
y
:
20
,
w
:
100
,
h
:
200
};
assert
(
r
.x
==
10
);
assert
(
r
.y
==
20
);
assert
(
r
.w
==
100
);
assert
(
r
.h
==
200
);
let
r2
:
r
ect
=
r
;
let
r2
:
R
ect
=
r
;
let
x
:
int
=
r2
.x
;
assert
(
x
==
10
);
f
(
r
,
10
,
20
,
100
,
200
);
...
...
src/test/run-pass/record-pat.rs
浏览文件 @
6d4907a7
...
...
@@ -9,17 +9,17 @@
// except according to those terms.
enum
t1
{
a
(
int
),
b
(
uint
),
}
type
t2
=
{
x
:
t1
,
y
:
int
};
enum
t3
{
c
(
t
2
,
uint
),
}
struct
T2
{
x
:
t1
,
y
:
int
}
enum
t3
{
c
(
T
2
,
uint
),
}
fn
m
(
in
:
t3
)
->
int
{
match
in
{
c
({
x
:
a
(
m
),
_
},
_
)
=>
{
return
m
;
}
c
({
x
:
b
(
m
),
y
:
y
},
z
)
=>
{
return
((
m
+
z
)
as
int
)
+
y
;
}
c
(
T2
{
x
:
a
(
m
),
_
},
_
)
=>
{
return
m
;
}
c
(
T2
{
x
:
b
(
m
),
y
:
y
},
z
)
=>
{
return
((
m
+
z
)
as
int
)
+
y
;
}
}
}
fn
main
()
{
assert
(
m
(
c
({
x
:
a
(
10
),
y
:
5
},
4u
))
==
10
);
assert
(
m
(
c
({
x
:
b
(
10u
),
y
:
5
},
4u
))
==
19
);
assert
(
m
(
c
(
T2
{
x
:
a
(
10
),
y
:
5
},
4u
))
==
10
);
assert
(
m
(
c
(
T2
{
x
:
b
(
10u
),
y
:
5
},
4u
))
==
19
);
}
src/test/run-pass/reflect-visit-data.rs
浏览文件 @
6d4907a7
...
...
@@ -29,9 +29,7 @@ fn align(size: uint, align: uint) -> uint {
((
size
+
align
)
-
1u
)
&
!
(
align
-
1u
)
}
enum
ptr_visit_adaptor
<
V
:
TyVisitor
movable_ptr
>
=
{
inner
:
V
};
enum
ptr_visit_adaptor
<
V
:
TyVisitor
movable_ptr
>
=
Inner
<
V
>
;
impl
<
V
:
TyVisitor
movable_ptr
>
ptr_visit_adaptor
<
V
>
{
...
...
@@ -469,11 +467,13 @@ fn visit_closure_ptr(ck: uint) -> bool {
}
}
enum
my_visitor
=
@
{
enum
my_visitor
=
@
Stuff
;
struct
Stuff
{
mut
ptr1
:
*
c_void
,
mut
ptr2
:
*
c_void
,
mut
vals
:
~
[
~
str
]
}
;
}
impl
my_visitor
{
fn
get
<
T
>
(
f
:
fn
(
T
))
{
...
...
@@ -485,13 +485,15 @@ fn get<T>(f: fn(T)) {
fn
visit_inner
(
inner
:
*
TyDesc
)
->
bool
{
unsafe
{
let
u
=
my_visitor
(
*
self
);
let
v
=
ptr_visit_adaptor
(
{
inner
:
u
});
let
v
=
ptr_visit_adaptor
::
<
my_visitor
>
(
Inner
{
inner
:
u
});
visit_tydesc
(
inner
,
v
as
TyVisitor
);
true
}
}
}
struct
Inner
<
V
>
{
inner
:
V
}
impl
my_visitor
:
movable_ptr
{
fn
move_ptr
(
adjustment
:
fn
(
*
c_void
)
->
*
c_void
)
{
self
.ptr1
=
adjustment
(
self
.ptr1
);
...
...
@@ -622,14 +624,16 @@ fn get_tydesc_for<T>(&&_t: T) -> *TyDesc {
get_tydesc
::
<
T
>
()
}
struct
Triple
{
x
:
int
,
y
:
int
,
z
:
int
}
fn
main
()
{
unsafe
{
let
r
=
(
1
,
2
,
3
,
true
,
false
,{
x
:
5
,
y
:
4
,
z
:
3
});
let
r
=
(
1
,
2
,
3
,
true
,
false
,
Triple
{
x
:
5
,
y
:
4
,
z
:
3
});
let
p
=
ptr
::
addr_of
(
&
r
)
as
*
c_void
;
let
u
=
my_visitor
(
@
{
mut
ptr1
:
p
,
let
u
=
my_visitor
(
@
Stuff
{
mut
ptr1
:
p
,
mut
ptr2
:
p
,
mut
vals
:
~
[]});
let
v
=
ptr_visit_adaptor
({
inner
:
u
});
let
v
=
ptr_visit_adaptor
(
Inner
{
inner
:
u
});
let
td
=
get_tydesc_for
(
r
);
unsafe
{
error!
(
"tydesc sz: %u, align: %u"
,
(
*
td
)
.size
,
(
*
td
)
.align
);
}
...
...
src/test/run-pass/regions-infer-borrow-scope.rs
浏览文件 @
6d4907a7
...
...
@@ -8,14 +8,14 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
type
point
=
{
x
:
int
,
y
:
int
};
struct
Point
{
x
:
int
,
y
:
int
}
fn
x_coord
(
p
:
&
r
/
p
oint
)
->
&
r
/
int
{
fn
x_coord
(
p
:
&
r
/
P
oint
)
->
&
r
/
int
{
return
&
p
.x
;
}
fn
main
()
{
let
p
=
@
{
x
:
3
,
y
:
4
};
let
p
=
@
Point
{
x
:
3
,
y
:
4
};
let
xc
=
x_coord
(
p
);
assert
*
xc
==
3
;
}
...
...
src/test/run-pass/regions-mock-trans-impls.rs
浏览文件 @
6d4907a7
...
...
@@ -14,36 +14,36 @@
use
libc
,
sys
,
cast
;
use
std
::
arena
::
Arena
;
type
bcx
=
{
fcx
:
&
f
cx
}
;
struct
Bcx
{
fcx
:
&
F
cx
}
type
fcx
=
{
struct
Fcx
{
arena
:
&
Arena
,
ccx
:
&
c
cx
}
;
ccx
:
&
C
cx
}
type
ccx
=
{
struct
Ccx
{
x
:
int
}
;
}
fn
h
(
bcx
:
&
r
/
bcx
)
->
&
r
/
b
cx
{
return
bcx
.fcx.arena
.alloc
(||
{
fcx
:
bcx
.fcx
});
fn
h
(
bcx
:
&
r
/
Bcx
)
->
&
r
/
B
cx
{
return
bcx
.fcx.arena
.alloc
(||
Bcx
{
fcx
:
bcx
.fcx
});
}
fn
g
(
fcx
:
&
f
cx
)
{
let
bcx
=
{
fcx
:
fcx
};
fn
g
(
fcx
:
&
F
cx
)
{
let
bcx
=
Bcx
{
fcx
:
fcx
};
h
(
&
bcx
);
}
fn
f
(
ccx
:
&
c
cx
)
{
fn
f
(
ccx
:
&
C
cx
)
{
let
a
=
Arena
();
let
fcx
=
&
{
arena
:
&
a
,
ccx
:
ccx
};
let
fcx
=
&
Fcx
{
arena
:
&
a
,
ccx
:
ccx
};
return
g
(
fcx
);
}
fn
main
()
{
let
ccx
=
{
x
:
0
};
let
ccx
=
Ccx
{
x
:
0
};
f
(
&
ccx
);
}
src/test/run-pass/regions-mock-trans.rs
浏览文件 @
6d4907a7
...
...
@@ -10,46 +10,46 @@
enum
arena
=
();
type
bcx
=
{
fcx
:
&
f
cx
}
;
struct
Bcx
{
fcx
:
&
F
cx
}
type
fcx
=
{
struct
Fcx
{
arena
:
&
arena
,
ccx
:
&
c
cx
}
;
ccx
:
&
C
cx
}
type
ccx
=
{
struct
Ccx
{
x
:
int
}
;
}
fn
alloc
(
_
bcx
:
&
arena
)
->
&
b
cx
{
fn
alloc
(
_
bcx
:
&
arena
)
->
&
B
cx
{
unsafe
{
return
cast
::
reinterpret_cast
(
&
libc
::
malloc
(
sys
::
size_of
::
<
b
cx
/&
blk
>
()
as
libc
::
size_t
));
&
libc
::
malloc
(
sys
::
size_of
::
<
B
cx
/&
blk
>
()
as
libc
::
size_t
));
}
}
fn
h
(
bcx
:
&
bcx
)
->
&
b
cx
{
fn
h
(
bcx
:
&
Bcx
)
->
&
B
cx
{
return
alloc
(
bcx
.fcx.arena
);
}
fn
g
(
fcx
:
&
f
cx
)
{
let
bcx
=
{
fcx
:
fcx
};
fn
g
(
fcx
:
&
F
cx
)
{
let
bcx
=
Bcx
{
fcx
:
fcx
};
let
bcx2
=
h
(
&
bcx
);
unsafe
{
libc
::
free
(
cast
::
reinterpret_cast
(
&
bcx2
));
}
}
fn
f
(
ccx
:
&
c
cx
)
{
fn
f
(
ccx
:
&
C
cx
)
{
let
a
=
arena
(());
let
fcx
=
{
arena
:
&
a
,
ccx
:
ccx
};
let
fcx
=
Fcx
{
arena
:
&
a
,
ccx
:
ccx
};
return
g
(
&
fcx
);
}
fn
main
()
{
let
ccx
=
{
x
:
0
};
let
ccx
=
Ccx
{
x
:
0
};
f
(
&
ccx
);
}
src/test/run-pass/regions-self-impls.rs
浏览文件 @
6d4907a7
...
...
@@ -8,18 +8,18 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
type
clam
=
{
chowder
:
&
int
};
struct
Clam
{
chowder
:
&
int
}
trait
get_chowder
{
fn
get_chowder
()
->
&
self
/
int
;
}
impl
c
lam
:
get_chowder
{
impl
C
lam
:
get_chowder
{
fn
get_chowder
()
->
&
self
/
int
{
return
self
.chowder
;
}
}
fn
main
()
{
let
clam
=
{
chowder
:
&
3
};
let
clam
=
Clam
{
chowder
:
&
3
};
log
(
debug
,
*
clam
.get_chowder
());
clam
.get_chowder
();
}
...
...
src/test/run-pass/regions-trait.rs
浏览文件 @
6d4907a7
...
...
@@ -8,16 +8,16 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
type
ctxt
=
{
v
:
uint
};
struct
Ctxt
{
v
:
uint
}
trait
get_ctxt
{
fn
get_ctxt
()
->
&
self
/
c
txt
;
fn
get_ctxt
()
->
&
self
/
C
txt
;
}
type
has_ctxt
=
{
c
:
&
ctxt
};
struct
HasCtxt
{
c
:
&
Ctxt
}
impl
has_c
txt
:
get_ctxt
{
fn
get_ctxt
()
->
&
self
/
c
txt
{
impl
HasC
txt
:
get_ctxt
{
fn
get_ctxt
()
->
&
self
/
C
txt
{
self
.c
}
}
...
...
@@ -27,8 +27,8 @@ fn get_v(gc: get_ctxt) -> uint {
}
fn
main
()
{
let
ctxt
=
{
v
:
22u
};
let
hc
=
{
c
:
&
ctxt
};
let
ctxt
=
Ctxt
{
v
:
22
};
let
hc
=
HasCtxt
{
c
:
&
ctxt
};
assert
get_v
(
hc
as
get_ctxt
)
==
22
u
;
assert
get_v
(
hc
as
get_ctxt
)
==
22
;
}
src/test/run-pass/resource-cycle.rs
浏览文件 @
6d4907a7
此差异已折叠。
点击以展开。
src/test/run-pass/resource-cycle2.rs
浏览文件 @
6d4907a7
此差异已折叠。
点击以展开。
src/test/run-pass/resource-cycle3.rs
浏览文件 @
6d4907a7
此差异已折叠。
点击以展开。
src/test/run-pass/resource-generic.rs
浏览文件 @
6d4907a7
此差异已折叠。
点击以展开。
src/test/run-pass/rt-circular-buffer.rs
浏览文件 @
6d4907a7
此差异已折叠。
点击以展开。
src/test/run-pass/sendfn-generic-fn.rs
浏览文件 @
6d4907a7
此差异已折叠。
点击以展开。
src/test/run-pass/shape_intrinsic_tag_then_rec.rs
浏览文件 @
6d4907a7
此差异已折叠。
点击以展开。
src/test/run-pass/struct-return.rs
浏览文件 @
6d4907a7
此差异已折叠。
点击以展开。
src/test/run-pass/task-comm-16.rs
浏览文件 @
6d4907a7
此差异已折叠。
点击以展开。
src/test/run-pass/trait-cast.rs
浏览文件 @
6d4907a7
此差异已折叠。
点击以展开。
src/test/run-pass/type-namespace.rs
浏览文件 @
6d4907a7
此差异已折叠。
点击以展开。
src/test/run-pass/uniq-cc-generic.rs
浏览文件 @
6d4907a7
此差异已折叠。
点击以展开。
src/test/run-pass/uniq-cc.rs
浏览文件 @
6d4907a7
此差异已折叠。
点击以展开。
src/test/run-pass/unique-autoderef-field.rs
浏览文件 @
6d4907a7
此差异已折叠。
点击以展开。
src/test/run-pass/unique-destructure.rs
浏览文件 @
6d4907a7
此差异已折叠。
点击以展开。
src/test/run-pass/unique-pat-2.rs
浏览文件 @
6d4907a7
此差异已折叠。
点击以展开。
src/test/run-pass/unique-rec.rs
浏览文件 @
6d4907a7
此差异已折叠。
点击以展开。
src/test/run-pass/vec-drop.rs
浏览文件 @
6d4907a7
此差异已折叠。
点击以展开。
src/test/run-pass/writealias.rs
浏览文件 @
6d4907a7
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录