Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
c97c03cd
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,发现更多精彩内容 >>
提交
c97c03cd
编写于
4月 08, 2013
作者:
N
Niko Matsakis
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
tests: changes in response to #5656
上级
03396473
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
14 addition
and
125 deletion
+14
-125
src/test/compile-fail/issue-3311.rs
src/test/compile-fail/issue-3311.rs
+0
-31
src/test/compile-fail/issue-3563.rs
src/test/compile-fail/issue-3563.rs
+1
-1
src/test/compile-fail/issue-3888.rs
src/test/compile-fail/issue-3888.rs
+0
-42
src/test/compile-fail/issue-3969.rs
src/test/compile-fail/issue-3969.rs
+1
-1
src/test/compile-fail/regions-infer-paramd-indirect.rs
src/test/compile-fail/regions-infer-paramd-indirect.rs
+2
-2
src/test/compile-fail/staticness-mismatch.rs
src/test/compile-fail/staticness-mismatch.rs
+1
-1
src/test/run-pass/class-impl-very-parameterized-trait.rs
src/test/run-pass/class-impl-very-parameterized-trait.rs
+5
-5
src/test/run-pass/explicit-self.rs
src/test/run-pass/explicit-self.rs
+1
-1
src/test/run-pass/issue-3860.rs
src/test/run-pass/issue-3860.rs
+1
-1
src/test/run-pass/regions-parameterization-self-types-issue-5224.rs
...un-pass/regions-parameterization-self-types-issue-5224.rs
+0
-38
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/compile-fail/issue-3311.rs
已删除
100644 → 0
浏览文件 @
03396473
// 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.
#[legacy_mode]
struct
Foo
<
'self
>
{
s
:
&
'self
str
,
u
:
~
()
}
pub
impl
<
'self
>
Foo
<
'self
>
{
fn
get_s
(
&
self
)
->
&
'self
str
{
self
.s
}
}
fn
bar
(
s
:
&
str
,
f
:
&
fn
(
Option
<
Foo
>
))
{
f
(
Some
(
Foo
{
s
:
s
,
u
:
~
()}));
}
fn
main
()
{
do
bar
(
~
"testing"
)
|
opt
|
{
io
::
println
(
opt
.unwrap
()
.get_s
());
//~ ERROR illegal borrow:
};
}
src/test/compile-fail/issue-3563.rs
浏览文件 @
c97c03cd
...
...
@@ -10,7 +10,7 @@
trait
A
{
fn
a
(
&
self
)
{
||
self
.b
()
//~ ERROR type `&
'self
Self` does not implement any method in scope named `b`
||
self
.b
()
//~ ERROR type `&Self` does not implement any method in scope named `b`
}
}
fn
main
()
{}
src/test/compile-fail/issue-3888.rs
已删除
100644 → 0
浏览文件 @
03396473
// 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.
// n.b. This should be a run-pass test, but for now I'm testing
// that we don't see an "unknown scope" error.
fn
vec_peek
<
'r
,
T
>
(
v
:
&
'r
[
T
])
->
Option
<
(
&
'r
T
,
&
'r
[
T
])
>
{
if
v
.len
()
==
0
{
None
}
else
{
let
vec_len
=
v
.len
();
let
head
=
&
v
[
0
];
// note: this *shouldn't* be an illegal borrow! See #3888
let
tail
=
v
.slice
(
1
,
vec_len
);
//~ ERROR illegal borrow: borrowed value does not live long enough
Some
(
(
head
,
tail
)
)
}
}
fn
test_peek_empty_stack
()
{
let
v
:
&
[
int
]
=
&
[];
assert
!
((
None
==
vec_peek
(
v
)));
}
fn
test_peek_empty_unique
()
{
let
v
:
~
[
int
]
=
~
[];
assert
!
((
None
==
vec_peek
(
v
)));
}
fn
test_peek_empty_managed
()
{
let
v
:
@
[
int
]
=
@
[];
assert
!
((
None
==
vec_peek
(
v
)));
}
fn
main
()
{}
src/test/compile-fail/issue-3969.rs
浏览文件 @
c97c03cd
...
...
@@ -18,7 +18,7 @@ trait BikeMethods {
impl
BikeMethods
for
Bike
{
fn
woops
()
->
~
str
{
~
"foo"
}
//~^ ERROR
method `woops` is declared as static in its impl, but not in its trait
//~^ ERROR
has a `&const self` declaration in the trait, but not in the impl
}
pub
fn
main
()
{
...
...
src/test/compile-fail/regions-infer-paramd-indirect.rs
浏览文件 @
c97c03cd
...
...
@@ -18,12 +18,12 @@ struct c<'self> {
f
:
@
b
<
'self
>
}
trait
set_f
{
trait
set_f
<
'self
>
{
fn
set_f_ok
(
&
self
,
b
:
@
b
<
'self
>
);
fn
set_f_bad
(
&
self
,
b
:
@
b
);
}
impl
<
'self
>
set_f
for
c
<
'self
>
{
impl
<
'self
>
set_f
<
'self
>
for
c
<
'self
>
{
fn
set_f_ok
(
&
self
,
b
:
@
b
<
'self
>
)
{
self
.f
=
b
;
}
...
...
src/test/compile-fail/staticness-mismatch.rs
浏览文件 @
c97c03cd
...
...
@@ -14,7 +14,7 @@ trait foo {
}
impl
foo
for
int
{
fn
bar
(
&
self
)
{}
//~ ERROR method `bar`
is declared as static in its trait, but not in its impl
fn
bar
(
&
self
)
{}
//~ ERROR method `bar`
has a `&self` declaration in the impl, but not in the trait
}
fn
main
()
{}
src/test/run-pass/class-impl-very-parameterized-trait.rs
浏览文件 @
c97c03cd
...
...
@@ -59,7 +59,7 @@ fn clear(&mut self) {}
}
impl
<
T
>
Map
<
int
,
T
>
for
cat
<
T
>
{
fn
each
(
&
self
,
f
:
&
fn
(
&
int
,
&
T
)
->
bool
)
{
fn
each
<
'a
>
(
&
'a
self
,
f
:
&
fn
(
&
int
,
&
'a
T
)
->
bool
)
{
let
mut
n
=
int
::
abs
(
self
.meows
);
while
n
>
0
{
if
!
f
(
&
n
,
&
self
.name
)
{
break
;
}
...
...
@@ -73,7 +73,7 @@ fn each_key(&self, f: &fn(v: &int) -> bool) {
for
self
.each
|
k
,
_
|
{
if
!
f
(
k
)
{
break
;
}
loop
;};
}
fn
each_value
(
&
self
,
f
:
&
fn
(
v
:
&
T
)
->
bool
)
{
fn
each_value
<
'a
>
(
&
'a
self
,
f
:
&
fn
(
v
:
&
'a
T
)
->
bool
)
{
for
self
.each
|
_
,
v
|
{
if
!
f
(
v
)
{
break
;
}
loop
;};
}
...
...
@@ -86,7 +86,7 @@ fn insert(&mut self, k: int, _: T) -> bool {
true
}
fn
find
(
&
self
,
k
:
&
int
)
->
Option
<&
'self
T
>
{
fn
find
<
'a
>
(
&
'a
self
,
k
:
&
int
)
->
Option
<&
'a
T
>
{
if
*
k
<=
self
.meows
{
Some
(
&
self
.name
)
}
else
{
...
...
@@ -94,7 +94,7 @@ fn find(&self, k: &int) -> Option<&'self T> {
}
}
fn
find_mut
(
&
mut
self
,
_
k
:
&
int
)
->
Option
<&
'self
mut
T
>
{
fail
!
()
}
fn
find_mut
<
'a
>
(
&
'a
mut
self
,
_
k
:
&
int
)
->
Option
<&
'a
mut
T
>
{
fail
!
()
}
fn
remove
(
&
mut
self
,
k
:
&
int
)
->
bool
{
if
self
.find
(
k
)
.is_some
()
{
...
...
@@ -106,7 +106,7 @@ fn remove(&mut self, k: &int) -> bool {
}
pub
impl
<
T
>
cat
<
T
>
{
fn
get
(
&
self
,
k
:
&
int
)
->
&
'self
T
{
fn
get
<
'a
>
(
&
'a
self
,
k
:
&
int
)
->
&
'a
T
{
match
self
.find
(
k
)
{
Some
(
v
)
=>
{
v
}
None
=>
{
fail
!
(
~
"epic fail"
);
}
...
...
src/test/run-pass/explicit-self.rs
浏览文件 @
c97c03cd
...
...
@@ -58,7 +58,7 @@ pub 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
A
{
&
self
.x
}
fn
baz
<
'a
>
(
&
'a
self
)
->
&
'a
A
{
&
self
.x
}
fn
spam
(
self
)
->
int
{
*
self
.x.a
}
}
...
...
src/test/run-pass/issue-3860.rs
浏览文件 @
c97c03cd
...
...
@@ -11,7 +11,7 @@
struct
Foo
{
x
:
int
}
pub
impl
Foo
{
fn
stuff
(
&
mut
self
)
->
&
'self
mut
Foo
{
fn
stuff
<
'a
>
(
&
'a
mut
self
)
->
&
'a
mut
Foo
{
return
self
;
}
}
...
...
src/test/run-pass/regions-parameterization-self-types-issue-5224.rs
已删除
100644 → 0
浏览文件 @
03396473
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// Test how region-parameterization inference
// interacts with explicit self types.
//
// Issue #5224.
trait
Getter
{
// This trait does not need to be
// region-parameterized, because 'self
// is bound in the self type:
fn
get
(
&
self
)
->
&
'self
int
;
}
struct
Foo
{
field
:
int
}
impl
Getter
for
Foo
{
fn
get
(
&
self
)
->
&
'self
int
{
&
self
.field
}
}
fn
get_int
<
G
:
Getter
>
(
g
:
&
G
)
->
int
{
*
g
.get
()
}
pub
fn
main
()
{
let
foo
=
Foo
{
field
:
22
};
assert
!
(
get_int
(
&
foo
)
==
22
);
}
src/test/run-pass/regions-self-impls.rs
浏览文件 @
c97c03cd
...
...
@@ -16,7 +16,7 @@ trait get_chowder<'self> {
fn
get_chowder
(
&
self
)
->
&
'self
int
;
}
impl
<
'self
>
get_chowder
for
Clam
<
'self
>
{
impl
<
'self
>
get_chowder
<
'self
>
for
Clam
<
'self
>
{
fn
get_chowder
(
&
self
)
->
&
'self
int
{
return
self
.chowder
;
}
}
...
...
src/test/run-pass/regions-trait.rs
浏览文件 @
c97c03cd
...
...
@@ -16,7 +16,7 @@ trait get_ctxt<'self> {
struct
HasCtxt
<
'self
>
{
c
:
&
'self
Ctxt
}
impl
<
'self
>
get_ctxt
for
HasCtxt
<
'self
>
{
impl
<
'self
>
get_ctxt
<
'self
>
for
HasCtxt
<
'self
>
{
fn
get_ctxt
(
&
self
)
->
&
'self
Ctxt
{
self
.c
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录