Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
25787bd2
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,发现更多精彩内容 >>
提交
25787bd2
编写于
9月 15, 2011
作者:
M
Marijn Haverbeke
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Forbid assignment to by-reference bindings
Issue #918
上级
d7a1d6a1
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
25 addition
and
21 deletion
+25
-21
src/comp/middle/alias.rs
src/comp/middle/alias.rs
+2
-2
src/comp/middle/mut.rs
src/comp/middle/mut.rs
+1
-0
src/comp/middle/resolve.rs
src/comp/middle/resolve.rs
+6
-4
src/comp/middle/trans.rs
src/comp/middle/trans.rs
+2
-2
src/comp/middle/tstate/auxiliary.rs
src/comp/middle/tstate/auxiliary.rs
+5
-4
src/comp/middle/tstate/bitvectors.rs
src/comp/middle/tstate/bitvectors.rs
+1
-1
src/comp/middle/tstate/pre_post_conditions.rs
src/comp/middle/tstate/pre_post_conditions.rs
+3
-3
src/comp/middle/tstate/states.rs
src/comp/middle/tstate/states.rs
+1
-1
src/comp/middle/ty.rs
src/comp/middle/ty.rs
+1
-1
src/comp/middle/typeck.rs
src/comp/middle/typeck.rs
+1
-1
src/comp/syntax/ast.rs
src/comp/syntax/ast.rs
+1
-1
src/comp/syntax/ast_util.rs
src/comp/syntax/ast_util.rs
+1
-1
未找到文件。
src/comp/middle/alias.rs
浏览文件 @
25787bd2
...
...
@@ -324,7 +324,7 @@ fn check_ret_ref(cx: ctx, sc: scope, mut: bool, expr: @ast::expr) {
let
mut_field
=
mut_field
(
root
.ds
);
alt
path_def
(
cx
,
root
.ex
)
{
none
.
{
bad
=
some
(
"temporary"
);
}
some
(
ast
::
def_local
(
did
))
|
some
(
ast
::
def_binding
(
did
))
|
some
(
ast
::
def_local
(
did
,
_
))
|
some
(
ast
::
def_binding
(
did
))
|
some
(
ast
::
def_arg
(
did
,
_
))
{
let
cur_node
=
did
.node
;
while
true
{
...
...
@@ -590,7 +590,7 @@ fn helper(tcx: ty::ctxt, needle: ty::t, haystack: ty::t, mut: bool) ->
fn
def_is_local
(
d
:
ast
::
def
,
objfields_count
:
bool
)
->
bool
{
ret
alt
d
{
ast
::
def_local
(
_
)
|
ast
::
def_arg
(
_
,
_
)
|
ast
::
def_binding
(
_
)
|
ast
::
def_local
(
_
,
_
)
|
ast
::
def_arg
(
_
,
_
)
|
ast
::
def_binding
(
_
)
|
ast
::
def_upvar
(
_
,
_
,
_
)
{
true
}
...
...
src/comp/middle/mut.rs
浏览文件 @
25787bd2
...
...
@@ -245,6 +245,7 @@ fn is_immutable_def(def: def) -> option::t<str> {
if
!
mut
{
some
(
"upvar"
)
}
else
{
is_immutable_def
(
*
inner
)
}
}
def_binding
(
_
)
{
some
(
"binding"
)
}
def_local
(
_
,
let_ref
.
)
{
some
(
"by-reference binding"
)
}
_
{
none
}
}
}
...
...
src/comp/middle/resolve.rs
浏览文件 @
25787bd2
...
...
@@ -608,7 +608,7 @@ fn scope_closes(sc: scope) -> option::t<bool> {
fn
def_is_local
(
d
:
def
)
->
bool
{
ret
alt
d
{
ast
::
def_arg
(
_
,
_
)
|
ast
::
def_local
(
_
)
|
ast
::
def_binding
(
_
)
|
ast
::
def_arg
(
_
,
_
)
|
ast
::
def_local
(
_
,
_
)
|
ast
::
def_binding
(
_
)
|
ast
::
def_upvar
(
_
,
_
,
_
)
{
true
}
...
...
@@ -797,10 +797,12 @@ fn lookup_in_block(name: ident, b: ast::blk_, pos: uint, loc_pos: uint,
let
j
=
vec
::
len
(
locs
);
while
j
>
0u
{
j
-=
1u
;
let
(
_
,
loc
)
=
locs
[
j
];
let
(
style
,
loc
)
=
locs
[
j
];
if
ns
==
ns_value
&&
(
i
<
pos
||
j
<
loc_pos
)
{
alt
lookup_in_pat
(
name
,
loc
.node.pat
)
{
some
(
did
)
{
ret
some
(
ast
::
def_local
(
did
));
}
some
(
did
)
{
ret
some
(
ast
::
def_local
(
did
,
style
));
}
_
{
}
}
}
...
...
@@ -1154,7 +1156,7 @@ fn ns_for_def(d: def) -> namespace {
ast
::
def_native_mod
(
_
)
{
ns_module
}
ast
::
def_const
(
_
)
{
ns_value
}
ast
::
def_arg
(
_
,
_
)
{
ns_value
}
ast
::
def_local
(
_
)
{
ns_value
}
ast
::
def_local
(
_
,
_
)
{
ns_value
}
ast
::
def_upvar
(
_
,
_
,
_
)
{
ns_value
}
ast
::
def_variant
(
_
,
_
)
{
ns_value
}
ast
::
def_ty
(
_
)
{
ns_type
}
...
...
src/comp/middle/trans.rs
浏览文件 @
25787bd2
...
...
@@ -2871,7 +2871,7 @@ fn trans_local_var(cx: @block_ctxt, def: ast::def) -> lval_result {
assert
(
cx
.fcx.llargs
.contains_key
(
did
.node
));
ret
lval_mem
(
cx
,
cx
.fcx.llargs
.get
(
did
.node
));
}
ast
::
def_local
(
did
)
{
ast
::
def_local
(
did
,
_
)
{
assert
(
cx
.fcx.lllocals
.contains_key
(
did
.node
));
ret
lval_mem
(
cx
,
cx
.fcx.lllocals
.get
(
did
.node
));
}
...
...
@@ -4399,7 +4399,7 @@ fn trans_ret(cx: @block_ctxt, e: option::t<@ast::expr>) -> result {
let
is_local
=
alt
x
.node
{
ast
::
expr_path
(
p
)
{
alt
bcx_tcx
(
bcx
)
.def_map
.get
(
x
.id
)
{
ast
::
def_local
(
_
)
{
true
}
ast
::
def_local
(
_
,
_
)
{
true
}
_
{
false
}
}
}
...
...
src/comp/middle/tstate/auxiliary.rs
浏览文件 @
25787bd2
...
...
@@ -575,8 +575,8 @@ fn expr_to_constr_arg(tcx: ty::ctxt, e: @expr) -> @constr_arg_use {
alt
e
.node
{
expr_path
(
p
)
{
alt
tcx
.def_map
.find
(
e
.id
)
{
some
(
def_local
(
id
))
|
some
(
def_arg
(
id
,
_
))
|
some
(
def_binding
(
id
))
|
some
(
def_upvar
(
id
,
_
,
_
))
{
some
(
def_local
(
id
,
_
))
|
some
(
def_arg
(
id
,
_
))
|
some
(
def_
binding
(
id
))
|
some
(
def_
upvar
(
id
,
_
,
_
))
{
ret
@
respan
(
p
.span
,
carg_ident
({
ident
:
p
.node.idents
[
0
],
node
:
id
.node
}));
}
...
...
@@ -790,7 +790,8 @@ fn path_to_ident(cx: ty::ctxt, p: path) -> ident {
fn
local_node_id_to_def_id_strict
(
fcx
:
fn_ctxt
,
sp
:
span
,
i
:
node_id
)
->
def_id
{
alt
local_node_id_to_def
(
fcx
,
i
)
{
some
(
def_local
(
id
))
|
some
(
def_arg
(
id
,
_
))
|
some
(
def_upvar
(
id
,
_
,
_
))
{
some
(
def_local
(
id
,
_
))
|
some
(
def_arg
(
id
,
_
))
|
some
(
def_upvar
(
id
,
_
,
_
))
{
ret
id
;
}
some
(
_
)
{
...
...
@@ -813,7 +814,7 @@ fn local_node_id_to_def(fcx: fn_ctxt, i: node_id) -> option::t<def> {
fn
local_node_id_to_def_id
(
fcx
:
fn_ctxt
,
i
:
node_id
)
->
option
::
t
<
def_id
>
{
alt
local_node_id_to_def
(
fcx
,
i
)
{
some
(
def_local
(
id
))
|
some
(
def_arg
(
id
,
_
))
|
some
(
def_binding
(
id
))
|
some
(
def_local
(
id
,
_
))
|
some
(
def_arg
(
id
,
_
))
|
some
(
def_binding
(
id
))
|
some
(
def_upvar
(
id
,
_
,
_
))
{
some
(
id
)
}
...
...
src/comp/middle/tstate/bitvectors.rs
浏览文件 @
25787bd2
...
...
@@ -184,7 +184,7 @@ fn clear_in_poststate_expr(fcx: fn_ctxt, e: @expr, t: poststate) {
alt
vec
::
last
(
p
.node.idents
)
{
some
(
i
)
{
alt
local_node_id_to_def
(
fcx
,
e
.id
)
{
some
(
def_local
(
d_id
))
{
some
(
def_local
(
d_id
,
_
))
{
clear_in_poststate_
(
bit_num
(
fcx
,
ninit
(
d_id
.node
,
i
)),
t
);
}
some
(
_
)
{
/* ignore args (for now...) */
}
...
...
src/comp/middle/tstate/pre_post_conditions.rs
浏览文件 @
25787bd2
...
...
@@ -197,7 +197,7 @@ fn gen_if_local(fcx: fn_ctxt, lhs: @expr, rhs: @expr, larger_id: node_id,
alt
node_id_to_def
(
fcx
.ccx
,
new_var
)
{
some
(
d
)
{
alt
d
{
def_local
(
d_id
)
{
def_local
(
d_id
,
_
)
{
find_pre_post_expr
(
fcx
,
rhs
);
let
p
=
expr_pp
(
fcx
.ccx
,
rhs
);
set_pre_and_post
(
fcx
.ccx
,
larger_id
,
p
.precondition
,
...
...
@@ -235,7 +235,7 @@ fn handle_update(fcx: fn_ctxt, parent: @expr, lhs: @expr, rhs: @expr,
// pure and assign_op require the lhs to be init'd
let
df
=
node_id_to_def_strict
(
fcx
.ccx.tcx
,
lhs
.id
);
alt
df
{
def_local
(
d_id
)
{
def_local
(
d_id
,
_
)
{
let
i
=
bit_num
(
fcx
,
ninit
(
d_id
.node
,
path_to_ident
(
fcx
.ccx.tcx
,
p
)));
...
...
@@ -281,7 +281,7 @@ fn handle_var(fcx: fn_ctxt, rslt: pre_and_post, id: node_id, name: ident) {
fn
handle_var_def
(
fcx
:
fn_ctxt
,
rslt
:
pre_and_post
,
def
:
def
,
name
:
ident
)
{
alt
def
{
def_local
(
d_id
)
|
def_arg
(
d_id
,
_
)
{
def_local
(
d_id
,
_
)
|
def_arg
(
d_id
,
_
)
{
use_var
(
fcx
,
d_id
.node
);
let
i
=
bit_num
(
fcx
,
ninit
(
d_id
.node
,
name
));
require_and_preserve
(
i
,
rslt
);
...
...
src/comp/middle/tstate/states.rs
浏览文件 @
25787bd2
...
...
@@ -232,7 +232,7 @@ fn gen_if_local(fcx: fn_ctxt, p: poststate, e: @expr) -> bool {
alt
e
.node
{
expr_path
(
pth
)
{
alt
fcx
.ccx.tcx.def_map
.find
(
e
.id
)
{
some
(
def_local
(
loc
))
{
some
(
def_local
(
loc
,
_
))
{
ret
set_in_poststate_ident
(
fcx
,
loc
.node
,
path_to_ident
(
fcx
.ccx.tcx
,
pth
),
p
);
}
...
...
src/comp/middle/ty.rs
浏览文件 @
25787bd2
...
...
@@ -2559,7 +2559,7 @@ fn def_has_ty_params(def: ast::def) -> bool {
ast
::
def_mod
(
_
)
{
ret
false
;
}
ast
::
def_const
(
_
)
{
ret
false
;
}
ast
::
def_arg
(
_
,
_
)
{
ret
false
;
}
ast
::
def_local
(
_
)
{
ret
false
;
}
ast
::
def_local
(
_
,
_
)
{
ret
false
;
}
ast
::
def_upvar
(
_
,
_
,
_
)
{
ret
false
;
}
ast
::
def_variant
(
_
,
_
)
{
ret
true
;
}
ast
::
def_ty
(
_
)
{
ret
false
;
}
...
...
src/comp/middle/typeck.rs
浏览文件 @
25787bd2
...
...
@@ -92,7 +92,7 @@ fn ty_param_kinds_and_ty_for_def(fcx: @fn_ctxt, sp: span, defn: ast::def) ->
let
typ
=
ty
::
mk_var
(
fcx
.ccx.tcx
,
lookup_local
(
fcx
,
sp
,
id
.node
));
ret
{
kinds
:
no_kinds
,
ty
:
typ
};
}
ast
::
def_local
(
id
)
{
ast
::
def_local
(
id
,
_
)
{
assert
(
fcx
.locals
.contains_key
(
id
.node
));
let
typ
=
ty
::
mk_var
(
fcx
.ccx.tcx
,
lookup_local
(
fcx
,
sp
,
id
.node
));
ret
{
kinds
:
no_kinds
,
ty
:
typ
};
...
...
src/comp/syntax/ast.rs
浏览文件 @
25787bd2
...
...
@@ -32,7 +32,7 @@
def_native_mod
(
def_id
);
def_const
(
def_id
);
def_arg
(
def_id
,
mode
);
def_local
(
def_id
);
def_local
(
def_id
,
let_style
);
def_variant
(
def_id
,
/* tag */
def_id
);
/* variant */
...
...
src/comp/syntax/ast_util.rs
浏览文件 @
25787bd2
...
...
@@ -30,7 +30,7 @@ fn def_id_of_def(d: def) -> def_id {
def_native_mod
(
id
)
{
ret
id
;
}
def_const
(
id
)
{
ret
id
;
}
def_arg
(
id
,
_
)
{
ret
id
;
}
def_local
(
id
)
{
ret
id
;
}
def_local
(
id
,
_
)
{
ret
id
;
}
def_variant
(
_
,
id
)
{
ret
id
;
}
def_ty
(
id
)
{
ret
id
;
}
def_ty_arg
(
_
,
_
)
{
fail
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录