Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
5c999d4e
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,发现更多精彩内容 >>
提交
5c999d4e
编写于
7月 20, 2013
作者:
B
bors
浏览文件
操作
浏览文件
下载
差异文件
auto merge of #7894 : pcwalton/rust/and-pointers-in-at-boxes, r=brson
r? @brson
上级
8aae6edc
9089cf2e
变更
24
隐藏空白更改
内联
并排
Showing
24 changed file
with
84 addition
and
81 deletion
+84
-81
src/libextra/fun_treemap.rs
src/libextra/fun_treemap.rs
+14
-3
src/libextra/list.rs
src/libextra/list.rs
+2
-2
src/libextra/serialize.rs
src/libextra/serialize.rs
+2
-2
src/librustc/metadata/encoder.rs
src/librustc/metadata/encoder.rs
+7
-5
src/librustc/middle/kind.rs
src/librustc/middle/kind.rs
+4
-0
src/librustc/middle/subst.rs
src/librustc/middle/subst.rs
+1
-1
src/librustc/middle/ty.rs
src/librustc/middle/ty.rs
+1
-1
src/libstd/clone.rs
src/libstd/clone.rs
+2
-2
src/libstd/num/num.rs
src/libstd/num/num.rs
+2
-2
src/libstd/rand.rs
src/libstd/rand.rs
+1
-1
src/libsyntax/ext/base.rs
src/libsyntax/ext/base.rs
+1
-2
src/libsyntax/util/interner.rs
src/libsyntax/util/interner.rs
+1
-1
src/test/auxiliary/cci_nested_lib.rs
src/test/auxiliary/cci_nested_lib.rs
+8
-4
src/test/compile-fail/box-static-bound.rs
src/test/compile-fail/box-static-bound.rs
+10
-0
src/test/compile-fail/kindck-owned-trait.rs
src/test/compile-fail/kindck-owned-trait.rs
+1
-0
src/test/compile-fail/kindck-owned.rs
src/test/compile-fail/kindck-owned.rs
+2
-1
src/test/run-pass/alignment-gep-tup-like-2.rs
src/test/run-pass/alignment-gep-tup-like-2.rs
+6
-2
src/test/run-pass/generic-box.rs
src/test/run-pass/generic-box.rs
+1
-1
src/test/run-pass/generic-exterior-box.rs
src/test/run-pass/generic-exterior-box.rs
+1
-1
src/test/run-pass/infer-with-expected.rs
src/test/run-pass/infer-with-expected.rs
+2
-2
src/test/run-pass/issue-3447.rs
src/test/run-pass/issue-3447.rs
+9
-8
src/test/run-pass/kindck-owned-trait-contains-1.rs
src/test/run-pass/kindck-owned-trait-contains-1.rs
+4
-4
src/test/run-pass/log-linearized.rs
src/test/run-pass/log-linearized.rs
+2
-2
src/test/run-pass/regions-trait.rs
src/test/run-pass/regions-trait.rs
+0
-34
未找到文件。
src/libextra/fun_treemap.rs
浏览文件 @
5c999d4e
...
...
@@ -31,10 +31,17 @@ enum TreeNode<K, V> {
}
/// Create a treemap
pub
fn
init
<
K
,
V
>
()
->
Treemap
<
K
,
V
>
{
@
Empty
}
pub
fn
init
<
K
:
'static
,
V
:
'static
>
()
->
Treemap
<
K
,
V
>
{
@
Empty
}
/// Insert a value into the map
pub
fn
insert
<
K
:
Eq
+
Ord
,
V
>
(
m
:
Treemap
<
K
,
V
>
,
k
:
K
,
v
:
V
)
->
Treemap
<
K
,
V
>
{
pub
fn
insert
<
K
:
Eq
+
Ord
+
'static
,
V
:
'static
>
(
m
:
Treemap
<
K
,
V
>
,
k
:
K
,
v
:
V
)
->
Treemap
<
K
,
V
>
{
@
match
m
{
@
Empty
=>
Node
(
@
k
,
@
v
,
@
Empty
,
@
Empty
),
@
Node
(
kk
,
vv
,
left
,
right
)
=>
cond!
(
...
...
@@ -46,7 +53,11 @@ pub fn insert<K:Eq + Ord,V>(m: Treemap<K, V>, k: K, v: V) -> Treemap<K, V> {
}
/// Find a value based on the key
pub
fn
find
<
K
:
Eq
+
Ord
,
V
:
Clone
>
(
m
:
Treemap
<
K
,
V
>
,
k
:
K
)
->
Option
<
V
>
{
pub
fn
find
<
K
:
Eq
+
Ord
+
'static
,
V
:
Clone
+
'static
>
(
m
:
Treemap
<
K
,
V
>
,
k
:
K
)
->
Option
<
V
>
{
match
*
m
{
Empty
=>
None
,
Node
(
kk
,
v
,
left
,
right
)
=>
cond!
(
...
...
src/libextra/list.rs
浏览文件 @
5c999d4e
...
...
@@ -25,7 +25,7 @@ pub enum MutList<T> {
}
/// Create a list from a vector
pub
fn
from_vec
<
T
:
Clone
>
(
v
:
&
[
T
])
->
@
List
<
T
>
{
pub
fn
from_vec
<
T
:
Clone
+
'static
>
(
v
:
&
[
T
])
->
@
List
<
T
>
{
v
.rev_iter
()
.fold
(
@
Nil
::
<
T
>
,
|
t
,
h
|
@
Cons
((
*
h
)
.clone
(),
t
))
}
...
...
@@ -109,7 +109,7 @@ pub fn head<T:Clone>(ls: @List<T>) -> T {
}
/// Appends one list to another
pub
fn
append
<
T
:
Clone
>
(
l
:
@
List
<
T
>
,
m
:
@
List
<
T
>
)
->
@
List
<
T
>
{
pub
fn
append
<
T
:
Clone
+
'static
>
(
l
:
@
List
<
T
>
,
m
:
@
List
<
T
>
)
->
@
List
<
T
>
{
match
*
l
{
Nil
=>
return
m
,
Cons
(
ref
x
,
xs
)
=>
{
...
...
src/libextra/serialize.rs
浏览文件 @
5c999d4e
...
...
@@ -423,7 +423,7 @@ fn encode(&self, s: &mut S) {
}
}
impl
<
D
:
Decoder
,
T
:
Decodable
<
D
>>
Decodable
<
D
>
for
@
T
{
impl
<
D
:
Decoder
,
T
:
Decodable
<
D
>
+
'static
>
Decodable
<
D
>
for
@
T
{
fn
decode
(
d
:
&
mut
D
)
->
@
T
{
@
Decodable
::
decode
(
d
)
}
...
...
@@ -435,7 +435,7 @@ fn encode(&self, s: &mut S) {
}
}
impl
<
D
:
Decoder
,
T
:
Decodable
<
D
>>
Decodable
<
D
>
for
@
mut
T
{
impl
<
D
:
Decoder
,
T
:
Decodable
<
D
>
+
'static
>
Decodable
<
D
>
for
@
mut
T
{
fn
decode
(
d
:
&
mut
D
)
->
@
mut
T
{
@
mut
Decodable
::
decode
(
d
)
}
...
...
src/librustc/metadata/encoder.rs
浏览文件 @
5c999d4e
...
...
@@ -1238,8 +1238,9 @@ fn encode_info_for_items(ecx: &EncodeContext,
// Path and definition ID indexing
fn
create_index
<
T
:
Clone
+
Hash
+
IterBytes
>
(
index
:
~
[
entry
<
T
>
])
->
~
[
@~
[
entry
<
T
>
]]
{
fn
create_index
<
T
:
Clone
+
Hash
+
IterBytes
+
'static
>
(
index
:
~
[
entry
<
T
>
])
->
~
[
@~
[
entry
<
T
>
]]
{
let
mut
buckets
:
~
[
@
mut
~
[
entry
<
T
>
]]
=
~
[];
for
uint
::
range
(
0u
,
256u
)
|
_
i
|
{
buckets
.push
(
@
mut
~
[]);
};
for
index
.iter
()
.advance
|
elt
|
{
...
...
@@ -1254,9 +1255,10 @@ fn create_index<T:Clone + Hash + IterBytes>(index: ~[entry<T>])
return
buckets_frozen
;
}
fn
encode_index
<
T
>
(
ebml_w
:
&
mut
writer
::
Encoder
,
buckets
:
~
[
@~
[
entry
<
T
>
]],
write_fn
:
&
fn
(
@
io
::
Writer
,
&
T
))
{
fn
encode_index
<
T
:
'static
>
(
ebml_w
:
&
mut
writer
::
Encoder
,
buckets
:
~
[
@~
[
entry
<
T
>
]],
write_fn
:
&
fn
(
@
io
::
Writer
,
&
T
))
{
let
writer
=
ebml_w
.writer
;
ebml_w
.start_tag
(
tag_index
);
let
mut
bucket_locs
:
~
[
uint
]
=
~
[];
...
...
src/librustc/middle/kind.rs
浏览文件 @
5c999d4e
...
...
@@ -285,6 +285,10 @@ pub fn check_expr(e: @expr, (cx, v): (Context, visit::vt<Context>)) {
}
match
e
.node
{
expr_unary
(
_
,
box
(
_
),
interior
)
=>
{
let
interior_type
=
ty
::
expr_ty
(
cx
.tcx
,
interior
);
let
_
=
check_durable
(
cx
.tcx
,
interior_type
,
interior
.span
);
}
expr_cast
(
source
,
_
)
=>
{
check_cast_for_escaping_regions
(
cx
,
source
,
e
);
match
ty
::
get
(
ty
::
expr_ty
(
cx
.tcx
,
e
))
.sty
{
...
...
src/librustc/middle/subst.rs
浏览文件 @
5c999d4e
...
...
@@ -79,7 +79,7 @@ fn subst(&self, tcx: ty::ctxt, substs: &ty::substs) -> ~[T] {
}
}
impl
<
T
:
Subst
>
Subst
for
@
T
{
impl
<
T
:
Subst
+
'static
>
Subst
for
@
T
{
fn
subst
(
&
self
,
tcx
:
ty
::
ctxt
,
substs
:
&
ty
::
substs
)
->
@
T
{
match
self
{
&@
ref
t
=>
@
t
.subst
(
tcx
,
substs
)
...
...
src/librustc/middle/ty.rs
浏览文件 @
5c999d4e
...
...
@@ -858,7 +858,7 @@ fn mk_rcache() -> creader_cache {
return
@
mut
HashMap
::
new
();
}
pub
fn
new_ty_hash
<
V
>
()
->
@
mut
HashMap
<
t
,
V
>
{
pub
fn
new_ty_hash
<
V
:
'static
>
()
->
@
mut
HashMap
<
t
,
V
>
{
@
mut
HashMap
::
new
()
}
...
...
src/libstd/clone.rs
浏览文件 @
5c999d4e
...
...
@@ -112,7 +112,7 @@ fn deep_clone(&self) -> ~T { ~(**self).deep_clone() }
}
// FIXME: #6525: should also be implemented for `T: Send + DeepClone`
impl
<
T
:
Freeze
+
DeepClone
>
DeepClone
for
@
T
{
impl
<
T
:
Freeze
+
DeepClone
+
'static
>
DeepClone
for
@
T
{
/// Return a deep copy of the managed box. The `Freeze` trait is required to prevent performing
/// a deep clone of a potentially cyclical type.
#[inline]
...
...
@@ -120,7 +120,7 @@ fn deep_clone(&self) -> @T { @(**self).deep_clone() }
}
// FIXME: #6525: should also be implemented for `T: Send + DeepClone`
impl
<
T
:
Freeze
+
DeepClone
>
DeepClone
for
@
mut
T
{
impl
<
T
:
Freeze
+
DeepClone
+
'static
>
DeepClone
for
@
mut
T
{
/// Return a deep copy of the managed box. The `Freeze` trait is required to prevent performing
/// a deep clone of a potentially cyclical type.
#[inline]
...
...
src/libstd/num/num.rs
浏览文件 @
5c999d4e
...
...
@@ -446,12 +446,12 @@ pub fn pow_with_uint<T:NumCast+One+Zero+Div<T,T>+Mul<T,T>>(radix: uint, pow: uin
total
}
impl
<
T
:
Zero
>
Zero
for
@
mut
T
{
impl
<
T
:
Zero
+
'static
>
Zero
for
@
mut
T
{
fn
zero
()
->
@
mut
T
{
@
mut
Zero
::
zero
()
}
fn
is_zero
(
&
self
)
->
bool
{
(
**
self
)
.is_zero
()
}
}
impl
<
T
:
Zero
>
Zero
for
@
T
{
impl
<
T
:
Zero
+
'static
>
Zero
for
@
T
{
fn
zero
()
->
@
T
{
@
Zero
::
zero
()
}
fn
is_zero
(
&
self
)
->
bool
{
(
**
self
)
.is_zero
()
}
}
...
...
src/libstd/rand.rs
浏览文件 @
5c999d4e
...
...
@@ -242,7 +242,7 @@ impl<T: Rand> Rand for ~T {
fn
rand
<
R
:
Rng
>
(
rng
:
&
mut
R
)
->
~
T
{
~
rng
.gen
()
}
}
impl
<
T
:
Rand
>
Rand
for
@
T
{
impl
<
T
:
Rand
+
'static
>
Rand
for
@
T
{
#[inline]
fn
rand
<
R
:
Rng
>
(
rng
:
&
mut
R
)
->
@
T
{
@
rng
.gen
()
}
}
...
...
src/libsyntax/ext/base.rs
浏览文件 @
5c999d4e
...
...
@@ -414,8 +414,7 @@ pub enum MapChain<K,V> {
// get the map from an env frame
impl
<
K
:
Eq
+
Hash
+
IterBytes
,
V
>
MapChain
<
K
,
V
>
{
impl
<
K
:
Eq
+
Hash
+
IterBytes
+
'static
,
V
:
'static
>
MapChain
<
K
,
V
>
{
// Constructor. I don't think we need a zero-arg one.
fn
new
(
init
:
~
HashMap
<
K
,
@
V
>
)
->
@
mut
MapChain
<
K
,
V
>
{
@
mut
BaseMapChain
(
init
)
...
...
src/libsyntax/util/interner.rs
浏览文件 @
5c999d4e
...
...
@@ -21,7 +21,7 @@ pub struct Interner<T> {
}
// when traits can extend traits, we should extend index<uint,T> to get []
impl
<
T
:
Eq
+
IterBytes
+
Hash
+
Freeze
+
Clone
>
Interner
<
T
>
{
impl
<
T
:
Eq
+
IterBytes
+
Hash
+
Freeze
+
Clone
+
'static
>
Interner
<
T
>
{
pub
fn
new
()
->
Interner
<
T
>
{
Interner
{
map
:
@
mut
HashMap
::
new
(),
...
...
src/test/auxiliary/cci_nested_lib.rs
浏览文件 @
5c999d4e
...
...
@@ -18,11 +18,15 @@ pub struct alist<A,B> {
data
:
@
mut
~
[
Entry
<
A
,
B
>
]
}
pub
fn
alist_add
<
A
,
B
>
(
lst
:
&
alist
<
A
,
B
>
,
k
:
A
,
v
:
B
)
{
pub
fn
alist_add
<
A
:
'static
,
B
:
'static
>
(
lst
:
&
alist
<
A
,
B
>
,
k
:
A
,
v
:
B
)
{
lst
.data
.push
(
Entry
{
key
:
k
,
value
:
v
});
}
pub
fn
alist_get
<
A
:
Clone
,
B
:
Clone
>
(
lst
:
&
alist
<
A
,
B
>
,
k
:
A
)
->
B
{
pub
fn
alist_get
<
A
:
Clone
+
'static
,
B
:
Clone
+
'static
>
(
lst
:
&
alist
<
A
,
B
>
,
k
:
A
)
->
B
{
let
eq_fn
=
lst
.eq_fn
;
for
lst
.data
.iter
()
.advance
|
entry
|
{
if
eq_fn
(
entry
.key
.clone
(),
k
.clone
())
{
...
...
@@ -33,13 +37,13 @@ pub fn alist_get<A:Clone,B:Clone>(lst: &alist<A,B>, k: A) -> B {
}
#[inline]
pub
fn
new_int_alist
<
B
>
()
->
alist
<
int
,
B
>
{
pub
fn
new_int_alist
<
B
:
'static
>
()
->
alist
<
int
,
B
>
{
fn
eq_int
(
a
:
int
,
b
:
int
)
->
bool
{
a
==
b
}
return
alist
{
eq_fn
:
eq_int
,
data
:
@
mut
~
[]};
}
#[inline]
pub
fn
new_int_alist_2
<
B
>
()
->
alist
<
int
,
B
>
{
pub
fn
new_int_alist_2
<
B
:
'static
>
()
->
alist
<
int
,
B
>
{
#[inline]
fn
eq_int
(
a
:
int
,
b
:
int
)
->
bool
{
a
==
b
}
return
alist
{
eq_fn
:
eq_int
,
data
:
@
mut
~
[]};
...
...
src/test/compile-fail/box-static-bound.rs
0 → 100644
浏览文件 @
5c999d4e
fn
f
<
T
>
(
x
:
T
)
->
@
T
{
@
x
//~ ERROR value may contain borrowed pointers
}
fn
g
<
T
:
'static
>
(
x
:
T
)
->
@
T
{
@
x
// ok
}
fn
main
()
{}
src/test/compile-fail/kindck-owned-trait.rs
浏览文件 @
5c999d4e
...
...
@@ -14,6 +14,7 @@ fn to_foo<T:Clone + foo>(t: T) -> @foo {
@
t
as
@
foo
//~^ ERROR value may contain borrowed pointers; add `'static` bound
//~^^ ERROR cannot pack type
//~^^^ ERROR value may contain borrowed pointers
}
fn
to_foo2
<
T
:
Clone
+
foo
+
'static
>
(
t
:
T
)
->
@
foo
{
...
...
src/test/compile-fail/kindck-owned.rs
浏览文件 @
5c999d4e
...
...
@@ -23,5 +23,6 @@ fn main() {
copy2
(
&
x
);
//~ ERROR does not fulfill `'static`
copy2
(
@
3
);
copy2
(
@&
x
);
//~ ERROR does not fulfill `'static`
copy2
(
@&
x
);
//~ ERROR value may contain borrowed pointers
//~^ ERROR does not fulfill `'static`
}
src/test/run-pass/alignment-gep-tup-like-2.rs
浏览文件 @
5c999d4e
...
...
@@ -18,12 +18,16 @@ struct Rec<A> {
rec
:
Option
<@
mut
RecEnum
<
A
>>
}
fn
make_cycle
<
A
>
(
a
:
A
)
{
fn
make_cycle
<
A
:
'static
>
(
a
:
A
)
{
let
g
:
@
mut
RecEnum
<
A
>
=
@
mut
RecEnum
(
Rec
{
val
:
a
,
rec
:
None
});
g
.rec
=
Some
(
g
);
}
fn
f
<
A
:
Send
+
Clone
,
B
:
Send
+
Clone
>
(
a
:
A
,
b
:
B
)
->
@
fn
()
->
(
A
,
B
)
{
fn
f
<
A
:
Send
+
Clone
+
'static
,
B
:
Send
+
Clone
+
'static
>
(
a
:
A
,
b
:
B
)
->
@
fn
()
->
(
A
,
B
)
{
let
result
:
@
fn
()
->
(
A
,
B
)
=
||
(
a
.clone
(),
b
.clone
());
result
}
...
...
src/test/run-pass/generic-box.rs
浏览文件 @
5c999d4e
...
...
@@ -10,7 +10,7 @@
fn
box
<
T
>
(
x
:
Box
<
T
>
)
->
@
Box
<
T
>
{
return
@
x
;
}
fn
box
<
T
:
'static
>
(
x
:
Box
<
T
>
)
->
@
Box
<
T
>
{
return
@
x
;
}
struct
Box
<
T
>
{
x
:
T
,
y
:
T
,
z
:
T
}
...
...
src/test/run-pass/generic-exterior-box.rs
浏览文件 @
5c999d4e
...
...
@@ -12,7 +12,7 @@
struct
Recbox
<
T
>
{
x
:
@
T
}
fn
reclift
<
T
>
(
t
:
T
)
->
Recbox
<
T
>
{
return
Recbox
{
x
:
@
t
};
}
fn
reclift
<
T
:
'static
>
(
t
:
T
)
->
Recbox
<
T
>
{
return
Recbox
{
x
:
@
t
};
}
pub
fn
main
()
{
let
foo
:
int
=
17
;
...
...
src/test/run-pass/infer-with-expected.rs
浏览文件 @
5c999d4e
...
...
@@ -14,12 +14,12 @@
// happen.)
fn
eat_tup
(
_
r
:
~@
(
int
,
@
fn
(
Pair
)
->
int
))
{}
fn
eat_rec
(
_
r
:
@
~
Rec
)
{}
fn
eat_rec
(
_
r
:
~
Rec
)
{}
struct
Rec
<
'self
>
{
a
:
int
,
b
:
&
'self
fn
(
Pair
)
->
int
}
struct
Pair
{
x
:
int
,
y
:
int
}
pub
fn
main
()
{
eat_tup
(
~@
(
10
,
|
a
|
a
.x
));
eat_rec
(
@
~
Rec
{
a
:
10
,
b
:
|
a
|
a
.x
});
eat_rec
(
~
Rec
{
a
:
10
,
b
:
|
a
|
a
.x
});
}
src/test/run-pass/issue-3447.rs
浏览文件 @
5c999d4e
...
...
@@ -8,13 +8,15 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
struct
list
<
'self
,
T
>
{
element
:
&
'self
T
,
next
:
Option
<@
mut
list
<
'self
,
T
>>
static
S
:
&
'static
str
=
"str"
;
struct
list
<
T
>
{
element
:
T
,
next
:
Option
<@
mut
list
<
T
>>
}
impl
<
'self
,
T
>
list
<
'self
,
T
>
{
pub
fn
addEnd
(
&
mut
self
,
element
:
&
'self
T
)
{
impl
<
T
:
'static
>
list
<
T
>
{
pub
fn
addEnd
(
&
mut
self
,
element
:
T
)
{
let
newList
=
list
{
element
:
element
,
next
:
None
...
...
@@ -25,10 +27,9 @@ pub fn addEnd(&mut self, element: &'self T) {
}
pub
fn
main
()
{
let
s
=
@
"str"
;
let
ls
=
list
{
element
:
&
s
,
element
:
S
,
next
:
None
};
println
(
*
ls
.element
);
println
(
ls
.element
);
}
src/test/run-pass/kindck-owned-trait-contains-1.rs
浏览文件 @
5c999d4e
...
...
@@ -10,19 +10,19 @@
trait
repeat
<
A
>
{
fn
get
(
&
self
)
->
A
;
}
impl
<
A
:
Clone
>
repeat
<
A
>
for
@
A
{
impl
<
A
:
Clone
+
'static
>
repeat
<
A
>
for
@
A
{
fn
get
(
&
self
)
->
A
{
(
**
self
)
.clone
()
}
}
fn
repeater
<
A
:
Clone
>
(
v
:
@
A
)
->
@
repeat
:
<
A
>
{
fn
repeater
<
A
:
Clone
+
'static
>
(
v
:
@
A
)
->
@
repeat
:
<
A
>
{
// Note: owned kind is not necessary as A appears in the trait type
@
v
as
@
repeat
:
<
A
>
// No
}
pub
fn
main
()
{
let
x
=
&
3
;
let
x
=
3
;
let
y
=
repeater
(
@
x
);
assert_eq!
(
*
x
,
*
(
y
.get
()
));
assert_eq!
(
x
,
y
.get
(
));
}
src/test/run-pass/log-linearized.rs
浏览文件 @
5c999d4e
...
...
@@ -19,12 +19,12 @@ struct Smallintmap<T> {v: ~[option<T>]}
struct
V
<
T
>
{
v
:
~
[
option
<
T
>
]
}
fn
mk
<
T
>
()
->
@
mut
Smallintmap
<
T
>
{
fn
mk
<
T
:
'static
>
()
->
@
mut
Smallintmap
<
T
>
{
let
mut
v
:
~
[
option
<
T
>
]
=
~
[];
return
@
mut
Smallintmap
{
v
:
v
};
}
fn
f
<
T
,
U
>
()
{
fn
f
<
T
,
U
:
'static
>
()
{
let
mut
sim
=
mk
::
<
U
>
();
error!
(
sim
);
}
...
...
src/test/run-pass/regions-trait.rs
已删除
100644 → 0
浏览文件 @
8aae6edc
// 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.
struct
Ctxt
{
v
:
uint
}
trait
get_ctxt
<
'self
>
{
fn
get_ctxt
(
&
self
)
->
&
'self
Ctxt
;
}
struct
HasCtxt
<
'self
>
{
c
:
&
'self
Ctxt
}
impl
<
'self
>
get_ctxt
<
'self
>
for
HasCtxt
<
'self
>
{
fn
get_ctxt
(
&
self
)
->
&
'self
Ctxt
{
self
.c
}
}
fn
get_v
(
gc
:
@
get_ctxt
:)
->
uint
{
gc
.get_ctxt
()
.v
}
pub
fn
main
()
{
let
ctxt
=
Ctxt
{
v
:
22
};
let
hc
=
HasCtxt
{
c
:
&
ctxt
};
assert_eq!
(
get_v
(
@
hc
as
@
get_ctxt
:),
22
);
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录