Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
1c348e6e
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,发现更多精彩内容 >>
提交
1c348e6e
编写于
11月 21, 2012
作者:
P
Patrick Walton
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
librustc: Implement @mut [T] as the new replacement for @[mut T]
上级
7bc29c62
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
42 addition
and
12 deletion
+42
-12
src/librustc/middle/const_eval.rs
src/librustc/middle/const_eval.rs
+2
-1
src/librustc/middle/trans/expr.rs
src/librustc/middle/trans/expr.rs
+2
-1
src/librustc/middle/ty.rs
src/librustc/middle/ty.rs
+1
-0
src/librustc/middle/typeck/astconv.rs
src/librustc/middle/typeck/astconv.rs
+6
-5
src/librustc/middle/typeck/check.rs
src/librustc/middle/typeck/check.rs
+7
-2
src/libsyntax/ast.rs
src/libsyntax/ast.rs
+1
-0
src/libsyntax/parse/parser.rs
src/libsyntax/parse/parser.rs
+7
-3
src/libsyntax/print/pprust.rs
src/libsyntax/print/pprust.rs
+4
-0
src/test/compile-fail/borrowck-mut-boxed-vec.rs
src/test/compile-fail/borrowck-mut-boxed-vec.rs
+7
-0
src/test/run-pass/new-vstore-mut-box-syntax.rs
src/test/run-pass/new-vstore-mut-box-syntax.rs
+5
-0
未找到文件。
src/librustc/middle/const_eval.rs
浏览文件 @
1c348e6e
...
...
@@ -92,7 +92,8 @@ fn classify(e: @expr,
ast
::
expr_vstore_fixed
(
_
)
|
ast
::
expr_vstore_slice
=>
classify
(
e
,
def_map
,
tcx
),
ast
::
expr_vstore_uniq
|
ast
::
expr_vstore_box
=>
non_const
ast
::
expr_vstore_box
|
ast
::
expr_vstore_mut_box
=>
non_const
}
}
...
...
src/librustc/middle/trans/expr.rs
浏览文件 @
1c348e6e
...
...
@@ -392,7 +392,8 @@ fn trans_rvalue_datum_unadjusted(bcx: block, expr: @ast::expr) -> DatumBlock {
trace_span!
(
bcx
,
expr
.span
,
shorten
(
bcx
.expr_to_str
(
expr
)));
match
expr
.node
{
ast
::
expr_vstore
(
contents
,
ast
::
expr_vstore_box
)
=>
{
ast
::
expr_vstore
(
contents
,
ast
::
expr_vstore_box
)
|
ast
::
expr_vstore
(
contents
,
ast
::
expr_vstore_mut_box
)
=>
{
return
tvec
::
trans_uniq_or_managed_vstore
(
bcx
,
heap_shared
,
expr
,
contents
);
}
...
...
src/librustc/middle/ty.rs
浏览文件 @
1c348e6e
...
...
@@ -3187,6 +3187,7 @@ fn expr_kind(tcx: ctxt,
ast
::
expr_addr_of
(
*
)
|
ast
::
expr_binary
(
*
)
|
ast
::
expr_vstore
(
_
,
ast
::
expr_vstore_box
)
|
ast
::
expr_vstore
(
_
,
ast
::
expr_vstore_mut_box
)
|
ast
::
expr_vstore
(
_
,
ast
::
expr_vstore_uniq
)
=>
{
RvalueDatumExpr
}
...
...
src/librustc/middle/typeck/astconv.rs
浏览文件 @
1c348e6e
...
...
@@ -176,13 +176,14 @@ fn mk_pointer<AC: ast_conv, RS: region_scope Copy Owned>(
let
tcx
=
self
.tcx
();
match
a_seq_ty
.ty.node
{
// to convert to an e{vec,str}, there can't be a
// mutability argument
_
if
a_seq_ty
.mutbl
!=
ast
::
m_imm
=>
(),
ast
::
ty_vec
(
mt
)
=>
{
return
ty
::
mk_evec
(
tcx
,
ast_mt_to_mt
(
self
,
rscope
,
mt
),
vst
);
let
mut
mt
=
ast_mt_to_mt
(
self
,
rscope
,
mt
);
if
a_seq_ty
.mutbl
==
ast
::
m_mutbl
{
mt
=
{
ty
:
mt
.ty
,
mutbl
:
ast
::
m_mutbl
};
}
return
ty
::
mk_evec
(
tcx
,
mt
,
vst
);
}
ast
::
ty_path
(
path
,
id
)
=>
{
ast
::
ty_path
(
path
,
id
)
if
a_seq_ty
.mutbl
==
ast
::
m_imm
=>
{
match
tcx
.def_map
.find
(
id
)
{
Some
(
ast
::
def_prim_ty
(
ast
::
ty_str
))
=>
{
check_path_args
(
tcx
,
path
,
NO_TPS
|
NO_REGIONS
);
...
...
src/librustc/middle/typeck/check.rs
浏览文件 @
1c348e6e
...
...
@@ -1705,9 +1705,14 @@ fn check_struct_enum_variant(fcx: @fn_ctxt,
}
ast
::
expr_vec
(
args
,
mutbl
)
=>
{
let
tt
=
ast_expr_vstore_to_vstore
(
fcx
,
ev
,
args
.len
(),
vst
);
let
mutability
;
match
vst
{
ast
::
expr_vstore_mut_box
=>
mutability
=
ast
::
m_mutbl
,
_
=>
mutability
=
mutbl
}
let
t
:
ty
::
t
=
fcx
.infcx
()
.next_ty_var
();
for
args
.each
|
e
|
{
bot
|
=
check_expr_with
(
fcx
,
*
e
,
t
);
}
ty
::
mk_evec
(
tcx
,
{
ty
:
t
,
mutbl
:
mut
bl
},
tt
)
ty
::
mk_evec
(
tcx
,
{
ty
:
t
,
mutbl
:
mut
ability
},
tt
)
}
ast
::
expr_repeat
(
element
,
count_expr
,
mutbl
)
=>
{
let
count
=
ty
::
eval_repeat_count
(
tcx
,
count_expr
,
expr
.span
);
...
...
@@ -2721,7 +2726,7 @@ fn ast_expr_vstore_to_vstore(fcx: @fn_ctxt, e: @ast::expr, n: uint,
ty
::
vstore_fixed
(
u
)
}
ast
::
expr_vstore_uniq
=>
ty
::
vstore_uniq
,
ast
::
expr_vstore_box
=>
ty
::
vstore_box
,
ast
::
expr_vstore_box
|
ast
::
expr_vstore_mut_box
=>
ty
::
vstore_box
,
ast
::
expr_vstore_slice
=>
{
let
r
=
fcx
.infcx
()
.next_region_var
(
e
.span
,
e
.id
);
ty
::
vstore_slice
(
r
)
...
...
src/libsyntax/ast.rs
浏览文件 @
1c348e6e
...
...
@@ -645,6 +645,7 @@ enum expr_vstore {
expr_vstore_fixed
(
Option
<
uint
>
),
// [1,2,3,4]
expr_vstore_uniq
,
// ~[1,2,3,4]
expr_vstore_box
,
// @[1,2,3,4]
expr_vstore_mut_box
,
// @mut [1,2,3,4]
expr_vstore_slice
// &[1,2,3,4]
}
...
...
src/libsyntax/parse/parser.rs
浏览文件 @
1c348e6e
...
...
@@ -38,7 +38,8 @@
expr_lit
,
expr_log
,
expr_loop
,
expr_loop_body
,
expr_mac
,
expr_paren
,
expr_path
,
expr_rec
,
expr_repeat
,
expr_ret
,
expr_swap
,
expr_struct
,
expr_tup
,
expr_unary
,
expr_unary_move
,
expr_vec
,
expr_vstore
,
expr_while
,
extern_fn
,
field
,
fn_decl
,
expr_vec
,
expr_vstore
,
expr_vstore_mut_box
,
expr_while
,
extern_fn
,
field
,
fn_decl
,
foreign_item
,
foreign_item_const
,
foreign_item_fn
,
foreign_mod
,
ident
,
impure_fn
,
infer
,
inherited
,
item
,
item_
,
item_class
,
item_const
,
item_enum
,
item_fn
,
...
...
@@ -1450,8 +1451,11 @@ fn parse_prefix_expr() -> @expr {
hi
=
e
.span.hi
;
// HACK: turn @[...] into a @-evec
ex
=
match
e
.node
{
expr_vec
(
*
)
|
expr_lit
(
@
{
node
:
lit_str
(
_
),
span
:
_
})
if
m
==
m_imm
=>
expr_vstore
(
e
,
expr_vstore_box
),
expr_vec
(
*
)
if
m
==
m_mutbl
=>
expr_vstore
(
e
,
expr_vstore_mut_box
),
expr_vec
(
*
)
if
m
==
m_imm
=>
expr_vstore
(
e
,
expr_vstore_box
),
expr_lit
(
@
{
node
:
lit_str
(
_
),
span
:
_
})
if
m
==
m_imm
=>
expr_vstore
(
e
,
expr_vstore_box
),
_
=>
expr_unary
(
box
(
m
),
e
)
};
}
...
...
src/libsyntax/print/pprust.rs
浏览文件 @
1c348e6e
...
...
@@ -1027,6 +1027,10 @@ fn print_expr_vstore(s: ps, t: ast::expr_vstore) {
ast
::
expr_vstore_fixed
(
None
)
=>
word
(
s
.s
,
~
"_"
),
ast
::
expr_vstore_uniq
=>
word
(
s
.s
,
~
"~"
),
ast
::
expr_vstore_box
=>
word
(
s
.s
,
~
"@"
),
ast
::
expr_vstore_mut_box
=>
{
word
(
s
.s
,
~
"@"
);
word
(
s
.s
,
~
"mut"
);
}
ast
::
expr_vstore_slice
=>
word
(
s
.s
,
~
"&"
),
}
}
...
...
src/test/compile-fail/borrowck-mut-boxed-vec.rs
0 → 100644
浏览文件 @
1c348e6e
fn
main
()
{
let
v
=
@
mut
[
1
,
2
,
3
];
for
v
.each
|
_
x
|
{
//~ ERROR illegal borrow
v
[
1
]
=
4
;
}
}
src/test/run-pass/new-vstore-mut-box-syntax.rs
0 → 100644
浏览文件 @
1c348e6e
fn
main
()
{
let
x
:
@
mut
[
int
]
=
@
mut
[
1
,
2
,
3
];
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录