Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
6fe6a6f9
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,发现更多精彩内容 >>
提交
6fe6a6f9
编写于
11月 25, 2013
作者:
B
bors
浏览文件
操作
浏览文件
下载
差异文件
auto merge of #10657 : sanxiyn/rust/pat, r=cmr
上级
679a2c04
9028330f
变更
14
隐藏空白更改
内联
并排
Showing
14 changed file
with
26 addition
and
49 deletion
+26
-49
src/librustc/middle/borrowck/check_loans.rs
src/librustc/middle/borrowck/check_loans.rs
+2
-2
src/librustc/middle/borrowck/gather_loans/mod.rs
src/librustc/middle/borrowck/gather_loans/mod.rs
+2
-2
src/librustc/middle/check_const.rs
src/librustc/middle/check_const.rs
+2
-2
src/librustc/middle/lint.rs
src/librustc/middle/lint.rs
+2
-2
src/librustc/middle/moves.rs
src/librustc/middle/moves.rs
+0
-23
src/librustc/middle/pat_util.rs
src/librustc/middle/pat_util.rs
+6
-6
src/librustc/middle/privacy.rs
src/librustc/middle/privacy.rs
+1
-1
src/librustc/middle/region.rs
src/librustc/middle/region.rs
+2
-2
src/librustc/middle/typeck/check/mod.rs
src/librustc/middle/typeck/check/mod.rs
+1
-1
src/librustc/middle/typeck/check/writeback.rs
src/librustc/middle/typeck/check/writeback.rs
+2
-2
src/libsyntax/ast_map.rs
src/libsyntax/ast_map.rs
+2
-2
src/libsyntax/ast_util.rs
src/libsyntax/ast_util.rs
+2
-2
src/libsyntax/ext/expand.rs
src/libsyntax/ext/expand.rs
+1
-1
src/libsyntax/visit.rs
src/libsyntax/visit.rs
+1
-1
未找到文件。
src/librustc/middle/borrowck/check_loans.rs
浏览文件 @
6fe6a6f9
...
...
@@ -51,7 +51,7 @@ fn visit_local(&mut self, l:@ast::Local, _:()) {
fn
visit_block
(
&
mut
self
,
b
:
&
ast
::
Block
,
_
:())
{
check_loans_in_block
(
self
,
b
);
}
fn
visit_pat
(
&
mut
self
,
p
:
@
ast
::
Pat
,
_
:())
{
fn
visit_pat
(
&
mut
self
,
p
:
&
ast
::
Pat
,
_
:())
{
check_loans_in_pat
(
self
,
p
);
}
fn
visit_fn
(
&
mut
self
,
fk
:
&
visit
::
fn_kind
,
fd
:
&
ast
::
fn_decl
,
...
...
@@ -847,7 +847,7 @@ fn check_loans_in_expr<'a>(this: &mut CheckLoanCtxt<'a>,
}
fn
check_loans_in_pat
<
'a
>
(
this
:
&
mut
CheckLoanCtxt
<
'a
>
,
pat
:
@
ast
::
Pat
)
pat
:
&
ast
::
Pat
)
{
this
.check_for_conflicting_loans
(
pat
.id
);
this
.check_move_out_from_id
(
pat
.id
,
pat
.span
);
...
...
src/librustc/middle/borrowck/gather_loans/mod.rs
浏览文件 @
6fe6a6f9
...
...
@@ -87,7 +87,7 @@ fn visit_fn(&mut self, fk:&fn_kind, fd:&fn_decl, b:&Block,
fn
visit_stmt
(
&
mut
self
,
s
:
@
Stmt
,
_
:())
{
add_stmt_to_map
(
self
,
s
);
}
fn
visit_pat
(
&
mut
self
,
p
:
@
Pat
,
_
:())
{
fn
visit_pat
(
&
mut
self
,
p
:
&
Pat
,
_
:())
{
add_pat_to_id_range
(
self
,
p
);
}
fn
visit_local
(
&
mut
self
,
l
:
@
Local
,
_
:())
{
...
...
@@ -119,7 +119,7 @@ pub fn gather_loans(bccx: &BorrowckCtxt,
}
fn
add_pat_to_id_range
(
this
:
&
mut
GatherLoanCtxt
,
p
:
@
ast
::
Pat
)
{
p
:
&
ast
::
Pat
)
{
// NB: This visitor function just adds the pat ids into the id
// range. We gather loans that occur in patterns using the
// `gather_pat()` method below. Eventually these two should be
...
...
src/librustc/middle/check_const.rs
浏览文件 @
6fe6a6f9
...
...
@@ -33,7 +33,7 @@ impl Visitor<bool> for CheckCrateVisitor {
fn
visit_item
(
&
mut
self
,
i
:
@
item
,
env
:
bool
)
{
check_item
(
self
,
self
.sess
,
self
.ast_map
,
self
.def_map
,
i
,
env
);
}
fn
visit_pat
(
&
mut
self
,
p
:
@
Pat
,
env
:
bool
)
{
fn
visit_pat
(
&
mut
self
,
p
:
&
Pat
,
env
:
bool
)
{
check_pat
(
self
,
p
,
env
);
}
fn
visit_expr
(
&
mut
self
,
ex
:
@
Expr
,
env
:
bool
)
{
...
...
@@ -81,7 +81,7 @@ pub fn check_item(v: &mut CheckCrateVisitor,
}
}
pub
fn
check_pat
(
v
:
&
mut
CheckCrateVisitor
,
p
:
@
Pat
,
_
is_const
:
bool
)
{
pub
fn
check_pat
(
v
:
&
mut
CheckCrateVisitor
,
p
:
&
Pat
,
_
is_const
:
bool
)
{
fn
is_str
(
e
:
@
Expr
)
->
bool
{
match
e
.node
{
ExprVstore
(
...
...
src/librustc/middle/lint.rs
浏览文件 @
6fe6a6f9
...
...
@@ -900,7 +900,7 @@ fn check_unsafe_block(cx: &Context, e: &ast::Expr) {
}
}
fn
check_unused_mut_pat
(
cx
:
&
Context
,
p
:
@
ast
::
Pat
)
{
fn
check_unused_mut_pat
(
cx
:
&
Context
,
p
:
&
ast
::
Pat
)
{
match
p
.node
{
ast
::
PatIdent
(
ast
::
BindByValue
(
ast
::
MutMutable
),
ref
path
,
_
)
if
pat_util
::
pat_is_binding
(
cx
.tcx.def_map
,
p
)
=>
{
...
...
@@ -1119,7 +1119,7 @@ fn visit_item(&mut self, it: @ast::item, _: ()) {
}
}
fn
visit_pat
(
&
mut
self
,
p
:
@
ast
::
Pat
,
_
:
())
{
fn
visit_pat
(
&
mut
self
,
p
:
&
ast
::
Pat
,
_
:
())
{
check_pat_non_uppercase_statics
(
self
,
p
);
check_unused_mut_pat
(
self
,
p
);
...
...
src/librustc/middle/moves.rs
浏览文件 @
6fe6a6f9
...
...
@@ -459,8 +459,6 @@ fn has_dtor(tcx: ty::ctxt, ty: ty::t) -> bool {
}
ExprMatch
(
discr
,
ref
arms
)
=>
{
// We must do this first so that `arms_have_by_move_bindings`
// below knows which bindings are moves.
for
arm
in
arms
.iter
()
{
self
.consume_arm
(
arm
);
}
...
...
@@ -657,27 +655,6 @@ pub fn use_fn_arg(&mut self, arg_expr: @Expr) {
self
.consume_expr
(
arg_expr
)
}
pub
fn
arms_have_by_move_bindings
(
&
mut
self
,
moves_map
:
MovesMap
,
arms
:
&
[
Arm
])
->
Option
<@
Pat
>
{
let
mut
ret
=
None
;
for
arm
in
arms
.iter
()
{
for
&
pat
in
arm
.pats
.iter
()
{
let
cont
=
do
ast_util
::
walk_pat
(
pat
)
|
p
|
{
if
moves_map
.contains
(
&
p
.id
)
{
ret
=
Some
(
p
);
false
}
else
{
true
}
};
if
!
cont
{
return
ret
}
}
}
ret
}
pub
fn
compute_captures
(
&
mut
self
,
fn_expr_id
:
NodeId
)
->
@
[
CaptureVar
]
{
debug!
(
"compute_capture_vars(fn_expr_id={:?})"
,
fn_expr_id
);
let
_
indenter
=
indenter
();
...
...
src/librustc/middle/pat_util.rs
浏览文件 @
6fe6a6f9
...
...
@@ -20,7 +20,7 @@
// This is used because same-named variables in alternative patterns need to
// use the NodeId of their namesake in the first pattern.
pub
fn
pat_id_map
(
dm
:
resolve
::
DefMap
,
pat
:
@
Pat
)
->
PatIdMap
{
pub
fn
pat_id_map
(
dm
:
resolve
::
DefMap
,
pat
:
&
Pat
)
->
PatIdMap
{
let
mut
map
=
HashMap
::
new
();
do
pat_bindings
(
dm
,
pat
)
|
_
bm
,
p_id
,
_
s
,
n
|
{
map
.insert
(
path_to_ident
(
n
),
p_id
);
...
...
@@ -52,7 +52,7 @@ pub fn pat_is_const(dm: resolve::DefMap, pat: &Pat) -> bool {
}
}
pub
fn
pat_is_binding
(
dm
:
resolve
::
DefMap
,
pat
:
@
Pat
)
->
bool
{
pub
fn
pat_is_binding
(
dm
:
resolve
::
DefMap
,
pat
:
&
Pat
)
->
bool
{
match
pat
.node
{
PatIdent
(
*
)
=>
{
!
pat_is_variant_or_struct
(
dm
,
pat
)
&&
...
...
@@ -62,7 +62,7 @@ pub fn pat_is_binding(dm: resolve::DefMap, pat: @Pat) -> bool {
}
}
pub
fn
pat_is_binding_or_wild
(
dm
:
resolve
::
DefMap
,
pat
:
@
Pat
)
->
bool
{
pub
fn
pat_is_binding_or_wild
(
dm
:
resolve
::
DefMap
,
pat
:
&
Pat
)
->
bool
{
match
pat
.node
{
PatIdent
(
*
)
=>
pat_is_binding
(
dm
,
pat
),
PatWild
|
PatWildMulti
=>
true
,
...
...
@@ -73,7 +73,7 @@ pub fn pat_is_binding_or_wild(dm: resolve::DefMap, pat: @Pat) -> bool {
/// Call `it` on every "binding" in a pattern, e.g., on `a` in
/// `match foo() { Some(a) => (), None => () }`
pub
fn
pat_bindings
(
dm
:
resolve
::
DefMap
,
pat
:
@
Pat
,
pat
:
&
Pat
,
it
:
|
BindingMode
,
NodeId
,
Span
,
&
Path
|)
{
do
walk_pat
(
pat
)
|
p
|
{
match
p
.node
{
...
...
@@ -86,7 +86,7 @@ pub fn pat_bindings(dm: resolve::DefMap,
};
}
pub
fn
pat_binding_ids
(
dm
:
resolve
::
DefMap
,
pat
:
@
Pat
)
->
~
[
NodeId
]
{
pub
fn
pat_binding_ids
(
dm
:
resolve
::
DefMap
,
pat
:
&
Pat
)
->
~
[
NodeId
]
{
let
mut
found
=
~
[];
pat_bindings
(
dm
,
pat
,
|
_
bm
,
b_id
,
_
sp
,
_
pt
|
found
.push
(
b_id
)
);
return
found
;
...
...
@@ -94,7 +94,7 @@ pub fn pat_binding_ids(dm: resolve::DefMap, pat: @Pat) -> ~[NodeId] {
/// Checks if the pattern contains any patterns that bind something to
/// an ident, e.g. `foo`, or `Foo(foo)` or `foo @ Bar(*)`.
pub
fn
pat_contains_bindings
(
dm
:
resolve
::
DefMap
,
pat
:
@
Pat
)
->
bool
{
pub
fn
pat_contains_bindings
(
dm
:
resolve
::
DefMap
,
pat
:
&
Pat
)
->
bool
{
let
mut
contains_bindings
=
false
;
do
walk_pat
(
pat
)
|
p
|
{
if
pat_is_binding
(
dm
,
p
)
{
...
...
src/librustc/middle/privacy.rs
浏览文件 @
6fe6a6f9
...
...
@@ -739,7 +739,7 @@ fn visit_view_item(&mut self, a: &ast::view_item, _: ()) {
}
}
fn
visit_pat
(
&
mut
self
,
pattern
:
@
ast
::
Pat
,
_
:
())
{
fn
visit_pat
(
&
mut
self
,
pattern
:
&
ast
::
Pat
,
_
:
())
{
match
pattern
.node
{
ast
::
PatStruct
(
_
,
ref
fields
,
_
)
=>
{
match
ty
::
get
(
ty
::
pat_ty
(
self
.tcx
,
pattern
))
.sty
{
...
...
src/librustc/middle/region.rs
浏览文件 @
6fe6a6f9
...
...
@@ -340,7 +340,7 @@ fn resolve_arm(visitor: &mut RegionResolutionVisitor,
}
fn
resolve_pat
(
visitor
:
&
mut
RegionResolutionVisitor
,
pat
:
@
ast
::
Pat
,
pat
:
&
ast
::
Pat
,
cx
:
Context
)
{
assert_eq!
(
cx
.var_parent
,
cx
.parent
);
parent_to_expr
(
visitor
,
cx
,
pat
.id
,
pat
.span
);
...
...
@@ -480,7 +480,7 @@ fn visit_fn(&mut self, fk:&fn_kind, fd:&fn_decl, b:&Block, s:Span, n:NodeId, cx:
fn
visit_arm
(
&
mut
self
,
a
:
&
Arm
,
cx
:
Context
)
{
resolve_arm
(
self
,
a
,
cx
);
}
fn
visit_pat
(
&
mut
self
,
p
:
@
Pat
,
cx
:
Context
)
{
fn
visit_pat
(
&
mut
self
,
p
:
&
Pat
,
cx
:
Context
)
{
resolve_pat
(
self
,
p
,
cx
);
}
fn
visit_stmt
(
&
mut
self
,
s
:
@
Stmt
,
cx
:
Context
)
{
...
...
src/librustc/middle/typeck/check/mod.rs
浏览文件 @
6fe6a6f9
...
...
@@ -375,7 +375,7 @@ fn visit_local(&mut self, local:@ast::Local, _:()) {
}
// Add pattern bindings.
fn
visit_pat
(
&
mut
self
,
p
:
@
ast
::
Pat
,
_
:())
{
fn
visit_pat
(
&
mut
self
,
p
:
&
ast
::
Pat
,
_
:())
{
match
p
.node
{
ast
::
PatIdent
(
_
,
ref
path
,
_
)
if
pat_util
::
pat_is_binding
(
self
.fcx.ccx.tcx.def_map
,
p
)
=>
{
...
...
src/librustc/middle/typeck/check/writeback.rs
浏览文件 @
6fe6a6f9
...
...
@@ -278,7 +278,7 @@ fn visit_block(b: &ast::Block, wbcx: &mut WbCtxt) {
visit
::
walk_block
(
wbcx
,
b
,
());
}
fn
visit_pat
(
p
:
@
ast
::
Pat
,
wbcx
:
&
mut
WbCtxt
)
{
fn
visit_pat
(
p
:
&
ast
::
Pat
,
wbcx
:
&
mut
WbCtxt
)
{
if
!
wbcx
.success
{
return
;
}
...
...
@@ -323,7 +323,7 @@ impl Visitor<()> for WbCtxt {
fn
visit_stmt
(
&
mut
self
,
s
:
@
ast
::
Stmt
,
_
:())
{
visit_stmt
(
s
,
self
);
}
fn
visit_expr
(
&
mut
self
,
ex
:
@
ast
::
Expr
,
_
:())
{
visit_expr
(
ex
,
self
);
}
fn
visit_block
(
&
mut
self
,
b
:
&
ast
::
Block
,
_
:())
{
visit_block
(
b
,
self
);
}
fn
visit_pat
(
&
mut
self
,
p
:
@
ast
::
Pat
,
_
:())
{
visit_pat
(
p
,
self
);
}
fn
visit_pat
(
&
mut
self
,
p
:
&
ast
::
Pat
,
_
:())
{
visit_pat
(
p
,
self
);
}
fn
visit_local
(
&
mut
self
,
l
:
@
ast
::
Local
,
_
:())
{
visit_local
(
l
,
self
);
}
}
...
...
src/libsyntax/ast_map.rs
浏览文件 @
6fe6a6f9
...
...
@@ -242,7 +242,7 @@ fn map_block(&mut self, b: &Block) {
visit
::
walk_block
(
self
,
b
,
());
}
fn
map_pat
(
&
mut
self
,
pat
:
@
Pat
)
{
fn
map_pat
(
&
mut
self
,
pat
:
&
Pat
)
{
match
pat
.node
{
PatIdent
(
_
,
ref
path
,
_
)
=>
{
// Note: this is at least *potentially* a pattern...
...
...
@@ -345,7 +345,7 @@ fn visit_item(&mut self, i: @item, _: ()) {
self
.path
.pop
();
}
fn
visit_pat
(
&
mut
self
,
pat
:
@
Pat
,
_
:
())
{
fn
visit_pat
(
&
mut
self
,
pat
:
&
Pat
,
_
:
())
{
self
.map_pat
(
pat
);
visit
::
walk_pat
(
self
,
pat
,
())
}
...
...
src/libsyntax/ast_util.rs
浏览文件 @
6fe6a6f9
...
...
@@ -497,7 +497,7 @@ fn visit_stmt(&mut self, statement: @Stmt, env: ()) {
visit
::
walk_stmt
(
self
,
statement
,
env
)
}
fn
visit_pat
(
&
mut
self
,
pattern
:
@
Pat
,
env
:
())
{
fn
visit_pat
(
&
mut
self
,
pattern
:
&
Pat
,
env
:
())
{
self
.operation
.visit_id
(
pattern
.id
);
visit
::
walk_pat
(
self
,
pattern
,
env
)
}
...
...
@@ -636,7 +636,7 @@ pub fn is_item_impl(item: @ast::item) -> bool {
}
}
pub
fn
walk_pat
(
pat
:
@
Pat
,
it
:
|
@
Pat
|
->
bool
)
->
bool
{
pub
fn
walk_pat
(
pat
:
&
Pat
,
it
:
|
&
Pat
|
->
bool
)
->
bool
{
if
!
it
(
pat
)
{
return
false
;
}
...
...
src/libsyntax/ext/expand.rs
浏览文件 @
6fe6a6f9
...
...
@@ -612,7 +612,7 @@ struct NewNameFinderContext {
}
impl
Visitor
<
()
>
for
NewNameFinderContext
{
fn
visit_pat
(
&
mut
self
,
pattern
:
@
ast
::
Pat
,
_
:
())
{
fn
visit_pat
(
&
mut
self
,
pattern
:
&
ast
::
Pat
,
_
:
())
{
match
*
pattern
{
// we found a pat_ident!
ast
::
Pat
{
...
...
src/libsyntax/visit.rs
浏览文件 @
6fe6a6f9
...
...
@@ -78,7 +78,7 @@ fn visit_local(&mut self, l:@Local, e:E) { walk_local(self, l, e) }
fn
visit_block
(
&
mut
self
,
b
:
&
Block
,
e
:
E
)
{
walk_block
(
self
,
b
,
e
)
}
fn
visit_stmt
(
&
mut
self
,
s
:
@
Stmt
,
e
:
E
)
{
walk_stmt
(
self
,
s
,
e
)
}
fn
visit_arm
(
&
mut
self
,
a
:
&
Arm
,
e
:
E
)
{
walk_arm
(
self
,
a
,
e
)
}
fn
visit_pat
(
&
mut
self
,
p
:
@
Pat
,
e
:
E
)
{
walk_pat
(
self
,
p
,
e
)
}
fn
visit_pat
(
&
mut
self
,
p
:
&
Pat
,
e
:
E
)
{
walk_pat
(
self
,
p
,
e
)
}
fn
visit_decl
(
&
mut
self
,
d
:
@
Decl
,
e
:
E
)
{
walk_decl
(
self
,
d
,
e
)
}
fn
visit_expr
(
&
mut
self
,
ex
:
@
Expr
,
e
:
E
)
{
walk_expr
(
self
,
ex
,
e
)
}
fn
visit_expr_post
(
&
mut
self
,
_
ex
:
@
Expr
,
_
e
:
E
)
{
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录