Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
b7e72974
R
Rust
项目概览
int
/
Rust
12 个月 前同步成功
通知
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,发现更多精彩内容 >>
提交
b7e72974
编写于
2月 28, 2013
作者:
B
bors
浏览文件
操作
浏览文件
下载
差异文件
auto merge of #5147 : nikomatsakis/rust/remove-legacy-trait-table, r=nikomatsakis
r? @pcwalton
上级
66f9e60e
4ecb672d
变更
54
展开全部
隐藏空白更改
内联
并排
Showing
54 changed file
with
295 addition
and
354 deletion
+295
-354
src/libcore/io.rs
src/libcore/io.rs
+7
-7
src/libcore/rand.rs
src/libcore/rand.rs
+6
-6
src/libcore/repr.rs
src/libcore/repr.rs
+2
-2
src/libcore/run.rs
src/libcore/run.rs
+1
-1
src/libcore/task/local_data_priv.rs
src/libcore/task/local_data_priv.rs
+1
-1
src/librustc/metadata/common.rs
src/librustc/metadata/common.rs
+2
-3
src/librustc/metadata/filesearch.rs
src/librustc/metadata/filesearch.rs
+2
-2
src/librustc/middle/astencode.rs
src/librustc/middle/astencode.rs
+1
-9
src/librustc/middle/trans/cabi.rs
src/librustc/middle/trans/cabi.rs
+2
-2
src/librustc/middle/trans/cabi_arm.rs
src/librustc/middle/trans/cabi_arm.rs
+2
-2
src/librustc/middle/trans/cabi_x86_64.rs
src/librustc/middle/trans/cabi_x86_64.rs
+1
-1
src/librustc/middle/trans/meth.rs
src/librustc/middle/trans/meth.rs
+5
-20
src/librustc/middle/ty.rs
src/librustc/middle/ty.rs
+0
-2
src/librustc/middle/typeck/check/vtable.rs
src/librustc/middle/typeck/check/vtable.rs
+97
-133
src/librustc/middle/typeck/rscope.rs
src/librustc/middle/typeck/rscope.rs
+3
-3
src/libstd/sha1.rs
src/libstd/sha1.rs
+2
-2
src/libsyntax/ext/auto_encode.rs
src/libsyntax/ext/auto_encode.rs
+3
-5
src/libsyntax/fold.rs
src/libsyntax/fold.rs
+113
-108
src/libsyntax/parse/mod.rs
src/libsyntax/parse/mod.rs
+1
-1
src/test/auxiliary/issue-2380.rs
src/test/auxiliary/issue-2380.rs
+1
-1
src/test/bench/shootout-mandelbrot.rs
src/test/bench/shootout-mandelbrot.rs
+1
-1
src/test/compile-fail/class-cast-to-trait.rs
src/test/compile-fail/class-cast-to-trait.rs
+1
-1
src/test/compile-fail/kindck-owned-trait-contains.rs
src/test/compile-fail/kindck-owned-trait-contains.rs
+1
-1
src/test/compile-fail/kindck-owned-trait-scoped.rs
src/test/compile-fail/kindck-owned-trait-scoped.rs
+3
-3
src/test/compile-fail/kindck-owned-trait.rs
src/test/compile-fail/kindck-owned-trait.rs
+2
-2
src/test/compile-fail/map-types.rs
src/test/compile-fail/map-types.rs
+2
-2
src/test/compile-fail/regions-trait-1.rs
src/test/compile-fail/regions-trait-1.rs
+1
-1
src/test/compile-fail/regions-trait-2.rs
src/test/compile-fail/regions-trait-2.rs
+1
-1
src/test/compile-fail/regions-trait-3.rs
src/test/compile-fail/regions-trait-3.rs
+1
-1
src/test/compile-fail/selftype-astparam.rs
src/test/compile-fail/selftype-astparam.rs
+2
-2
src/test/compile-fail/tps-invariant-trait.rs
src/test/compile-fail/tps-invariant-trait.rs
+1
-1
src/test/compile-fail/trait-cast.rs
src/test/compile-fail/trait-cast.rs
+1
-1
src/test/compile-fail/trait-test-2.rs
src/test/compile-fail/trait-test-2.rs
+1
-1
src/test/run-fail/unwind-box-trait.rs
src/test/run-fail/unwind-box-trait.rs
+1
-1
src/test/run-pass/autoderef-method-on-trait-monomorphized.rs
src/test/run-pass/autoderef-method-on-trait-monomorphized.rs
+1
-1
src/test/run-pass/autoderef-method-on-trait.rs
src/test/run-pass/autoderef-method-on-trait.rs
+1
-1
src/test/run-pass/boxed-trait-with-vstore.rs
src/test/run-pass/boxed-trait-with-vstore.rs
+1
-1
src/test/run-pass/class-cast-to-trait-cross-crate-2.rs
src/test/run-pass/class-cast-to-trait-cross-crate-2.rs
+1
-1
src/test/run-pass/class-cast-to-trait-multiple-types.rs
src/test/run-pass/class-cast-to-trait-multiple-types.rs
+2
-2
src/test/run-pass/class-cast-to-trait.rs
src/test/run-pass/class-cast-to-trait.rs
+1
-1
src/test/run-pass/class-separate-impl.rs
src/test/run-pass/class-separate-impl.rs
+1
-1
src/test/run-pass/explicit-self-objects-ext-1.rs
src/test/run-pass/explicit-self-objects-ext-1.rs
+1
-1
src/test/run-pass/explicit-self-objects-ext-2.rs
src/test/run-pass/explicit-self-objects-ext-2.rs
+1
-1
src/test/run-pass/explicit-self-objects-ext-3.rs
src/test/run-pass/explicit-self-objects-ext-3.rs
+1
-1
src/test/run-pass/explicit-self-objects-ext-4.rs
src/test/run-pass/explicit-self-objects-ext-4.rs
+1
-1
src/test/run-pass/issue-2288.rs
src/test/run-pass/issue-2288.rs
+1
-1
src/test/run-pass/issue-2734.rs
src/test/run-pass/issue-2734.rs
+1
-1
src/test/run-pass/issue-2735.rs
src/test/run-pass/issue-2735.rs
+3
-3
src/test/run-pass/issue-2904.rs
src/test/run-pass/issue-2904.rs
+1
-1
src/test/run-pass/issue-2935.rs
src/test/run-pass/issue-2935.rs
+1
-1
src/test/run-pass/issue-3305.rs
src/test/run-pass/issue-3305.rs
+1
-1
src/test/run-pass/kindck-owned-trait-contains-1.rs
src/test/run-pass/kindck-owned-trait-contains-1.rs
+1
-1
src/test/run-pass/reflect-visit-data.rs
src/test/run-pass/reflect-visit-data.rs
+2
-2
src/test/run-pass/regions-trait.rs
src/test/run-pass/regions-trait.rs
+1
-1
未找到文件。
src/libcore/io.rs
浏览文件 @
b7e72974
...
...
@@ -504,7 +504,7 @@ pub fn FILE_reader(f: *libc::FILE, cleanup: bool) -> @Reader {
pub
fn
stdin
()
->
@
Reader
{
unsafe
{
rustrt
::
rust_get_stdin
()
as
@
Reader
@
rustrt
::
rust_get_stdin
()
as
@
Reader
}
}
...
...
@@ -642,11 +642,11 @@ fn get_type(&self) -> WriterType {
}
}
pub
fn
FILE_writer
(
f
:
*
libc
::
FILE
,
cleanup
:
bool
)
->
Writer
{
pub
fn
FILE_writer
(
f
:
*
libc
::
FILE
,
cleanup
:
bool
)
->
@
Writer
{
if
cleanup
{
Wrapper
{
base
:
f
,
cleanup
:
FILERes
(
f
)
}
as
Writer
@
Wrapper
{
base
:
f
,
cleanup
:
FILERes
(
f
)
}
as
@
Writer
}
else
{
f
as
Writer
@
f
as
@
Writer
}
}
...
...
@@ -702,11 +702,11 @@ pub fn FdRes(fd: fd_t) -> FdRes {
}
}
pub
fn
fd_writer
(
fd
:
fd_t
,
cleanup
:
bool
)
->
Writer
{
pub
fn
fd_writer
(
fd
:
fd_t
,
cleanup
:
bool
)
->
@
Writer
{
if
cleanup
{
Wrapper
{
base
:
fd
,
cleanup
:
FdRes
(
fd
)
}
as
Writer
@
Wrapper
{
base
:
fd
,
cleanup
:
FdRes
(
fd
)
}
as
@
Writer
}
else
{
fd
as
Writer
@
fd
as
@
Writer
}
}
...
...
src/libcore/rand.rs
浏览文件 @
b7e72974
...
...
@@ -412,8 +412,8 @@ pub fn Rng() -> Rng {
* all other generators constructed with the same seed. The seed may be any
* length.
*/
pub
fn
seeded_rng
(
seed
:
&
[
u8
])
->
Rng
{
seeded_randres
(
seed
)
as
Rng
pub
fn
seeded_rng
(
seed
:
&
[
u8
])
->
@
Rng
{
@
seeded_randres
(
seed
)
as
@
Rng
}
fn
seeded_randres
(
seed
:
&
[
u8
])
->
@
RandRes
{
...
...
@@ -449,8 +449,8 @@ fn next() -> u32 {
seeded_xorshift
(
123456789u32
,
362436069u32
,
521288629u32
,
88675123u32
)
}
pub
pure
fn
seeded_xorshift
(
x
:
u32
,
y
:
u32
,
z
:
u32
,
w
:
u32
)
->
Rng
{
XorShiftState
{
x
:
x
,
y
:
y
,
z
:
z
,
w
:
w
}
as
Rng
pub
pure
fn
seeded_xorshift
(
x
:
u32
,
y
:
u32
,
z
:
u32
,
w
:
u32
)
->
@
Rng
{
@
XorShiftState
{
x
:
x
,
y
:
y
,
z
:
z
,
w
:
w
}
as
@
Rng
}
...
...
@@ -472,10 +472,10 @@ pub fn task_rng() -> Rng {
unsafe
{
let
rng
=
seeded_randres
(
seed
());
task
::
local_data
::
local_data_set
(
tls_rng_state
,
rng
);
rng
as
Rng
@
rng
as
@
Rng
}
}
Some
(
rng
)
=>
rng
as
Rng
Some
(
rng
)
=>
@
rng
as
@
Rng
}
}
...
...
src/libcore/repr.rs
浏览文件 @
b7e72974
...
...
@@ -201,7 +201,7 @@ fn visit_ptr_inner(ptr: *c_void, inner: *TyDesc) -> bool {
unsafe
{
let
mut
u
=
ReprVisitor
(
ptr
,
self
.writer
);
let
v
=
reflect
::
MovePtrAdaptor
(
u
);
visit_tydesc
(
inner
,
(
v
)
as
@
TyVisitor
);
visit_tydesc
(
inner
,
@
v
as
@
TyVisitor
);
true
}
}
...
...
@@ -570,7 +570,7 @@ pub fn write_repr<T>(writer: @Writer, object: &T) {
let
tydesc
=
intrinsic
::
get_tydesc
::
<
T
>
();
let
mut
u
=
ReprVisitor
(
ptr
,
writer
);
let
v
=
reflect
::
MovePtrAdaptor
(
u
);
visit_tydesc
(
tydesc
,
(
v
)
as
@
TyVisitor
)
visit_tydesc
(
tydesc
,
@
v
as
@
TyVisitor
)
}
}
...
...
src/libcore/run.rs
浏览文件 @
b7e72974
...
...
@@ -288,7 +288,7 @@ fn finish(&mut self) -> int { finish_repr(&mut self.r) }
finished
:
false
,
};
ProgRes
(
repr
)
as
Program
@
ProgRes
(
repr
)
as
@
Program
}
fn
read_all
(
rd
:
io
::
Reader
)
->
~
str
{
...
...
src/libcore/task/local_data_priv.rs
浏览文件 @
b7e72974
...
...
@@ -155,7 +155,7 @@ pub unsafe fn local_set<T:Durable>(
// does not have a reference associated with it, so it may become invalid
// when the box is destroyed.
let
data_ptr
=
cast
::
reinterpret_cast
(
&
data
);
let
data_box
=
data
as
LocalData
;
let
data_box
=
@
data
as
@
LocalData
;
// Construct new entry to store in the map.
let
new_entry
=
Some
((
keyval
,
data_ptr
,
data_box
));
// Find a place to put it.
...
...
src/librustc/metadata/common.rs
浏览文件 @
b7e72974
...
...
@@ -132,9 +132,8 @@ pub enum astencode_tag { // Reserves 0x50 -- 0x6f
tag_table_method_map
=
0x60
,
tag_table_vtable_map
=
0x61
,
tag_table_adjustments
=
0x62
,
tag_table_legacy_boxed_trait
=
0x63
,
tag_table_moves_map
=
0x64
,
tag_table_capture_map
=
0x65
tag_table_moves_map
=
0x63
,
tag_table_capture_map
=
0x64
}
pub
const
tag_item_trait_method_sort
:
uint
=
0x70
;
...
...
src/librustc/metadata/filesearch.rs
浏览文件 @
b7e72974
...
...
@@ -71,11 +71,11 @@ fn get_target_lib_file_path(&self, file: &Path) -> Path {
let
sysroot
=
get_sysroot
(
maybe_sysroot
);
debug!
(
"using sysroot = %s"
,
sysroot
.to_str
());
FileSearchImpl
{
@
FileSearchImpl
{
sysroot
:
sysroot
,
addl_lib_search_paths
:
addl_lib_search_paths
,
target_triple
:
str
::
from_slice
(
target_triple
)
}
as
FileSearch
}
as
@
FileSearch
}
pub
fn
search
<
T
:
Copy
>
(
filesearch
:
FileSearch
,
pick
:
pick
<
T
>
)
->
Option
<
T
>
{
...
...
src/librustc/middle/astencode.rs
浏览文件 @
b7e72974
...
...
@@ -966,12 +966,6 @@ fn encode_side_tables_for_id(ecx: @e::EncodeContext,
}
}
do
option
::
iter
(
&
tcx
.legacy_boxed_traits
.find
(
&
id
))
|
_
x
|
{
do
ebml_w
.tag
(
c
::
tag_table_legacy_boxed_trait
)
{
ebml_w
.id
(
id
);
}
}
for
maps
.moves_map
.find
(
&
id
)
.each
|
_
|
{
do
ebml_w
.tag
(
c
::
tag_table_moves_map
)
{
ebml_w
.id
(
id
);
...
...
@@ -1121,8 +1115,6 @@ fn decode_side_tables(xcx: @ExtendedDecodeContext,
if
tag
==
(
c
::
tag_table_mutbl
as
uint
)
{
dcx
.maps.mutbl_map
.insert
(
id
,
());
}
else
if
tag
==
(
c
::
tag_table_legacy_boxed_trait
as
uint
)
{
dcx
.tcx.legacy_boxed_traits
.insert
(
id
,
());
}
else
if
tag
==
(
c
::
tag_table_moves_map
as
uint
)
{
dcx
.maps.moves_map
.insert
(
id
,
());
}
else
{
...
...
@@ -1230,7 +1222,7 @@ fn ident_of(&self, +st: ~str) -> ast::ident {
#[cfg(test)]
fn
mk_ctxt
()
->
fake_ext_ctxt
{
parse
::
new_parse_sess
(
None
)
as
fake_ext_ctxt
@
parse
::
new_parse_sess
(
None
)
as
fake_ext_ctxt
}
#[cfg(test)]
...
...
src/librustc/middle/trans/cabi.rs
浏览文件 @
b7e72974
...
...
@@ -209,8 +209,8 @@ fn compute_info(&self,
}
}
pub
fn
llvm_abi_info
()
->
ABIInfo
{
return
LLVM_ABIInfo
as
ABIInfo
;
pub
fn
llvm_abi_info
()
->
@
ABIInfo
{
return
@
LLVM_ABIInfo
as
@
ABIInfo
;
}
src/librustc/middle/trans/cabi_arm.rs
浏览文件 @
b7e72974
...
...
@@ -159,6 +159,6 @@ fn compute_info(&self,
}
}
pub
fn
abi_info
()
->
ABIInfo
{
return
ARM_ABIInfo
as
ABIInfo
;
pub
fn
abi_info
()
->
@
ABIInfo
{
return
@
ARM_ABIInfo
as
@
ABIInfo
;
}
src/librustc/middle/trans/cabi_x86_64.rs
浏览文件 @
b7e72974
...
...
@@ -408,5 +408,5 @@ fn compute_info(&self,
}
pub
fn
x86_64_abi_info
()
->
ABIInfo
{
return
X86_64_ABIInfo
as
ABIInfo
;
return
@
X86_64_ABIInfo
as
@
ABIInfo
;
}
src/librustc/middle/trans/meth.rs
浏览文件 @
b7e72974
...
...
@@ -870,26 +870,11 @@ pub fn trans_trait_cast(bcx: block,
match
vstore
{
ty
::
vstore_slice
(
*
)
|
ty
::
vstore_box
=>
{
let
mut
llboxdest
=
GEPi
(
bcx
,
lldest
,
[
0u
,
1u
]);
if
bcx
.tcx
()
.legacy_boxed_traits
.contains_key
(
&
id
)
{
// Allocate an @ box and store the value into it
let
MallocResult
{
bcx
:
new_bcx
,
box
:
llbox
,
body
:
body
}
=
malloc_boxed
(
bcx
,
v_ty
);
bcx
=
new_bcx
;
add_clean_free
(
bcx
,
llbox
,
heap_managed
);
bcx
=
expr
::
trans_into
(
bcx
,
val
,
SaveIn
(
body
));
revoke_clean
(
bcx
,
llbox
);
// Store the @ box into the pair
Store
(
bcx
,
llbox
,
PointerCast
(
bcx
,
llboxdest
,
T_ptr
(
val_ty
(
llbox
))));
}
else
{
// Just store the pointer into the pair.
llboxdest
=
PointerCast
(
bcx
,
llboxdest
,
T_ptr
(
type_of
(
bcx
.ccx
(),
v_ty
)));
bcx
=
expr
::
trans_into
(
bcx
,
val
,
SaveIn
(
llboxdest
));
}
// Just store the pointer into the pair.
llboxdest
=
PointerCast
(
bcx
,
llboxdest
,
T_ptr
(
type_of
(
bcx
.ccx
(),
v_ty
)));
bcx
=
expr
::
trans_into
(
bcx
,
val
,
SaveIn
(
llboxdest
));
}
ty
::
vstore_uniq
=>
{
// Translate the uniquely-owned value into the second element of
...
...
src/librustc/middle/ty.rs
浏览文件 @
b7e72974
...
...
@@ -269,7 +269,6 @@ struct ctxt_ {
adjustments
:
HashMap
<
ast
::
node_id
,
@
AutoAdjustment
>
,
normalized_cache
:
HashMap
<
t
,
t
>
,
lang_items
:
middle
::
lang_items
::
LanguageItems
,
legacy_boxed_traits
:
HashMap
<
node_id
,
()
>
,
// A mapping from an implementation ID to the method info and trait
// method ID of the provided (a.k.a. default) methods in the traits that
// that implementation implements.
...
...
@@ -831,7 +830,6 @@ pub fn mk_ctxt(s: session::Session,
adjustments
:
HashMap
(),
normalized_cache
:
new_ty_hash
(),
lang_items
:
lang_items
,
legacy_boxed_traits
:
HashMap
(),
provided_methods
:
HashMap
(),
provided_method_sources
:
HashMap
(),
supertraits
:
HashMap
(),
...
...
src/librustc/middle/typeck/check/vtable.rs
浏览文件 @
b7e72974
...
...
@@ -97,8 +97,8 @@ pub fn lookup_vtables(vcx: &VtableContext,
let
mut
result
=
~
[],
i
=
0u
;
for
substs
.tps.each
|
ty
|
{
for
ty
::
iter_bound_traits_and_supertraits
(
tcx
,
bounds
[
i
])
|
trait_ty
|
{
tcx
,
bounds
[
i
])
|
trait_ty
|
{
debug!
(
"about to subst: %?, %?"
,
ppaux
::
ty_to_str
(
tcx
,
trait_ty
),
ty
::
substs_to_str
(
tcx
,
substs
));
...
...
@@ -585,138 +585,102 @@ pub fn early_resolve_expr(ex: @ast::expr,
}
}
ast
::
expr_cast
(
src
,
_
)
=>
{
let
target_ty
=
fcx
.expr_ty
(
ex
);
match
ty
::
get
(
target_ty
)
.sty
{
ty
::
ty_trait
(
_
,
_
,
vstore
)
=>
{
// Look up vtables for the type we're casting to, passing in the
// source and target type.
//
// XXX: This is invariant and shouldn't be. --pcw
let
ty
=
fcx
.expr_ty
(
src
);
let
vcx
=
VtableContext
{
ccx
:
fcx
.ccx
,
infcx
:
fcx
.infcx
()
};
let
vtable_opt
=
lookup_vtable
(
&
vcx
,
&
location_info_for_expr
(
ex
),
ty
,
target_ty
,
true
,
is_early
);
match
vtable_opt
{
None
=>
{
// Try the new-style boxed trait; "@int as @Trait".
// Or the new-style region trait; "&int as &Trait".
// Or the new-style uniquely-owned trait; "~int as
// ~Trait".
let
mut
err
=
false
;
let
ty
=
structurally_resolved_type
(
fcx
,
ex
.span
,
ty
);
match
ty
::
get
(
ty
)
.sty
{
ty
::
ty_box
(
mt
)
|
ty
::
ty_rptr
(
_
,
mt
)
|
ty
::
ty_uniq
(
mt
)
=>
{
// Ensure that the trait vstore and the pointer
// type match.
match
(
&
ty
::
get
(
ty
)
.sty
,
vstore
)
{
(
&
ty
::
ty_box
(
_
),
ty
::
vstore_box
)
|
(
&
ty
::
ty_uniq
(
_
),
ty
::
vstore_uniq
)
|
(
&
ty
::
ty_rptr
(
*
),
ty
::
vstore_slice
(
*
))
=>
{
let
location_info
=
&
location_info_for_expr
(
ex
);
let
vtable_opt
=
lookup_vtable
(
&
vcx
,
location_info
,
mt
.ty
,
target_ty
,
true
,
is_early
);
match
vtable_opt
{
Some
(
vtable
)
=>
{
// Map this expression to that
// vtable (that is: "ex has vtable
// <vtable>")
if
!
is_early
{
let
vtable_map
=
cx
.vtable_map
;
vtable_map
.insert
(
ex
.id
,
@~
[
vtable
]);
}
}
None
=>
err
=
true
}
// Now, if this is &trait, we need to link
// the regions.
match
(
&
ty
::
get
(
ty
)
.sty
,
vstore
)
{
(
&
ty
::
ty_rptr
(
ra
,
_
),
ty
::
vstore_slice
(
rb
))
=>
{
infer
::
mk_subr
(
fcx
.infcx
(),
false
,
ex
.span
,
rb
,
ra
);
}
_
=>
{}
}
}
(
&
ty
::
ty_box
(
_
),
_
)
=>
{
fcx
.ccx.tcx.sess
.span_err
(
ex
.span
,
~
"must cast
\
a boxed
\
pointer to
\
a boxed
trait"
);
err
=
true
;
}
(
&
ty
::
ty_rptr
(
*
),
_
)
=>
{
fcx
.ccx.tcx.sess
.span_err
(
ex
.span
,
~
"must cast
\
a borrowed
\
pointer to
\
a borrowed
\
trait"
);
}
(
&
ty
::
ty_uniq
(
*
),
_
)
=>
{
fcx
.ccx.tcx.sess
.span_err
(
ex
.span
,
~
"must cast
\
a unique
\
pointer to
\
a uniquely-
\
owned trait"
);
}
_
=>
{
fcx
.ccx.tcx.sess
.impossible_case
(
ex
.span
,
~
"impossible combination of type and
\
trait vstore"
);
}
}
}
_
=>
err
=
true
}
if
err
{
fcx
.tcx
()
.sess
.span_fatal
(
ex
.span
,
fmt!
(
"failed to find an implementation of trait
\
%s for %s"
,
fcx
.infcx
()
.ty_to_str
(
target_ty
),
fcx
.infcx
()
.ty_to_str
(
ty
)));
}
}
Some
(
vtable
)
=>
{
/*
Map this expression to that vtable (that is: "ex has
vtable <vtable>")
*/
if
!
is_early
{
let
vtable_map
=
cx
.vtable_map
;
vtable_map
.insert
(
ex
.id
,
@~
[
vtable
]);
}
fcx
.tcx
()
.legacy_boxed_traits
.insert
(
ex
.id
,
());
}
}
let
target_ty
=
fcx
.expr_ty
(
ex
);
match
ty
::
get
(
target_ty
)
.sty
{
ty
::
ty_trait
(
_
,
_
,
vstore
)
=>
{
// Look up vtables for the type we're casting to,
// passing in the source and target type. The source
// must be a pointer type suitable to the object sigil,
// e.g.: `@x as @Trait`, `&x as &Trait` or `~x as ~Trait`
let
ty
=
structurally_resolved_type
(
fcx
,
ex
.span
,
fcx
.expr_ty
(
src
));
match
(
&
ty
::
get
(
ty
)
.sty
,
vstore
)
{
(
&
ty
::
ty_box
(
mt
),
ty
::
vstore_box
)
|
(
&
ty
::
ty_uniq
(
mt
),
ty
::
vstore_uniq
)
|
(
&
ty
::
ty_rptr
(
_
,
mt
),
ty
::
vstore_slice
(
*
))
=>
{
let
location_info
=
&
location_info_for_expr
(
ex
);
let
vcx
=
VtableContext
{
ccx
:
fcx
.ccx
,
infcx
:
fcx
.infcx
()
};
let
vtable_opt
=
lookup_vtable
(
&
vcx
,
location_info
,
mt
.ty
,
target_ty
,
true
,
is_early
);
match
vtable_opt
{
Some
(
vtable
)
=>
{
// Map this expression to that
// vtable (that is: "ex has vtable
// <vtable>")
if
!
is_early
{
let
vtable_map
=
cx
.vtable_map
;
vtable_map
.insert
(
ex
.id
,
@~
[
vtable
]);
}
}
None
=>
{
fcx
.tcx
()
.sess
.span_err
(
ex
.span
,
fmt!
(
"failed to find an implementation
\
of trait %s for %s"
,
fcx
.infcx
()
.ty_to_str
(
target_ty
),
fcx
.infcx
()
.ty_to_str
(
mt
.ty
)));
}
}
// Now, if this is &trait, we need to link the
// regions.
match
(
&
ty
::
get
(
ty
)
.sty
,
vstore
)
{
(
&
ty
::
ty_rptr
(
ra
,
_
),
ty
::
vstore_slice
(
rb
))
=>
{
infer
::
mk_subr
(
fcx
.infcx
(),
false
,
ex
.span
,
rb
,
ra
);
}
_
=>
{}
}
}
(
_
,
ty
::
vstore_box
(
*
))
=>
{
fcx
.ccx.tcx.sess
.span_err
(
ex
.span
,
fmt!
(
"can only cast an @-pointer
\
to an @-object, not a %s"
,
ty
::
ty_sort_str
(
fcx
.tcx
(),
ty
)));
}
(
_
,
ty
::
vstore_uniq
(
*
))
=>
{
fcx
.ccx.tcx.sess
.span_err
(
ex
.span
,
fmt!
(
"can only cast an ~-pointer
\
to a ~-object, not a %s"
,
ty
::
ty_sort_str
(
fcx
.tcx
(),
ty
)));
}
(
_
,
ty
::
vstore_slice
(
*
))
=>
{
fcx
.ccx.tcx.sess
.span_err
(
ex
.span
,
fmt!
(
"can only cast an &-pointer
\
to an &-object, not a %s"
,
ty
::
ty_sort_str
(
fcx
.tcx
(),
ty
)));
}
(
_
,
ty
::
vstore_fixed
(
*
))
=>
{
fcx
.tcx
()
.sess
.span_bug
(
ex
.span
,
fmt!
(
"trait with fixed vstore"
));
}
}
}
_
=>
{
/* not a cast to a trait; ignore */
}
}
_
=>
()
}
}
_
=>
()
}
...
...
src/librustc/middle/typeck/rscope.rs
浏览文件 @
b7e72974
...
...
@@ -70,11 +70,11 @@ pub fn bound_self_region(rp: Option<ty::region_variance>)
}
}
pub
struct
anon_rscope
{
anon
:
ty
::
Region
,
base
:
region_scope
}
pub
struct
anon_rscope
{
anon
:
ty
::
Region
,
base
:
@
region_scope
}
pub
fn
in_anon_rscope
<
RS
:
region_scope
+
Copy
+
Durable
>
(
self
:
RS
,
r
:
ty
::
Region
)
->
@
anon_rscope
{
@
anon_rscope
{
anon
:
r
,
base
:
self
as
region_scope
}
@
anon_rscope
{
anon
:
r
,
base
:
@
self
as
@
region_scope
}
}
impl
region_scope
for
@
anon_rscope
{
...
...
@@ -97,7 +97,7 @@ pub struct binding_rscope {
pub
fn
in_binding_rscope
<
RS
:
region_scope
+
Copy
+
Durable
>
(
self
:
RS
)
->
@
mut
binding_rscope
{
let
base
=
self
as
region_scope
;
let
base
=
@
self
as
@
region_scope
;
@
mut
binding_rscope
{
base
:
base
,
anon_bindings
:
0
}
}
...
...
src/libstd/sha1.rs
浏览文件 @
b7e72974
...
...
@@ -63,7 +63,7 @@ trait Sha1 {
/// Construct a `sha` object
pub
fn
sha1
()
->
Sha1
{
pub
fn
sha1
()
->
@
Sha1
{
struct
Sha1State
{
h
:
~
[
u32
],
len_low
:
u32
,
...
...
@@ -269,7 +269,7 @@ fn result_str(&mut self) -> ~str {
computed
:
false
,
work_buf
:
@
mut
vec
::
from_elem
(
work_buf_len
,
0u32
)
};
let
mut
sh
=
(
st
)
as
Sha1
;
let
mut
sh
=
@
st
as
@
Sha1
;
sh
.reset
();
return
sh
;
}
...
...
src/libsyntax/ext/auto_encode.rs
浏览文件 @
b7e72974
...
...
@@ -1296,7 +1296,7 @@ fn emit_tup_elt(&self, +_idx: uint, f: fn()) {
}
fn
to_call_log
(
val
:
Encodable
<
TestEncoder
>
)
->
~
[
call
]
{
fn
to_call_log
<
E
:
Encodable
<
TestEncoder
>>
(
val
:
E
)
->
~
[
call
]
{
let
mut
te
=
TestEncoder
{
call_log
:
@
mut
~
[]};
val
.encode
(
&
te
);
copy
*
te
.call_log
...
...
@@ -1309,8 +1309,7 @@ enum Written {
}
#[test]
fn
encode_enum_test
()
{
check_equal
(
to_call_log
(
Book
(
34
,
44
)
as
Encodable
::
<
TestEncoder
>
),
check_equal
(
to_call_log
(
Book
(
34
,
44
)),
~
[
CallToEmitEnum
(
~
"Written"
),
CallToEmitEnumVariant
(
~
"Book"
,
0
,
2
),
CallToEmitEnumVariantArg
(
0
),
...
...
@@ -1325,8 +1324,7 @@ enum Written {
pub
struct
HasPos
{
pos
:
BPos
}
#[test]
fn
encode_newtype_test
()
{
check_equal
(
to_call_log
(
HasPos
{
pos
:
BPos
(
48
)}
as
Encodable
::
<
TestEncoder
>
),
check_equal
(
to_call_log
(
HasPos
{
pos
:
BPos
(
48
)}),
~
[
CallToEmitStruct
(
~
"HasPos"
,
1
),
CallToEmitField
(
~
"pos"
,
0
),
CallToEmitUint
(
48
)]);
...
...
src/libsyntax/fold.rs
浏览文件 @
b7e72974
此差异已折叠。
点击以展开。
src/libsyntax/parse/mod.rs
浏览文件 @
b7e72974
...
...
@@ -251,7 +251,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/test/auxiliary/issue-2380.rs
浏览文件 @
b7e72974
...
...
@@ -16,5 +16,5 @@ pub trait i<T> { }
pub
fn
f
<
T
>
()
->
i
<
T
>
{
impl
<
T
>
i
<
T
>
for
()
{
}
()
as
i
::
<
T
>
@
()
as
@
i
<
T
>
}
src/test/bench/shootout-mandelbrot.rs
浏览文件 @
b7e72974
...
...
@@ -112,7 +112,7 @@ fn writer(path: ~str, pport: comm::Port<Line>, size: uint)
{
let
cout
:
io
::
Writer
=
match
path
{
~
""
=>
{
Devnull
as
io
::
Writer
@
Devnull
as
@
io
::
Writer
}
~
"-"
=>
{
io
::
stdout
()
...
...
src/test/compile-fail/class-cast-to-trait.rs
浏览文件 @
b7e72974
...
...
@@ -58,6 +58,6 @@ fn cat(in_x : uint, in_y : int, in_name: ~str) -> cat {
}
fn
main
()
{
let
nyan
:
noisy
=
cat
(
0
,
2
,
~
"nyan"
)
as
noisy
;
let
nyan
:
noisy
=
@
cat
(
0
,
2
,
~
"nyan"
)
as
@
noisy
;
nyan
.eat
();
//~ ERROR type `@noisy` does not implement any method in scope named `eat`
}
src/test/compile-fail/kindck-owned-trait-contains.rs
浏览文件 @
b7e72974
...
...
@@ -16,7 +16,7 @@ fn get() -> 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
浏览文件 @
b7e72974
...
...
@@ -26,7 +26,7 @@ fn to_foo<T:Copy>(t: T) {
// the fn body itself.
let
v
=
&
3
;
struct
F
<
T
>
{
f
:
T
}
let
x
=
F
{
f
:
t
}
as
foo
;
let
x
=
@
F
{
f
:
t
}
as
foo
;
assert
x
.foo
(
v
)
==
3
;
}
...
...
@@ -34,14 +34,14 @@ fn to_foo_2<T:Copy>(t: T) -> foo {
// Not OK---T may contain borrowed ptrs and it is going to escape
// as part of the returned foo value
struct
F
<
T
>
{
f
:
T
}
F
{
f
:
t
}
as
foo
//~ ERROR value may contain borrowed pointers; use `&static` bound
@
F
{
f
:
t
}
as
foo
//~ ERROR value may contain borrowed pointers; use `&static` bound
}
fn
to_foo_3
<
T
:
Copy
+
&
static
>
(
t
:
T
)
->
foo
{
// OK---T may escape as part of the returned foo value, but it is
// owned and hence does not contain borrowed ptrs
struct
F
<
T
>
{
f
:
T
}
F
{
f
:
t
}
as
foo
@
F
{
f
:
t
}
as
foo
}
fn
main
()
{
...
...
src/test/compile-fail/kindck-owned-trait.rs
浏览文件 @
b7e72974
...
...
@@ -11,11 +11,11 @@
trait
foo
{
fn
foo
();
}
fn
to_foo
<
T
:
Copy
+
foo
>
(
t
:
T
)
->
foo
{
t
as
foo
//~ ERROR value may contain borrowed pointers; use `&static` bound
@
t
as
@
foo
//~ ERROR value may contain borrowed pointers; use `&static` bound
}
fn
to_foo2
<
T
:
Copy
+
foo
+
&
static
>
(
t
:
T
)
->
foo
{
t
as
foo
@
t
as
@
foo
}
fn
main
()
{}
src/test/compile-fail/map-types.rs
浏览文件 @
b7e72974
...
...
@@ -14,8 +14,8 @@
// Test that trait types printed in error msgs include the type arguments.
fn
main
()
{
let
x
:
Map
<~
str
,
~
str
>
=
LinearMap
::
new
::
<~
str
,
~
str
>
()
as
let
x
:
@
Map
<~
str
,
~
str
>
=
@
LinearMap
::
new
::
<~
str
,
~
str
>
()
as
Map
::
<~
str
,
~
str
>
;
let
y
:
Map
<
uint
,
~
str
>
=
x
;
let
y
:
@
Map
<
uint
,
~
str
>
=
@
x
;
//~^ ERROR mismatched types: expected `@core::container::Map/&<uint,~str>`
}
src/test/compile-fail/regions-trait-1.rs
浏览文件 @
b7e72974
...
...
@@ -34,5 +34,5 @@ fn get_v(gc: get_ctxt) -> uint {
fn
main
()
{
let
ctxt
=
ctxt
{
v
:
22u
};
let
hc
=
has_ctxt
{
c
:
&
ctxt
};
assert
get_v
(
hc
as
get_ctxt
)
==
22u
;
assert
get_v
(
@
hc
as
get_ctxt
)
==
22u
;
}
src/test/compile-fail/regions-trait-2.rs
浏览文件 @
b7e72974
...
...
@@ -23,7 +23,7 @@ fn get_ctxt() -> &self/ctxt { self.c }
fn
make_gc
()
->
get_ctxt
{
let
ctxt
=
ctxt
{
v
:
22u
};
let
hc
=
has_ctxt
{
c
:
&
ctxt
};
//~ ERROR illegal borrow
return
hc
as
get_ctxt
;
return
@
hc
as
get_ctxt
;
}
fn
main
()
{
...
...
src/test/compile-fail/regions-trait-3.rs
浏览文件 @
b7e72974
...
...
@@ -17,7 +17,7 @@ fn make_gc1(gc: get_ctxt/&a) -> get_ctxt/&b {
}
fn
make_gc2
(
gc
:
get_ctxt
/&
a
)
->
get_ctxt
/&
b
{
return
gc
as
get_ctxt
;
//~ ERROR cannot infer an appropriate lifetime
return
@
gc
as
get_ctxt
;
//~ ERROR cannot infer an appropriate lifetime
}
fn
main
()
{
...
...
src/test/compile-fail/selftype-astparam.rs
浏览文件 @
b7e72974
...
...
@@ -19,7 +19,7 @@ fn plus(++x: int) -> int { self + x }
fn
do_add
<
A
:
add
>
(
x
:
A
,
y
:
A
)
->
A
{
x
.plus
(
y
)
}
fn
main
()
{
let
x
=
3
as
add
;
let
y
=
4
as
add
;
let
x
=
@
3
as
@
add
;
let
y
=
@
4
as
@
add
;
do_add
(
x
,
y
);
//~ ERROR a boxed trait with self types may not be passed as a bounded type
}
src/test/compile-fail/tps-invariant-trait.rs
浏览文件 @
b7e72974
...
...
@@ -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-cast.rs
浏览文件 @
b7e72974
...
...
@@ -11,7 +11,7 @@
trait
foo
<
T
>
{
}
fn
bar
(
x
:
foo
<
uint
>
)
->
foo
<
int
>
{
return
(
x
as
foo
::
<
int
>
);
return
(
@
x
as
foo
::
<
int
>
);
//~^ ERROR mismatched types: expected `@foo<int>` but found `@foo<uint>`
//~^^ ERROR mismatched types: expected `@foo<int>` but found `@foo<uint>`
// This is unfortunate -- new handling of parens means the error message
...
...
src/test/compile-fail/trait-test-2.rs
浏览文件 @
b7e72974
...
...
@@ -15,5 +15,5 @@ impl bar for uint { fn dup() -> uint { self } fn blah<X>() {} }
fn
main
()
{
10
i
.dup
::
<
int
>
();
//~ ERROR does not take type parameters
10
i
.blah
::
<
int
,
int
>
();
//~ ERROR incorrect number of type parameters
(
10
as
bar
)
.dup
();
//~ ERROR contains a self-type
(
@
10
as
bar
)
.dup
();
//~ ERROR contains a self-type
}
src/test/run-fail/unwind-box-trait.rs
浏览文件 @
b7e72974
...
...
@@ -23,7 +23,7 @@ fn foo() { }
}
fn
main
()
{
let
x
=
~
0
as
i
;
let
x
=
@~
0
as
@
i
;
failfn
();
log
(
error
,
x
);
}
src/test/run-pass/autoderef-method-on-trait-monomorphized.rs
浏览文件 @
b7e72974
...
...
@@ -21,6 +21,6 @@ fn is_equal<D:double>(x: @D, exp: uint) {
}
pub
fn
main
()
{
let
x
=
@
(
3u
as
double
);
let
x
=
@
(
@
3u
as
@
double
);
is_equal
(
x
,
6
);
}
src/test/run-pass/autoderef-method-on-trait.rs
浏览文件 @
b7e72974
...
...
@@ -17,6 +17,6 @@ fn double() -> uint { self * 2u }
}
pub
fn
main
()
{
let
x
=
@
(
3u
as
double
);
let
x
=
@
(
@
3u
as
@
double
);
assert
x
.double
()
==
6u
;
}
src/test/run-pass/boxed-trait-with-vstore.rs
浏览文件 @
b7e72974
...
...
@@ -19,7 +19,7 @@ fn foo() {
}
pub
fn
main
()
{
let
x
=
3
as
@
Foo
;
let
x
=
@
3
as
@
Foo
;
x
.foo
();
}
src/test/run-pass/class-cast-to-trait-cross-crate-2.rs
浏览文件 @
b7e72974
...
...
@@ -21,7 +21,7 @@ fn print_out<T:ToStr>(thing: T, expected: ~str) {
}
pub
fn
main
()
{
let
nyan
:
ToStr
=
cat
(
0u
,
2
,
~
"nyan"
)
as
ToStr
;
let
nyan
:
@
ToStr
=
@
cat
(
0u
,
2
,
~
"nyan"
)
as
@
ToStr
;
print_out
(
nyan
,
~
"nyan"
);
}
src/test/run-pass/class-cast-to-trait-multiple-types.rs
浏览文件 @
b7e72974
...
...
@@ -86,8 +86,8 @@ fn annoy_neighbors<T:noisy>(critter: T) {
pub
fn
main
()
{
let
nyan
:
cat
=
cat
(
0u
,
2
,
~
"nyan"
);
let
whitefang
:
dog
=
dog
();
annoy_neighbors
(
(
copy
nyan
)
as
noisy
);
annoy_neighbors
(
(
copy
whitefang
)
as
noisy
);
annoy_neighbors
(
@
(
copy
nyan
)
as
@
noisy
);
annoy_neighbors
(
@
(
copy
whitefang
)
as
@
noisy
);
assert
(
nyan
.meow_count
()
==
10u
);
assert
(
*
whitefang
.volume
==
1
);
}
src/test/run-pass/class-cast-to-trait.rs
浏览文件 @
b7e72974
...
...
@@ -56,6 +56,6 @@ fn cat(in_x : uint, in_y : int, in_name: ~str) -> cat {
pub
fn
main
()
{
let
mut
nyan
:
noisy
=
cat
(
0u
,
2
,
~
"nyan"
)
as
noisy
;
let
mut
nyan
:
@
noisy
=
@
cat
(
0u
,
2
,
~
"nyan"
)
as
@
noisy
;
nyan
.speak
();
}
src/test/run-pass/class-separate-impl.rs
浏览文件 @
b7e72974
...
...
@@ -63,6 +63,6 @@ fn print_out<T:ToStr>(thing: T, expected: ~str) {
}
pub
fn
main
()
{
let
mut
nyan
:
ToStr
=
cat
(
0u
,
2
,
~
"nyan"
)
as
ToStr
;
let
mut
nyan
:
@
ToStr
=
@
cat
(
0u
,
2
,
~
"nyan"
)
as
@
ToStr
;
print_out
(
nyan
,
~
"nyan"
);
}
src/test/run-pass/explicit-self-objects-ext-1.rs
浏览文件 @
b7e72974
...
...
@@ -34,6 +34,6 @@ fn read(&self, bytes: &mut [u8], len: uint) -> uint {
pub
fn
main
()
{
let
x
=
S
{
x
:
1
,
y
:
2
};
let
x
=
x
as
@
Reader
;
let
x
=
@
x
as
@
Reader
;
x
.read_bytes
(
0
);
}
src/test/run-pass/explicit-self-objects-ext-2.rs
浏览文件 @
b7e72974
...
...
@@ -34,6 +34,6 @@ fn read(&self, bytes: &mut [u8], len: uint) -> uint {
pub
fn
main
()
{
let
x
=
S
{
x
:
1
,
y
:
2
};
let
x
=
x
as
@
Reader
;
let
x
=
@
x
as
@
Reader
;
x
.read_bytes
(
0
);
}
src/test/run-pass/explicit-self-objects-ext-3.rs
浏览文件 @
b7e72974
...
...
@@ -34,6 +34,6 @@ fn read(&self, bytes: &mut [u8], len: uint) -> uint {
pub
fn
main
()
{
let
x
=
S
{
x
:
1
,
y
:
2
};
let
x
=
x
as
@
Reader
;
let
x
=
@
x
as
@
Reader
;
x
.read_bytes
(
0
);
}
src/test/run-pass/explicit-self-objects-ext-4.rs
浏览文件 @
b7e72974
...
...
@@ -34,6 +34,6 @@ fn read(bytes: &mut [u8], len: uint) -> uint {
pub
fn
main
()
{
let
x
=
S
{
x
:
1
,
y
:
2
};
let
x
=
x
as
@
Reader
;
let
x
=
@
x
as
@
Reader
;
x
.read_bytes
(
0
);
}
src/test/run-pass/issue-2288.rs
浏览文件 @
b7e72974
...
...
@@ -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/issue-2734.rs
浏览文件 @
b7e72974
...
...
@@ -12,7 +12,7 @@ trait hax { }
impl
<
A
>
hax
for
A
{
}
fn
perform_hax
<
T
:
&
static
>
(
x
:
@
T
)
->
hax
{
x
as
hax
@
x
as
@
hax
}
fn
deadcode
()
{
...
...
src/test/run-pass/issue-2735.rs
浏览文件 @
b7e72974
...
...
@@ -8,11 +8,11 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
trait
hax
{
}
impl
<
A
>
hax
for
A
{
}
trait
hax
{
}
impl
<
A
>
hax
for
A
{
}
fn
perform_hax
<
T
:
&
static
>
(
x
:
@
T
)
->
hax
{
x
as
hax
@
x
as
@
hax
}
fn
deadcode
()
{
...
...
src/test/run-pass/issue-2904.rs
浏览文件 @
b7e72974
...
...
@@ -60,7 +60,7 @@ fn square_from_char(c: char) -> square {
}
fn
read_board_grid
<
rdr
:
&
static
+
io
::
Reader
>
(
+
in
:
rdr
)
->
~
[
~
[
square
]]
{
let
in
=
(
in
)
as
io
::
Reader
;
let
in
=
@
in
as
@
io
::
Reader
;
let
mut
grid
=
~
[];
for
in
.each_line
|
line
|
{
let
mut
row
=
~
[];
...
...
src/test/run-pass/issue-2935.rs
浏览文件 @
b7e72974
...
...
@@ -25,7 +25,7 @@ pub fn main() {
// let y = @({a: 4i});
// let z = @({a: 4i} as it);
// let z = @({a: true} as it);
let
z
=
@
(
true
as
it
);
let
z
=
@
(
@
true
as
it
);
// x.f();
// y.f();
// (*z).f();
...
...
src/test/run-pass/issue-3305.rs
浏览文件 @
b7e72974
...
...
@@ -21,6 +21,6 @@ fn is_equal<D:double>(x: @D, exp: uint) {
}
pub
fn
main
()
{
let
x
=
@
(
3u
as
double
);
let
x
=
@
(
@
3u
as
@
double
);
is_equal
(
x
,
6
);
}
src/test/run-pass/kindck-owned-trait-contains-1.rs
浏览文件 @
b7e72974
...
...
@@ -16,7 +16,7 @@ fn get() -> 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/reflect-visit-data.rs
浏览文件 @
b7e72974
...
...
@@ -489,7 +489,7 @@ fn visit_inner(inner: *TyDesc) -> bool {
unsafe
{
let
u
=
my_visitor
(
*
self
);
let
v
=
ptr_visit_adaptor
::
<
my_visitor
>
(
Inner
{
inner
:
u
});
visit_tydesc
(
inner
,
v
as
TyVisitor
);
visit_tydesc
(
inner
,
@
v
as
@
TyVisitor
);
true
}
}
...
...
@@ -644,7 +644,7 @@ pub fn main() {
let
td
=
get_tydesc_for
(
r
);
unsafe
{
error!
(
"tydesc sz: %u, align: %u"
,
(
*
td
)
.size
,
(
*
td
)
.align
);
}
let
v
=
v
as
TyVisitor
;
let
v
=
@
v
as
@
TyVisitor
;
visit_tydesc
(
td
,
v
);
for
(
copy
u
.vals
)
.each
|
s
|
{
...
...
src/test/run-pass/regions-trait.rs
浏览文件 @
b7e72974
...
...
@@ -30,5 +30,5 @@ pub fn main() {
let
ctxt
=
Ctxt
{
v
:
22
};
let
hc
=
HasCtxt
{
c
:
&
ctxt
};
assert
get_v
(
hc
as
get_ctxt
)
==
22
;
assert
get_v
(
@
hc
as
@
get_ctxt
)
==
22
;
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录