Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
58f248d9
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,发现更多精彩内容 >>
提交
58f248d9
编写于
3月 13, 2013
作者:
P
Patrick Walton
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
test: Fix tests. rs=tests
上级
aa4c19b6
变更
42
隐藏空白更改
内联
并排
Showing
42 changed file
with
110 addition
and
98 deletion
+110
-98
doc/rust.md
doc/rust.md
+19
-19
src/libcore/rt/thread_local_storage.rs
src/libcore/rt/thread_local_storage.rs
+7
-2
src/libsyntax/parse/mod.rs
src/libsyntax/parse/mod.rs
+1
-1
src/libsyntax/syntax.rc
src/libsyntax/syntax.rc
+0
-1
src/test/auxiliary/ambig_impl_2_lib.rs
src/test/auxiliary/ambig_impl_2_lib.rs
+1
-1
src/test/compile-fail/ambig_impl_2_exe.rs
src/test/compile-fail/ambig_impl_2_exe.rs
+2
-2
src/test/compile-fail/ambig_impl_bounds.rs
src/test/compile-fail/ambig_impl_bounds.rs
+2
-2
src/test/compile-fail/borrowck-autoref-3261.rs
src/test/compile-fail/borrowck-autoref-3261.rs
+2
-2
src/test/compile-fail/class-cast-to-trait.rs
src/test/compile-fail/class-cast-to-trait.rs
+1
-1
src/test/compile-fail/infinite-instantiation.rs
src/test/compile-fail/infinite-instantiation.rs
+2
-2
src/test/compile-fail/issue-2590.rs
src/test/compile-fail/issue-2590.rs
+2
-2
src/test/compile-fail/issue-3021-d.rs
src/test/compile-fail/issue-3021-d.rs
+1
-1
src/test/compile-fail/kindck-owned-trait-contains.rs
src/test/compile-fail/kindck-owned-trait-contains.rs
+2
-2
src/test/compile-fail/kindck-owned-trait-scoped.rs
src/test/compile-fail/kindck-owned-trait-scoped.rs
+4
-1
src/test/compile-fail/map-types.rs
src/test/compile-fail/map-types.rs
+1
-1
src/test/compile-fail/pure-modifies-aliased.rs
src/test/compile-fail/pure-modifies-aliased.rs
+1
-1
src/test/compile-fail/regions-bounds.rs
src/test/compile-fail/regions-bounds.rs
+0
-7
src/test/compile-fail/regions-infer-paramd-indirect.rs
src/test/compile-fail/regions-infer-paramd-indirect.rs
+3
-3
src/test/compile-fail/regions-infer-paramd-method.rs
src/test/compile-fail/regions-infer-paramd-method.rs
+5
-2
src/test/compile-fail/regions-trait-2.rs
src/test/compile-fail/regions-trait-2.rs
+4
-4
src/test/compile-fail/regions-trait-3.rs
src/test/compile-fail/regions-trait-3.rs
+6
-3
src/test/compile-fail/tps-invariant-trait.rs
src/test/compile-fail/tps-invariant-trait.rs
+1
-1
src/test/compile-fail/trait-impl-different-num-params.rs
src/test/compile-fail/trait-impl-different-num-params.rs
+1
-1
src/test/compile-fail/trait-test-2.rs
src/test/compile-fail/trait-test-2.rs
+3
-3
src/test/compile-fail/vtable-res-trait-param.rs
src/test/compile-fail/vtable-res-trait-param.rs
+1
-1
src/test/run-pass/autoderef-method-priority.rs
src/test/run-pass/autoderef-method-priority.rs
+3
-0
src/test/run-pass/class-exports.rs
src/test/run-pass/class-exports.rs
+1
-1
src/test/run-pass/impl-variance.rs
src/test/run-pass/impl-variance.rs
+1
-1
src/test/run-pass/issue-2284.rs
src/test/run-pass/issue-2284.rs
+1
-1
src/test/run-pass/issue-2288.rs
src/test/run-pass/issue-2288.rs
+2
-2
src/test/run-pass/kindck-owned-trait-contains-1.rs
src/test/run-pass/kindck-owned-trait-contains-1.rs
+2
-2
src/test/run-pass/monad.rs
src/test/run-pass/monad.rs
+3
-3
src/test/run-pass/rcvr-borrowed-to-region.rs
src/test/run-pass/rcvr-borrowed-to-region.rs
+4
-1
src/test/run-pass/reflect-visit-data.rs
src/test/run-pass/reflect-visit-data.rs
+1
-1
src/test/run-pass/regions-self-impls.rs
src/test/run-pass/regions-self-impls.rs
+1
-1
src/test/run-pass/regions-trait.rs
src/test/run-pass/regions-trait.rs
+1
-1
src/test/run-pass/static-impl.rs
src/test/run-pass/static-impl.rs
+7
-7
src/test/run-pass/trait-generic.rs
src/test/run-pass/trait-generic.rs
+2
-2
src/test/run-pass/trait-inheritance-auto-xc.rs
src/test/run-pass/trait-inheritance-auto-xc.rs
+3
-3
src/test/run-pass/trait-inheritance-cross-trait-call-xc.rs
src/test/run-pass/trait-inheritance-cross-trait-call-xc.rs
+2
-2
src/test/run-pass/trait-to-str.rs
src/test/run-pass/trait-to-str.rs
+2
-2
src/test/run-pass/typeclasses-eq-example.rs
src/test/run-pass/typeclasses-eq-example.rs
+2
-2
未找到文件。
doc/rust.md
浏览文件 @
58f248d9
...
...
@@ -1181,8 +1181,8 @@ Traits are implemented for specific types through separate [implementations](#im
# type BoundingBox = int;
trait Shape {
fn draw(Surface);
fn bounding_box() -> BoundingBox;
fn draw(
&self,
Surface);
fn bounding_box(
&self
) -> BoundingBox;
}
~~~~
...
...
@@ -1195,9 +1195,9 @@ These appear after the trait name, using the same syntax used in [generic functi
~~~~
trait Seq<T> {
fn len() -> uint;
fn elt_at(n: uint) -> T;
fn iter(&fn(T));
fn len(
&self
) -> uint;
fn elt_at(
&self,
n: uint) -> T;
fn iter(&
self, &
fn(T));
}
~~~~
...
...
@@ -1209,7 +1209,7 @@ For example:
~~~~
# type Surface = int;
# trait Shape { fn draw(Surface); }
# trait Shape { fn draw(
&self,
Surface); }
fn draw_twice<T: Shape>(surface: Surface, sh: T) {
sh.draw(surface);
...
...
@@ -1271,8 +1271,8 @@ methods of the supertrait may be called on values of subtrait-bound type paramet
Refering to the previous example of
`trait Circle : Shape`
:
~~~
# trait Shape { fn area() -> float; }
# trait Circle : Shape { fn radius() -> float; }
# trait Shape { fn area(
&self
) -> float; }
# trait Circle : Shape { fn radius(
&self
) -> float; }
fn radius_times_area<T: Circle>(c: T) -> float {
// `c` is both a Circle and a Shape
c.radius() * c.area()
...
...
@@ -1282,10 +1282,10 @@ fn radius_times_area<T: Circle>(c: T) -> float {
Likewise, supertrait methods may also be called on trait objects.
~~~
{.xfail-test}
# trait Shape { fn area() -> float; }
# trait Circle : Shape { fn radius() -> float; }
# impl Shape for int { fn area() -> float { 0.0 } }
# impl Circle for int { fn radius() -> float { 0.0 } }
# trait Shape { fn area(
&self
) -> float; }
# trait Circle : Shape { fn radius(
&self
) -> float; }
# impl Shape for int { fn area(
&self
) -> float { 0.0 } }
# impl Circle for int { fn radius(
&self
) -> float { 0.0 } }
# let mycircle = 0;
let mycircle: Circle = @mycircle as @Circle;
...
...
@@ -1302,7 +1302,7 @@ Implementations are defined with the keyword `impl`.
# struct Point {x: float, y: float};
# type Surface = int;
# struct BoundingBox {x: float, y: float, width: float, height: float};
# trait Shape { fn draw(
Surface); fn bounding_box(
) -> BoundingBox; }
# trait Shape { fn draw(
&self, Surface); fn bounding_box(&self
) -> BoundingBox; }
# fn do_draw_circle(s: Surface, c: Circle) { }
struct Circle {
...
...
@@ -1311,8 +1311,8 @@ struct Circle {
}
impl Shape for Circle {
fn draw(
s: Surface) { do_draw_circle(s,
self); }
fn bounding_box() -> BoundingBox {
fn draw(
&self, s: Surface) { do_draw_circle(s, *
self); }
fn bounding_box(
&self
) -> BoundingBox {
let r = self.radius;
BoundingBox{x: self.center.x - r, y: self.center.y - r,
width: 2.0 * r, height: 2.0 * r}
...
...
@@ -2678,11 +2678,11 @@ An example of an object type:
~~~~~~~~
trait Printable {
fn to_str() -> ~str;
fn to_str(
&self
) -> ~str;
}
impl Printable for int {
fn to_str(
) -> ~str { int::to_str(
self) }
fn to_str(
&self) -> ~str { int::to_str(*
self) }
}
fn print(a: @Printable) {
...
...
@@ -2721,11 +2721,11 @@ example, in:
~~~~~~~~
trait Printable {
fn make_string() -> ~str;
fn make_string(
&self
) -> ~str;
}
impl Printable for ~str {
fn make_string(
) -> ~str { copy
self }
fn make_string(
&self) -> ~str { copy *
self }
}
~~~~~~~~
...
...
src/libcore/rt/thread_local_storage.rs
浏览文件 @
58f248d9
...
...
@@ -10,7 +10,7 @@
use
libc
::{
c_void
};
#[cfg(unix)]
use
libc
::{
c_uint
,
c_int
};
use
libc
::{
c_uint
,
c_
ulong
,
c_
int
};
#[cfg(unix)]
use
ptr
::
null
;
#[cfg(windows)]
...
...
@@ -34,7 +34,12 @@ pub unsafe fn get(key: Key) -> *mut c_void {
unsafe
{
pthread_getspecific
(
key
)
}
}
#[cfg(unix)]
#[cfg(target_os=
"macos"
)]
#[allow(non_camel_case_types)]
// foreign type
type
pthread_key_t
=
c_ulong
;
#[cfg(target_os=
"linux"
)]
#[cfg(target_os=
"freebsd"
)]
#[allow(non_camel_case_types)]
// foreign type
type
pthread_key_t
=
c_uint
;
...
...
src/libsyntax/parse/mod.rs
浏览文件 @
58f248d9
...
...
@@ -312,7 +312,7 @@ mod test {
@~
"fn foo (x : int) { x; }"
,
~
[],
new_parse_sess
(
None
));
check_equal
(
to_json_str
(
@
tts
as
Encodable
::
<
std
::
json
::
Encoder
>
),
check_equal
(
to_json_str
(
@
tts
as
@
Encodable
<
std
::
json
::
Encoder
>
),
~
"[[
\"
tt_tok
\"
,[,[
\"
IDENT
\"
,[
\"
fn
\"
,false]]]],
\
[
\"
tt_tok
\"
,[,[
\"
IDENT
\"
,[
\"
foo
\"
,false]]]],
\
[
\"
tt_delim
\"
,[[[
\"
tt_tok
\"
,[,[
\"
LPAREN
\"
,[]]]],
\
...
...
src/libsyntax/syntax.rc
浏览文件 @
58f248d9
...
...
@@ -22,7 +22,6 @@
#[allow(vecs_implicitly_copyable)];
#[allow(non_camel_case_types)];
#[allow(deprecated_mode)];
#[deny(deprecated_self)];
#[no_core];
...
...
src/test/auxiliary/ambig_impl_2_lib.rs
浏览文件 @
58f248d9
...
...
@@ -11,4 +11,4 @@
trait
me
{
fn
me
(
&
self
)
->
uint
;
}
impl
me
for
uint
{
fn
me
(
&
self
)
->
uint
{
self
}
}
impl
me
for
uint
{
fn
me
(
&
self
)
->
uint
{
*
self
}
}
src/test/compile-fail/ambig_impl_2_exe.rs
浏览文件 @
58f248d9
...
...
@@ -13,8 +13,8 @@
extern
mod
ambig_impl_2_lib
;
use
ambig_impl_2_lib
::
me
;
trait
me
{
fn
me
()
->
uint
;
fn
me
(
&
self
)
->
uint
;
}
impl
me
for
uint
{
fn
me
(
)
->
uint
{
self
}
}
//~ NOTE is `__extensions__::me`
impl
me
for
uint
{
fn
me
(
&
self
)
->
uint
{
*
self
}
}
//~ NOTE is `__extensions__::me`
fn
main
()
{
1u
.me
();
}
//~ ERROR multiple applicable methods in scope
//~^ NOTE is `ambig_impl_2_lib::__extensions__::me`
src/test/compile-fail/ambig_impl_bounds.rs
浏览文件 @
58f248d9
...
...
@@ -8,8 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
trait
A
{
fn
foo
();
}
trait
B
{
fn
foo
();
}
trait
A
{
fn
foo
(
&
self
);
}
trait
B
{
fn
foo
(
&
self
);
}
fn
foo
<
T
:
A
+
B
>
(
t
:
T
)
{
t
.foo
();
//~ ERROR multiple applicable methods in scope
...
...
src/test/compile-fail/borrowck-autoref-3261.rs
浏览文件 @
58f248d9
...
...
@@ -10,8 +10,8 @@
struct
X
(
Either
<
(
uint
,
uint
),
extern
fn
()
>
);
pub
impl
&
'self
X
{
fn
with
(
self
,
blk
:
&
fn
(
x
:
&
Either
<
(
uint
,
uint
),
extern
fn
()
>
))
{
pub
impl
X
{
fn
with
(
&
self
,
blk
:
&
fn
(
x
:
&
Either
<
(
uint
,
uint
),
extern
fn
()
>
))
{
blk
(
&**
self
)
}
}
...
...
src/test/compile-fail/class-cast-to-trait.rs
浏览文件 @
58f248d9
...
...
@@ -49,7 +49,7 @@ fn meow(&self) {
}
}
fn
cat
(
&
self
,
in_x
:
uint
,
in_y
:
int
,
in_name
:
~
str
)
->
cat
{
fn
cat
(
in_x
:
uint
,
in_y
:
int
,
in_name
:
~
str
)
->
cat
{
cat
{
meows
:
in_x
,
how_hungry
:
in_y
,
...
...
src/test/compile-fail/infinite-instantiation.rs
浏览文件 @
58f248d9
...
...
@@ -17,13 +17,13 @@ trait to_opt {
impl
to_opt
for
uint
{
fn
to_option
(
&
self
)
->
Option
<
uint
>
{
Some
(
self
)
Some
(
*
self
)
}
}
impl
<
T
:
Copy
>
to_opt
for
Option
<
T
>
{
fn
to_option
(
&
self
)
->
Option
<
Option
<
T
>>
{
Some
(
self
)
Some
(
*
self
)
}
}
...
...
src/test/compile-fail/issue-2590.rs
浏览文件 @
58f248d9
...
...
@@ -13,11 +13,11 @@ struct parser {
}
trait
parse
{
fn
parse
()
->
~
[
int
];
fn
parse
(
&
self
)
->
~
[
int
];
}
impl
parse
for
parser
{
fn
parse
()
->
~
[
int
]
{
fn
parse
(
&
self
)
->
~
[
int
]
{
self
.tokens
//~ ERROR moving out of immutable field
}
}
...
...
src/test/compile-fail/issue-3021-d.rs
浏览文件 @
58f248d9
...
...
@@ -21,7 +21,7 @@ struct SipState {
v1
:
u64
,
}
fn
mk_result
(
&
self
,
st
:
SipState
)
->
u64
{
fn
mk_result
(
st
:
SipState
)
->
u64
{
let
v0
=
st
.v0
,
v1
=
st
.v1
;
...
...
src/test/compile-fail/kindck-owned-trait-contains.rs
浏览文件 @
58f248d9
...
...
@@ -11,12 +11,12 @@
trait
repeat
<
A
>
{
fn
get
(
&
self
)
->
A
;
}
impl
<
A
:
Copy
>
repeat
<
A
>
for
@
A
{
fn
get
(
&
self
)
->
A
{
*
self
}
fn
get
(
&
self
)
->
A
{
*
*
self
}
}
fn
repeater
<
A
:
Copy
>
(
v
:
@
A
)
->
@
repeat
<
A
>
{
// Note: owned kind is not necessary as A appears in the trait type
@
v
as
@
repeat
::
<
A
>
// No
@
v
as
@
repeat
<
A
>
// No
}
fn
main
()
{
...
...
src/test/compile-fail/kindck-owned-trait-scoped.rs
浏览文件 @
58f248d9
// xfail-test
// xfail'd because to_foo() doesn't work.
// 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.
...
...
@@ -15,7 +18,7 @@ trait foo {
fn
foo
(
&
self
,
i
:
&
'self
int
)
->
int
;
}
impl
<
T
:
Copy
>
foo
<
'self
>
for
T
{
impl
<
T
:
Copy
>
foo
for
T
{
fn
foo
(
&
self
,
i
:
&
'self
int
)
->
int
{
*
i
}
}
...
...
src/test/compile-fail/map-types.rs
浏览文件 @
58f248d9
...
...
@@ -15,7 +15,7 @@
fn
main
()
{
let
x
:
@
Map
<~
str
,
~
str
>
=
@
LinearMap
::
new
::
<~
str
,
~
str
>
()
as
@
(
Map
::
<~
str
,
~
str
>
)
;
@
Map
<~
str
,
~
str
>
;
let
y
:
@
Map
<
uint
,
~
str
>
=
@
x
;
//~^ ERROR mismatched types: expected `@core::container::Map<uint,~str>`
}
src/test/compile-fail/pure-modifies-aliased.rs
浏览文件 @
58f248d9
...
...
@@ -24,7 +24,7 @@ trait modify_in_box_rec {
impl
modify_in_box_rec
for
int
{
pure
fn
modify_in_box_rec
(
&
self
,
sum
:
@
mut
S
)
{
sum
.f
=
self
;
//~ ERROR assigning to mutable field prohibited in pure context
sum
.f
=
*
self
;
//~ ERROR assigning to mutable field prohibited in pure context
}
}
...
...
src/test/compile-fail/regions-bounds.rs
浏览文件 @
58f248d9
...
...
@@ -13,19 +13,12 @@
// checked.
struct
an_enum
(
&
'self
int
);
trait
a_trait
{
fn
foo
(
&
self
)
->
&
'self
int
;
}
struct
a_class
{
x
:
&
'self
int
}
fn
a_fn1
(
e
:
an_enum
<
'a
>
)
->
an_enum
<
'b
>
{
return
e
;
//~ ERROR mismatched types: expected `an_enum/&b` but found `an_enum/&a`
}
fn
a_fn2
(
e
:
@
a_trait
<
'a
>
)
->
@
a_trait
<
'b
>
{
return
e
;
//~ ERROR mismatched types: expected `@a_trait/&b` but found `@a_trait/&a`
}
fn
a_fn3
(
e
:
a_class
<
'a
>
)
->
a_class
<
'b
>
{
return
e
;
//~ ERROR mismatched types: expected `a_class/&b` but found `a_class/&a`
}
...
...
src/test/compile-fail/regions-infer-paramd-indirect.rs
浏览文件 @
58f248d9
...
...
@@ -18,17 +18,17 @@ struct c<'self> {
f
:
@
b
<
'self
>
}
trait
set_f
<
'self
>
{
trait
set_f
{
fn
set_f_ok
(
&
self
,
b
:
@
b
<
'self
>
);
fn
set_f_bad
(
&
self
,
b
:
@
b
);
}
impl
<
'self
>
set_f
<
'self
>
for
c
<
'self
>
{
impl
<
'self
>
set_f
for
c
<
'self
>
{
fn
set_f_ok
(
&
self
,
b
:
@
b
<
'self
>
)
{
self
.f
=
b
;
}
fn
set_f_bad
(
b
:
@
b
)
{
fn
set_f_bad
(
&
self
,
b
:
@
b
)
{
self
.f
=
b
;
//~ ERROR mismatched types: expected `@@&self/int` but found `@@&int`
}
}
...
...
src/test/compile-fail/regions-infer-paramd-method.rs
浏览文件 @
58f248d9
// xfail-test
// xfail'd due to problems with by value self.
// 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.
...
...
@@ -12,9 +15,9 @@
// refers to self.
trait
foo
<
'self
>
{
fn
self_int
(
&
self
)
->
&
'self
int
;
fn
self_int
(
self
)
->
&
'self
int
;
fn
any_int
(
&
self
)
->
&
int
;
fn
any_int
(
self
)
->
&
int
;
}
struct
with_foo
<
'self
>
{
...
...
src/test/compile-fail/regions-trait-2.rs
浏览文件 @
58f248d9
...
...
@@ -10,22 +10,22 @@
struct
ctxt
{
v
:
uint
}
trait
get_ctxt
<
'self
>
{
trait
get_ctxt
{
fn
get_ctxt
(
&
self
)
->
&
'self
ctxt
;
}
struct
has_ctxt
<
'self
>
{
c
:
&
'self
ctxt
}
impl
<
'self
>
get_ctxt
<
'self
>
for
has_ctxt
<
'self
>
{
impl
<
'self
>
get_ctxt
for
has_ctxt
<
'self
>
{
fn
get_ctxt
(
&
self
)
->
&
self
/
ctxt
{
self
.c
}
}
fn
make_gc
()
->
@
get_ctxt
{
let
ctxt
=
ctxt
{
v
:
22u
};
let
hc
=
has_ctxt
{
c
:
&
ctxt
};
//~ ERROR illegal borrow
let
hc
=
has_ctxt
{
c
:
&
ctxt
};
return
@
hc
as
@
get_ctxt
;
}
fn
main
()
{
make_gc
()
.get_ctxt
()
.v
;
make_gc
()
.get_ctxt
()
.v
;
//~ ERROR illegal borrow
}
src/test/compile-fail/regions-trait-3.rs
浏览文件 @
58f248d9
// xfail-test
// xfail'd due to problems with by-value self.
// 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.
...
...
@@ -9,7 +12,7 @@
// except according to those terms.
trait
get_ctxt
{
fn
get_ctxt
(
&
self
)
->
&
self
/
uint
;
fn
get_ctxt
(
self
)
->
&
self
/
uint
;
}
fn
make_gc1
(
gc
:
@
get_ctxt
/&
a
)
->
@
get_ctxt
/&
b
{
...
...
@@ -20,8 +23,8 @@ struct Foo {
r
:
&
'self
uint
}
impl
get_ctxt
/&
self
for
Foo
/&
self
{
fn
get_ctxt
(
&
self
)
->
&
self
/
uint
{
self
.r
}
impl
get_ctxt
for
Foo
<
'self
>
{
fn
get_ctxt
(
&
self
)
->
&
'self
uint
{
self
.r
}
}
fn
make_gc2
(
foo
:
Foo
/&
a
)
->
@
get_ctxt
/&
b
{
...
...
src/test/compile-fail/tps-invariant-trait.rs
浏览文件 @
58f248d9
...
...
@@ -34,7 +34,7 @@ fn set_box_impl<T>(b: box_impl<@const T>, v: @const T) {
fn
main
()
{
let
b
=
box_impl
::
<@
int
>
(
box
::
<@
int
>
{
f
:
@
3
});
set_box_trait
(
@
b
as
@
box_trait
::
<@
int
>
,
@
mut
5
);
set_box_trait
(
@
b
as
@
box_trait
<@
int
>
,
@
mut
5
);
//~^ ERROR values differ in mutability
set_box_impl
(
b
,
@
mut
5
);
//~^ ERROR values differ in mutability
...
...
src/test/compile-fail/trait-impl-different-num-params.rs
浏览文件 @
58f248d9
...
...
@@ -14,7 +14,7 @@ trait foo {
impl
foo
for
int
{
fn
bar
(
&
self
)
->
int
{
//~^ ERROR method `bar` has 0 parameters but the trait has 1
self
*
self
}
}
...
...
src/test/compile-fail/trait-test-2.rs
浏览文件 @
58f248d9
...
...
@@ -8,9 +8,9 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
trait
bar
{
fn
dup
(
&
self
)
->
Self
;
fn
blah
<
X
>
();
}
impl
bar
for
int
{
fn
dup
(
&
self
)
->
int
{
self
}
fn
blah
<
X
>
(
)
{}
}
impl
bar
for
uint
{
fn
dup
(
&
self
)
->
uint
{
self
}
fn
blah
<
X
>
(
)
{}
}
trait
bar
{
fn
dup
(
&
self
)
->
Self
;
fn
blah
<
X
>
(
&
self
);
}
impl
bar
for
int
{
fn
dup
(
&
self
)
->
int
{
*
self
}
fn
blah
<
X
>
(
&
self
)
{}
}
impl
bar
for
uint
{
fn
dup
(
&
self
)
->
uint
{
*
self
}
fn
blah
<
X
>
(
&
self
)
{}
}
fn
main
()
{
10
i
.dup
::
<
int
>
();
//~ ERROR does not take type parameters
...
...
src/test/compile-fail/vtable-res-trait-param.rs
浏览文件 @
58f248d9
...
...
@@ -18,7 +18,7 @@ trait TraitB {
impl
TraitB
for
int
{
fn
gimme_an_a
<
A
:
TraitA
>
(
&
self
,
a
:
A
)
->
int
{
a
.method_a
()
+
self
a
.method_a
()
+
*
self
}
}
...
...
src/test/run-pass/autoderef-method-priority.rs
浏览文件 @
58f248d9
// xfail-test
// xfail'd because of a problem with by-value self.
// 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.
...
...
src/test/run-pass/class-exports.rs
浏览文件 @
58f248d9
...
...
@@ -25,7 +25,7 @@ pub impl cat {
fn
get_name
(
&
self
)
->
~
str
{
copy
self
.name
}
}
pub
fn
cat
(
&
self
,
in_name
:
~
str
)
->
cat
{
pub
fn
cat
(
in_name
:
~
str
)
->
cat
{
cat
{
name
:
in_name
,
meows
:
0u
...
...
src/test/run-pass/impl-variance.rs
浏览文件 @
58f248d9
...
...
@@ -13,7 +13,7 @@ trait foo {
}
impl
<
T
>
foo
for
~
[
const
T
]
{
fn
foo
(
&
self
)
->
uint
{
vec
::
len
(
self
)
}
fn
foo
(
&
self
)
->
uint
{
vec
::
len
(
*
self
)
}
}
pub
fn
main
()
{
...
...
src/test/run-pass/issue-2284.rs
浏览文件 @
58f248d9
...
...
@@ -13,7 +13,7 @@ trait Send {
}
fn
f
<
T
:
Send
>
(
t
:
T
)
{
t
.f
(
&
self
);
t
.f
();
}
pub
fn
main
()
{
...
...
src/test/run-pass/issue-2288.rs
浏览文件 @
58f248d9
...
...
@@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
trait
c
lam
<
A
:
Copy
>
{
trait
clam
<
A
:
Copy
>
{
fn
chowder
(
&
self
,
y
:
A
);
}
struct
foo
<
A
>
{
...
...
@@ -33,6 +33,6 @@ fn f<A:Copy>(x: @clam<A>, a: A) {
pub
fn
main
()
{
let
c
=
foo
(
42
);
let
d
:
@
clam
<
int
>
=
@
c
as
@
clam
::
<
int
>
;
let
d
:
@
clam
<
int
>
=
@
c
as
@
clam
<
int
>
;
f
(
d
,
c
.x
);
}
src/test/run-pass/kindck-owned-trait-contains-1.rs
浏览文件 @
58f248d9
...
...
@@ -11,12 +11,12 @@
trait
repeat
<
A
>
{
fn
get
(
&
self
)
->
A
;
}
impl
<
A
:
Copy
>
repeat
<
A
>
for
@
A
{
fn
get
(
&
self
)
->
A
{
*
self
}
fn
get
(
&
self
)
->
A
{
*
*
self
}
}
fn
repeater
<
A
:
Copy
>
(
v
:
@
A
)
->
@
repeat
<
A
>
{
// Note: owned kind is not necessary as A appears in the trait type
@
v
as
@
repeat
::
<
A
>
// No
@
v
as
@
repeat
<
A
>
// No
}
pub
fn
main
()
{
...
...
src/test/run-pass/monad.rs
浏览文件 @
58f248d9
...
...
@@ -28,9 +28,9 @@ trait option_monad<A> {
impl
<
A
>
option_monad
<
A
>
for
Option
<
A
>
{
fn
bind
<
B
>
(
&
self
,
f
:
&
fn
(
&
A
)
->
Option
<
B
>
)
->
Option
<
B
>
{
match
self
{
Some
(
ref
a
)
=>
{
f
(
a
)
}
None
=>
{
None
}
match
*
self
{
Some
(
ref
a
)
=>
{
f
(
a
)
}
None
=>
{
None
}
}
}
}
...
...
src/test/run-pass/rcvr-borrowed-to-region.rs
浏览文件 @
58f248d9
// xfail-test
// xfail'd due to segfaults with by-value self.
// 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.
...
...
@@ -15,7 +18,7 @@ trait get {
// Note: impl on a slice
impl
get
for
&
'self
int
{
fn
get
(
self
)
->
int
{
return
*
self
;
return
*
*
self
;
}
}
...
...
src/test/run-pass/reflect-visit-data.rs
浏览文件 @
58f248d9
...
...
@@ -487,7 +487,7 @@ fn get<T>(&self, f: &fn(T)) {
fn
visit_inner
(
&
self
,
inner
:
*
TyDesc
)
->
bool
{
unsafe
{
let
u
=
my_visitor
(
*
self
);
let
u
=
my_visitor
(
*
*
self
);
let
v
=
ptr_visit_adaptor
::
<
my_visitor
>
(
Inner
{
inner
:
u
});
visit_tydesc
(
inner
,
@
v
as
@
TyVisitor
);
true
...
...
src/test/run-pass/regions-self-impls.rs
浏览文件 @
58f248d9
...
...
@@ -16,7 +16,7 @@ trait get_chowder<'self> {
fn
get_chowder
(
&
self
)
->
&
'self
int
;
}
impl
<
'self
>
get_chowder
<
'self
>
for
Clam
<
'self
>
{
impl
<
'self
>
get_chowder
for
Clam
<
'self
>
{
fn
get_chowder
(
&
self
)
->
&
'self
int
{
return
self
.chowder
;
}
}
...
...
src/test/run-pass/regions-trait.rs
浏览文件 @
58f248d9
...
...
@@ -16,7 +16,7 @@ trait get_ctxt {
struct
HasCtxt
{
c
:
&
'self
Ctxt
}
impl
get_ctxt
<
'self
>
for
HasCtxt
<
'self
>
{
impl
get_ctxt
for
HasCtxt
<
'self
>
{
fn
get_ctxt
(
&
self
)
->
&
self
/
Ctxt
{
self
.c
}
...
...
src/test/run-pass/static-impl.rs
浏览文件 @
58f248d9
...
...
@@ -16,7 +16,7 @@ pub trait plus {
mod
a
{
use
plus
;
impl
plus
for
uint
{
fn
plus
(
&
self
)
->
int
{
self
as
int
+
20
}
}
impl
plus
for
uint
{
fn
plus
(
&
self
)
->
int
{
*
self
as
int
+
20
}
}
}
mod
b
{
...
...
@@ -25,15 +25,15 @@ impl plus for ~str { fn plus(&self) -> int { 200 } }
}
trait
uint_utils
{
fn
str
(
self
)
->
~
str
;
fn
multi
(
self
,
f
:
&
fn
(
uint
));
fn
str
(
&
self
)
->
~
str
;
fn
multi
(
&
self
,
f
:
&
fn
(
uint
));
}
impl
uint_utils
for
uint
{
fn
str
(
self
)
->
~
str
{
uint
::
to_str
(
self
)
}
fn
multi
(
self
,
f
:
&
fn
(
uint
))
{
fn
str
(
&
self
)
->
~
str
{
uint
::
to_str
(
*
self
)
}
fn
multi
(
&
self
,
f
:
&
fn
(
uint
))
{
let
mut
c
=
0u
;
while
c
<
self
{
f
(
c
);
c
+=
1u
;
}
while
c
<
*
self
{
f
(
c
);
c
+=
1u
;
}
}
}
...
...
@@ -44,7 +44,7 @@ trait vec_utils<T> {
}
impl
<
T
>
vec_utils
<
T
>
for
~
[
T
]
{
fn
length_
(
&
self
)
->
uint
{
vec
::
len
(
self
)
}
fn
length_
(
&
self
)
->
uint
{
vec
::
len
(
*
self
)
}
fn
iter_
(
&
self
,
f
:
&
fn
(
&
T
))
{
for
self
.each
|
x
|
{
f
(
x
);
}
}
fn
map_
<
U
:
Copy
>
(
&
self
,
f
:
&
fn
(
&
T
)
->
U
)
->
~
[
U
]
{
let
mut
r
=
~
[];
...
...
src/test/run-pass/trait-generic.rs
浏览文件 @
58f248d9
...
...
@@ -14,10 +14,10 @@ trait to_str {
fn
to_str
(
&
self
)
->
~
str
;
}
impl
to_str
for
int
{
fn
to_str
(
&
self
)
->
~
str
{
int
::
to_str
(
self
)
}
fn
to_str
(
&
self
)
->
~
str
{
int
::
to_str
(
*
self
)
}
}
impl
to_str
for
~
str
{
fn
to_str
(
&
self
)
->
~
str
{
copy
self
}
fn
to_str
(
&
self
)
->
~
str
{
copy
*
self
}
}
impl
to_str
for
()
{
fn
to_str
(
&
self
)
->
~
str
{
~
"()"
}
...
...
src/test/run-pass/trait-inheritance-auto-xc.rs
浏览文件 @
58f248d9
...
...
@@ -17,9 +17,9 @@
struct
A
{
x
:
int
}
impl
Foo
for
A
{
fn
f
()
->
int
{
10
}
}
impl
Bar
for
A
{
fn
g
()
->
int
{
20
}
}
impl
Baz
for
A
{
fn
h
()
->
int
{
30
}
}
impl
Foo
for
A
{
fn
f
(
&
self
)
->
int
{
10
}
}
impl
Bar
for
A
{
fn
g
(
&
self
)
->
int
{
20
}
}
impl
Baz
for
A
{
fn
h
(
&
self
)
->
int
{
30
}
}
fn
f
<
T
:
Quux
>
(
a
:
&
T
)
{
fail_unless!
(
a
.f
()
==
10
);
...
...
src/test/run-pass/trait-inheritance-cross-trait-call-xc.rs
浏览文件 @
58f248d9
...
...
@@ -16,11 +16,11 @@
use
aux
::
Foo
;
trait
Bar
:
Foo
{
fn
g
()
->
int
;
fn
g
(
&
self
)
->
int
;
}
impl
Bar
for
aux
::
A
{
fn
g
()
->
int
{
self
.f
()
}
fn
g
(
&
self
)
->
int
{
self
.f
()
}
}
pub
fn
main
()
{
...
...
src/test/run-pass/trait-to-str.rs
浏览文件 @
58f248d9
...
...
@@ -21,12 +21,12 @@ trait to_str {
}
impl
to_str
for
int
{
fn
to_str
(
&
self
)
->
~
str
{
int
::
to_str
(
self
)
}
fn
to_str
(
&
self
)
->
~
str
{
int
::
to_str
(
*
self
)
}
}
impl
<
T
:
to_str
>
to_str
for
~
[
T
]
{
fn
to_str
(
&
self
)
->
~
str
{
~
"["
+
str
::
connect
(
vec
::
map
(
self
,
|
e
|
e
.to_str
()
),
~
", "
)
+
~
"]"
~
"["
+
str
::
connect
(
vec
::
map
(
*
self
,
|
e
|
e
.to_str
()
),
~
", "
)
+
~
"]"
}
}
...
...
src/test/run-pass/typeclasses-eq-example.rs
浏览文件 @
58f248d9
...
...
@@ -18,7 +18,7 @@ enum Color { cyan, magenta, yellow, black }
impl
Equal
for
Color
{
fn
isEq
(
&
self
,
a
:
Color
)
->
bool
{
match
(
self
,
a
)
{
match
(
*
self
,
a
)
{
(
cyan
,
cyan
)
=>
{
true
}
(
magenta
,
magenta
)
=>
{
true
}
(
yellow
,
yellow
)
=>
{
true
}
...
...
@@ -35,7 +35,7 @@ enum ColorTree {
impl
Equal
for
ColorTree
{
fn
isEq
(
&
self
,
a
:
ColorTree
)
->
bool
{
match
(
self
,
a
)
{
match
(
*
self
,
a
)
{
(
leaf
(
x
),
leaf
(
y
))
=>
{
x
.isEq
(
y
)
}
(
branch
(
l1
,
r1
),
branch
(
l2
,
r2
))
=>
{
(
*
l1
)
.isEq
(
*
l2
)
&&
(
*
r1
)
.isEq
(
*
r2
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录