Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
3468b8d4
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,发现更多精彩内容 >>
提交
3468b8d4
编写于
10月 31, 2015
作者:
V
Vadim Petrochenkov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove PatWildMulti
上级
cc8d398e
变更
29
隐藏空白更改
内联
并排
Showing
29 changed file
with
47 addition
and
89 deletion
+47
-89
src/librustc/middle/cfg/construct.rs
src/librustc/middle/cfg/construct.rs
+1
-1
src/librustc/middle/check_const.rs
src/librustc/middle/check_const.rs
+1
-1
src/librustc/middle/check_match.rs
src/librustc/middle/check_match.rs
+6
-6
src/librustc/middle/dead.rs
src/librustc/middle/dead.rs
+1
-1
src/librustc/middle/expr_use_visitor.rs
src/librustc/middle/expr_use_visitor.rs
+1
-1
src/librustc/middle/mem_categorization.rs
src/librustc/middle/mem_categorization.rs
+1
-1
src/librustc/middle/pat_util.rs
src/librustc/middle/pat_util.rs
+1
-1
src/librustc/middle/stability.rs
src/librustc/middle/stability.rs
+0
-5
src/librustc_front/fold.rs
src/librustc_front/fold.rs
+1
-1
src/librustc_front/hir.rs
src/librustc_front/hir.rs
+2
-12
src/librustc_front/lowering.rs
src/librustc_front/lowering.rs
+2
-9
src/librustc_front/print/pprust.rs
src/librustc_front/print/pprust.rs
+4
-8
src/librustc_front/util.rs
src/librustc_front/util.rs
+1
-1
src/librustc_front/visit.rs
src/librustc_front/visit.rs
+1
-1
src/librustc_mir/tcx/pattern.rs
src/librustc_mir/tcx/pattern.rs
+1
-1
src/librustc_privacy/lib.rs
src/librustc_privacy/lib.rs
+1
-1
src/librustc_trans/trans/_match.rs
src/librustc_trans/trans/_match.rs
+3
-3
src/librustc_trans/trans/debuginfo/create_scope_map.rs
src/librustc_trans/trans/debuginfo/create_scope_map.rs
+2
-2
src/librustc_typeck/check/_match.rs
src/librustc_typeck/check/_match.rs
+1
-1
src/librustc_typeck/collect.rs
src/librustc_typeck/collect.rs
+1
-1
src/librustdoc/clean/mod.rs
src/librustdoc/clean/mod.rs
+1
-2
src/libsyntax/ast.rs
src/libsyntax/ast.rs
+2
-12
src/libsyntax/ext/base.rs
src/libsyntax/ext/base.rs
+1
-1
src/libsyntax/ext/build.rs
src/libsyntax/ext/build.rs
+1
-1
src/libsyntax/fold.rs
src/libsyntax/fold.rs
+1
-1
src/libsyntax/parse/parser.rs
src/libsyntax/parse/parser.rs
+3
-4
src/libsyntax/print/pprust.rs
src/libsyntax/print/pprust.rs
+4
-8
src/libsyntax/visit.rs
src/libsyntax/visit.rs
+1
-1
src/test/run-make/graphviz-flowgraph/f07.dot-expected.dot
src/test/run-make/graphviz-flowgraph/f07.dot-expected.dot
+1
-1
未找到文件。
src/librustc/middle/cfg/construct.rs
浏览文件 @
3468b8d4
...
...
@@ -104,7 +104,7 @@ fn pat(&mut self, pat: &hir::Pat, pred: CFGIndex) -> CFGIndex {
hir
::
PatQPath
(
..
)
|
hir
::
PatLit
(
..
)
|
hir
::
PatRange
(
..
)
|
hir
::
PatWild
(
_
)
=>
{
hir
::
PatWild
=>
{
self
.add_ast_node
(
pat
.id
,
&
[
pred
])
}
...
...
src/librustc/middle/check_const.rs
浏览文件 @
3468b8d4
...
...
@@ -176,7 +176,7 @@ fn fn_like(&mut self,
if
mode
==
Mode
::
ConstFn
{
for
arg
in
&
fd
.inputs
{
match
arg
.pat.node
{
hir
::
PatWild
(
_
)
=>
{}
hir
::
PatWild
=>
{}
hir
::
PatIdent
(
hir
::
BindByValue
(
hir
::
MutImmutable
),
_
,
None
)
=>
{}
_
=>
{
span_err!
(
self
.tcx.sess
,
arg
.pat.span
,
E0022
,
...
...
src/librustc/middle/check_match.rs
浏览文件 @
3468b8d4
...
...
@@ -47,7 +47,7 @@
pub
const
DUMMY_WILD_PAT
:
&
'static
Pat
=
&
Pat
{
id
:
DUMMY_NODE_ID
,
node
:
hir
::
PatWild
(
hir
::
PatWildSingle
)
,
node
:
hir
::
PatWild
,
span
:
DUMMY_SP
};
...
...
@@ -521,7 +521,7 @@ fn construct_witness<'a,'tcx>(cx: &MatchCheckCtxt<'a,'tcx>, ctor: &Constructor,
if
let
VariantKind
::
Struct
=
v
.kind
()
{
let
field_pats
:
Vec
<
_
>
=
v
.fields
.iter
()
.zip
(
pats
)
.filter
(|
&
(
_
,
ref
pat
)|
pat
.node
!=
hir
::
PatWild
(
hir
::
PatWildSingle
)
)
.filter
(|
&
(
_
,
ref
pat
)|
pat
.node
!=
hir
::
PatWild
)
.map
(|(
field
,
pat
)|
Spanned
{
span
:
DUMMY_SP
,
node
:
hir
::
FieldPat
{
...
...
@@ -553,7 +553,7 @@ fn construct_witness<'a,'tcx>(cx: &MatchCheckCtxt<'a,'tcx>, ctor: &Constructor,
},
_
=>
unreachable!
()
},
ty
::
TyStr
=>
hir
::
PatWild
(
hir
::
PatWildSingle
)
,
ty
::
TyStr
=>
hir
::
PatWild
,
_
=>
{
assert_eq!
(
pats_len
,
1
);
...
...
@@ -570,7 +570,7 @@ fn construct_witness<'a,'tcx>(cx: &MatchCheckCtxt<'a,'tcx>, ctor: &Constructor,
_
=>
{
match
*
ctor
{
ConstantValue
(
ref
v
)
=>
hir
::
PatLit
(
const_val_to_expr
(
v
)),
_
=>
hir
::
PatWild
(
hir
::
PatWildSingle
)
,
_
=>
hir
::
PatWild
,
}
}
};
...
...
@@ -799,7 +799,7 @@ fn pat_constructors(cx: &MatchCheckCtxt, p: &Pat,
},
hir
::
PatBox
(
_
)
|
hir
::
PatTup
(
_
)
|
hir
::
PatRegion
(
..
)
=>
vec!
(
Single
),
hir
::
PatWild
(
_
)
=>
hir
::
PatWild
=>
vec!
(),
}
}
...
...
@@ -862,7 +862,7 @@ pub fn specialize<'a>(cx: &MatchCheckCtxt, r: &[&'a Pat],
id
:
pat_id
,
ref
node
,
span
:
pat_span
}
=
raw_pat
(
r
[
col
]);
let
head
:
Option
<
Vec
<&
Pat
>>
=
match
*
node
{
hir
::
PatWild
(
_
)
=>
hir
::
PatWild
=>
Some
(
vec!
[
DUMMY_WILD_PAT
;
arity
]),
hir
::
PatIdent
(
_
,
_
,
_
)
=>
{
...
...
src/librustc/middle/dead.rs
浏览文件 @
3468b8d4
...
...
@@ -142,7 +142,7 @@ fn handle_field_pattern_match(&mut self, lhs: &hir::Pat,
_
=>
self
.tcx.sess
.span_bug
(
lhs
.span
,
"non-ADT in struct pattern"
)
};
for
pat
in
pats
{
if
let
hir
::
PatWild
(
hir
::
PatWildSingle
)
=
pat
.node.pat.node
{
if
let
hir
::
PatWild
=
pat
.node.pat.node
{
continue
;
}
self
.insert_def_id
(
variant
.field_named
(
pat
.node.name
)
.did
);
...
...
src/librustc/middle/expr_use_visitor.rs
浏览文件 @
3468b8d4
...
...
@@ -1141,7 +1141,7 @@ fn walk_pat(&mut self,
// will visit the substructure recursively.
}
hir
::
PatWild
(
_
)
|
hir
::
PatTup
(
..
)
|
hir
::
PatBox
(
..
)
|
hir
::
PatWild
|
hir
::
PatTup
(
..
)
|
hir
::
PatBox
(
..
)
|
hir
::
PatRegion
(
..
)
|
hir
::
PatLit
(
..
)
|
hir
::
PatRange
(
..
)
|
hir
::
PatVec
(
..
)
=>
{
// Similarly, each of these cases does not
...
...
src/librustc/middle/mem_categorization.rs
浏览文件 @
3468b8d4
...
...
@@ -1211,7 +1211,7 @@ fn cat_pattern_<F>(&self, cmt: cmt<'tcx>, pat: &hir::Pat, op: &mut F)
};
match
pat
.node
{
hir
::
PatWild
(
_
)
=>
{
hir
::
PatWild
=>
{
// _
}
...
...
src/librustc/middle/pat_util.rs
浏览文件 @
3468b8d4
...
...
@@ -101,7 +101,7 @@ pub fn pat_is_binding(dm: &DefMap, pat: &hir::Pat) -> bool {
pub
fn
pat_is_binding_or_wild
(
dm
:
&
DefMap
,
pat
:
&
hir
::
Pat
)
->
bool
{
match
pat
.node
{
hir
::
PatIdent
(
..
)
=>
pat_is_binding
(
dm
,
pat
),
hir
::
PatWild
(
_
)
=>
true
,
hir
::
PatWild
=>
true
,
_
=>
false
}
}
...
...
src/librustc/middle/stability.rs
浏览文件 @
3468b8d4
...
...
@@ -543,11 +543,6 @@ pub fn check_pat(tcx: &ty::ctxt, pat: &hir::Pat,
// Foo(a, b, c)
hir
::
PatEnum
(
_
,
Some
(
ref
pat_fields
))
=>
{
for
(
field
,
struct_field
)
in
pat_fields
.iter
()
.zip
(
&
v
.fields
)
{
// a .. pattern is fine, but anything positional is
// not.
if
let
hir
::
PatWild
(
hir
::
PatWildMulti
)
=
field
.node
{
continue
}
maybe_do_stability_check
(
tcx
,
struct_field
.did
,
field
.span
,
cb
)
}
}
...
...
src/librustc_front/fold.rs
浏览文件 @
3468b8d4
...
...
@@ -1010,7 +1010,7 @@ pub fn noop_fold_pat<T: Folder>(p: P<Pat>, folder: &mut T) -> P<Pat> {
Pat
{
id
:
folder
.new_id
(
id
),
node
:
match
node
{
PatWild
(
k
)
=>
PatWild
(
k
)
,
PatWild
=>
PatWild
,
PatIdent
(
binding_mode
,
pth1
,
sub
)
=>
{
PatIdent
(
binding_mode
,
Spanned
{
...
...
src/librustc_front/hir.rs
浏览文件 @
3468b8d4
...
...
@@ -24,7 +24,6 @@
pub
use
self
::
Mutability
::
*
;
pub
use
self
::
Pat_
::
*
;
pub
use
self
::
PathListItem_
::
*
;
pub
use
self
::
PatWildKind
::
*
;
pub
use
self
::
PrimTy
::
*
;
pub
use
self
::
Stmt_
::
*
;
pub
use
self
::
StructFieldKind
::
*
;
...
...
@@ -393,19 +392,10 @@ pub enum BindingMode {
BindByValue
(
Mutability
),
}
#[derive(Clone,
PartialEq,
Eq,
RustcEncodable,
RustcDecodable,
Hash,
Debug,
Copy)]
pub
enum
PatWildKind
{
/// Represents the wildcard pattern `_`
PatWildSingle
,
/// Represents the wildcard pattern `..`
PatWildMulti
,
}
#[derive(Clone,
PartialEq,
Eq,
RustcEncodable,
RustcDecodable,
Hash,
Debug)]
pub
enum
Pat_
{
/// Represents a wildcard pattern (
either `_` or `..
`)
PatWild
(
PatWildKind
)
,
/// Represents a wildcard pattern (
`_
`)
PatWild
,
/// A PatIdent may either be a new bound variable,
/// or a nullary enum (in which case the third field
...
...
src/librustc_front/lowering.rs
浏览文件 @
3468b8d4
...
...
@@ -818,7 +818,7 @@ pub fn lower_pat(_lctx: &LoweringContext, p: &Pat) -> P<hir::Pat> {
P
(
hir
::
Pat
{
id
:
p
.id
,
node
:
match
p
.node
{
PatWild
(
k
)
=>
hir
::
PatWild
(
lower_pat_wild_kind
(
_
lctx
,
k
))
,
PatWild
=>
hir
::
PatWild
,
PatIdent
(
ref
binding_mode
,
pth1
,
ref
sub
)
=>
{
hir
::
PatIdent
(
lower_binding_mode
(
_
lctx
,
binding_mode
),
pth1
,
...
...
@@ -1482,13 +1482,6 @@ pub fn lower_block_check_mode(_lctx: &LoweringContext, b: &BlockCheckMode) -> hi
}
}
pub
fn
lower_pat_wild_kind
(
_
lctx
:
&
LoweringContext
,
p
:
PatWildKind
)
->
hir
::
PatWildKind
{
match
p
{
PatWildSingle
=>
hir
::
PatWildSingle
,
PatWildMulti
=>
hir
::
PatWildMulti
,
}
}
pub
fn
lower_binding_mode
(
_
lctx
:
&
LoweringContext
,
b
:
&
BindingMode
)
->
hir
::
BindingMode
{
match
*
b
{
BindByRef
(
m
)
=>
hir
::
BindByRef
(
lower_mutability
(
_
lctx
,
m
)),
...
...
@@ -1670,7 +1663,7 @@ fn pat_ident_binding_mode(lctx: &LoweringContext,
}
fn
pat_wild
(
lctx
:
&
LoweringContext
,
span
:
Span
)
->
P
<
hir
::
Pat
>
{
pat
(
lctx
,
span
,
hir
::
PatWild
(
hir
::
PatWildSingle
)
)
pat
(
lctx
,
span
,
hir
::
PatWild
)
}
fn
pat
(
lctx
:
&
LoweringContext
,
span
:
Span
,
pat
:
hir
::
Pat_
)
->
P
<
hir
::
Pat
>
{
...
...
src/librustc_front/print/pprust.rs
浏览文件 @
3468b8d4
...
...
@@ -1719,8 +1719,7 @@ pub fn print_pat(&mut self, pat: &hir::Pat) -> io::Result<()> {
/* Pat isn't normalized, but the beauty of it
is that it doesn't matter */
match
pat
.node
{
hir
::
PatWild
(
hir
::
PatWildSingle
)
=>
try!
(
word
(
&
mut
self
.s
,
"_"
)),
hir
::
PatWild
(
hir
::
PatWildMulti
)
=>
try!
(
word
(
&
mut
self
.s
,
".."
)),
hir
::
PatWild
=>
try!
(
word
(
&
mut
self
.s
,
"_"
)),
hir
::
PatIdent
(
binding_mode
,
ref
path1
,
ref
sub
)
=>
{
match
binding_mode
{
hir
::
BindByRef
(
mutbl
)
=>
{
...
...
@@ -1815,13 +1814,10 @@ pub fn print_pat(&mut self, pat: &hir::Pat) -> io::Result<()> {
if
!
before
.is_empty
()
{
try!
(
self
.word_space
(
","
));
}
try!
(
self
.print_pat
(
&**
p
));
match
**
p
{
hir
::
Pat
{
node
:
hir
::
PatWild
(
hir
::
PatWildMulti
),
..
}
=>
{
// this case is handled by print_pat
}
_
=>
try!
(
word
(
&
mut
self
.s
,
".."
)),
if
p
.node
!=
hir
::
PatWild
{
try!
(
self
.print_pat
(
&**
p
));
}
try!
(
word
(
&
mut
self
.s
,
".."
));
if
!
after
.is_empty
()
{
try!
(
self
.word_space
(
","
));
}
...
...
src/librustc_front/util.rs
浏览文件 @
3468b8d4
...
...
@@ -44,7 +44,7 @@ fn walk_pat_<G>(pat: &Pat, it: &mut G) -> bool
slice
.iter
()
.all
(|
p
|
walk_pat_
(
&**
p
,
it
))
&&
after
.iter
()
.all
(|
p
|
walk_pat_
(
&**
p
,
it
))
}
PatWild
(
_
)
|
PatWild
|
PatLit
(
_
)
|
PatRange
(
_
,
_
)
|
PatIdent
(
_
,
_
,
_
)
|
...
...
src/librustc_front/visit.rs
浏览文件 @
3468b8d4
...
...
@@ -466,7 +466,7 @@ pub fn walk_pat<'v, V: Visitor<'v>>(visitor: &mut V, pattern: &'v Pat) {
visitor
.visit_expr
(
lower_bound
);
visitor
.visit_expr
(
upper_bound
)
}
PatWild
(
_
)
=>
(),
PatWild
=>
(),
PatVec
(
ref
prepatterns
,
ref
slice_pattern
,
ref
postpatterns
)
=>
{
walk_list!
(
visitor
,
visit_pat
,
prepatterns
);
walk_list!
(
visitor
,
visit_pat
,
slice_pattern
);
...
...
src/librustc_mir/tcx/pattern.rs
浏览文件 @
3468b8d4
...
...
@@ -139,7 +139,7 @@ impl<'tcx> Mirror<'tcx> for PatNode<'tcx> {
fn
make_mirror
<
'a
>
(
self
,
cx
:
&
mut
Cx
<
'a
,
'tcx
>
)
->
Pattern
<
'tcx
>
{
let
kind
=
match
self
.pat.node
{
hir
::
PatWild
(
..
)
=>
PatternKind
::
Wild
,
hir
::
PatWild
=>
PatternKind
::
Wild
,
hir
::
PatLit
(
ref
value
)
=>
{
let
value
=
const_eval
::
eval_const_expr
(
cx
.tcx
,
value
);
...
...
src/librustc_privacy/lib.rs
浏览文件 @
3468b8d4
...
...
@@ -962,7 +962,7 @@ fn visit_pat(&mut self, pattern: &hir::Pat) {
match
self
.tcx
.pat_ty
(
pattern
)
.sty
{
ty
::
TyStruct
(
def
,
_
)
=>
{
for
(
i
,
field
)
in
fields
.iter
()
.enumerate
()
{
if
let
hir
::
PatWild
(
..
)
=
field
.node
{
if
let
hir
::
PatWild
=
field
.node
{
continue
}
self
.check_field
(
field
.span
,
...
...
src/librustc_trans/trans/_match.rs
浏览文件 @
3468b8d4
...
...
@@ -866,7 +866,7 @@ fn pat_score(def_map: &DefMap, pat: &hir::Pat) -> usize {
let
column_contains_any_nonwild_patterns
=
|
&
col
:
&
usize
|
->
bool
{
m
.iter
()
.any
(|
row
|
match
row
.pats
[
col
]
.node
{
hir
::
PatWild
(
_
)
=>
false
,
hir
::
PatWild
=>
false
,
_
=>
true
})
};
...
...
@@ -1629,7 +1629,7 @@ fn trans_match_inner<'blk, 'tcx>(scope_cx: Block<'blk, 'tcx>,
// to the default arm.
let
has_default
=
arms
.last
()
.map_or
(
false
,
|
arm
|
{
arm
.pats
.len
()
==
1
&&
arm
.pats
.last
()
.unwrap
()
.node
==
hir
::
PatWild
(
hir
::
PatWildSingle
)
&&
arm
.pats
.last
()
.unwrap
()
.node
==
hir
::
PatWild
});
compile_submatch
(
bcx
,
&
matches
[
..
],
&
[
discr_datum
.match_input
()],
&
chk
,
has_default
);
...
...
@@ -1948,7 +1948,7 @@ pub fn bind_irrefutable_pat<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
cleanup_scope
)
});
}
hir
::
PatQPath
(
..
)
|
hir
::
PatWild
(
_
)
|
hir
::
PatLit
(
_
)
|
hir
::
PatQPath
(
..
)
|
hir
::
PatWild
|
hir
::
PatLit
(
_
)
|
hir
::
PatRange
(
_
,
_
)
=>
()
}
return
bcx
;
...
...
src/librustc_trans/trans/debuginfo/create_scope_map.rs
浏览文件 @
3468b8d4
...
...
@@ -235,7 +235,7 @@ fn walk_pattern(cx: &CrateContext,
}
}
hir
::
PatWild
(
_
)
=>
{
hir
::
PatWild
=>
{
scope_map
.insert
(
pat
.id
,
scope_stack
.last
()
.unwrap
()
.scope_metadata
);
}
...
...
@@ -485,4 +485,4 @@ fn walk_expr(cx: &CrateContext,
}
}
}
}
\ No newline at end of file
}
src/librustc_typeck/check/_match.rs
浏览文件 @
3468b8d4
...
...
@@ -44,7 +44,7 @@ pub fn check_pat<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>,
expected
);
match
pat
.node
{
hir
::
PatWild
(
_
)
=>
{
hir
::
PatWild
=>
{
fcx
.write_ty
(
pat
.id
,
expected
);
}
hir
::
PatLit
(
ref
lt
)
=>
{
...
...
src/librustc_typeck/collect.rs
浏览文件 @
3468b8d4
...
...
@@ -2218,7 +2218,7 @@ fn compute_type_scheme_of_foreign_fn_decl<'a, 'tcx>(
for
i
in
&
decl
.inputs
{
match
(
*
i
)
.pat.node
{
hir
::
PatIdent
(
_
,
_
,
_
)
=>
(),
hir
::
PatWild
(
hir
::
PatWildSingle
)
=>
(),
hir
::
PatWild
=>
(),
_
=>
{
span_err!
(
ccx
.tcx.sess
,
(
*
i
)
.pat.span
,
E0130
,
"patterns aren't allowed in foreign function declarations"
);
...
...
src/librustdoc/clean/mod.rs
浏览文件 @
3468b8d4
...
...
@@ -2528,8 +2528,7 @@ fn name_from_pat(p: &hir::Pat) -> String {
debug!
(
"Trying to get a name from pattern: {:?}"
,
p
);
match
p
.node
{
PatWild
(
PatWildSingle
)
=>
"_"
.to_string
(),
PatWild
(
PatWildMulti
)
=>
".."
.to_string
(),
PatWild
=>
"_"
.to_string
(),
PatIdent
(
_
,
ref
p
,
_
)
=>
p
.node
.to_string
(),
PatEnum
(
ref
p
,
_
)
=>
path_to_string
(
p
),
PatQPath
(
..
)
=>
panic!
(
"tried to get argument name from PatQPath,
\
...
...
src/libsyntax/ast.rs
浏览文件 @
3468b8d4
...
...
@@ -31,7 +31,6 @@
pub
use
self
::
Mutability
::
*
;
pub
use
self
::
Pat_
::
*
;
pub
use
self
::
PathListItem_
::
*
;
pub
use
self
::
PatWildKind
::
*
;
pub
use
self
::
PrimTy
::
*
;
pub
use
self
::
Sign
::
*
;
pub
use
self
::
Stmt_
::
*
;
...
...
@@ -569,19 +568,10 @@ pub enum BindingMode {
BindByValue
(
Mutability
),
}
#[derive(Clone,
PartialEq,
Eq,
RustcEncodable,
RustcDecodable,
Hash,
Debug,
Copy)]
pub
enum
PatWildKind
{
/// Represents the wildcard pattern `_`
PatWildSingle
,
/// Represents the wildcard pattern `..`
PatWildMulti
,
}
#[derive(Clone,
PartialEq,
Eq,
RustcEncodable,
RustcDecodable,
Hash,
Debug)]
pub
enum
Pat_
{
/// Represents a wildcard pattern (
either `_` or `..
`)
PatWild
(
PatWildKind
)
,
/// Represents a wildcard pattern (
`_
`)
PatWild
,
/// A PatIdent may either be a new bound variable,
/// or a nullary enum (in which case the third field
...
...
src/libsyntax/ext/base.rs
浏览文件 @
3468b8d4
...
...
@@ -356,7 +356,7 @@ pub fn raw_expr(sp: Span) -> P<ast::Expr> {
pub
fn
raw_pat
(
sp
:
Span
)
->
ast
::
Pat
{
ast
::
Pat
{
id
:
ast
::
DUMMY_NODE_ID
,
node
:
ast
::
PatWild
(
ast
::
PatWildSingle
)
,
node
:
ast
::
PatWild
,
span
:
sp
,
}
}
...
...
src/libsyntax/ext/build.rs
浏览文件 @
3468b8d4
...
...
@@ -801,7 +801,7 @@ fn pat(&self, span: Span, pat: ast::Pat_) -> P<ast::Pat> {
P
(
ast
::
Pat
{
id
:
ast
::
DUMMY_NODE_ID
,
node
:
pat
,
span
:
span
})
}
fn
pat_wild
(
&
self
,
span
:
Span
)
->
P
<
ast
::
Pat
>
{
self
.pat
(
span
,
ast
::
PatWild
(
ast
::
PatWildSingle
)
)
self
.pat
(
span
,
ast
::
PatWild
)
}
fn
pat_lit
(
&
self
,
span
:
Span
,
expr
:
P
<
ast
::
Expr
>
)
->
P
<
ast
::
Pat
>
{
self
.pat
(
span
,
ast
::
PatLit
(
expr
))
...
...
src/libsyntax/fold.rs
浏览文件 @
3468b8d4
...
...
@@ -1125,7 +1125,7 @@ pub fn noop_fold_pat<T: Folder>(p: P<Pat>, folder: &mut T) -> P<Pat> {
p
.map
(|
Pat
{
id
,
node
,
span
}|
Pat
{
id
:
folder
.new_id
(
id
),
node
:
match
node
{
PatWild
(
k
)
=>
PatWild
(
k
)
,
PatWild
=>
PatWild
,
PatIdent
(
binding_mode
,
pth1
,
sub
)
=>
{
PatIdent
(
binding_mode
,
Spanned
{
span
:
folder
.new_span
(
pth1
.span
),
...
...
src/libsyntax/parse/parser.rs
浏览文件 @
3468b8d4
...
...
@@ -41,8 +41,7 @@
use
ast
::{
MutTy
,
BiMul
,
Mutability
};
use
ast
::{
MethodImplItem
,
NamedField
,
UnNeg
,
NoReturn
,
UnNot
};
use
ast
::{
Pat
,
PatBox
,
PatEnum
,
PatIdent
,
PatLit
,
PatQPath
,
PatMac
,
PatRange
};
use
ast
::{
PatRegion
,
PatStruct
,
PatTup
,
PatVec
,
PatWild
,
PatWildMulti
};
use
ast
::
PatWildSingle
;
use
ast
::{
PatRegion
,
PatStruct
,
PatTup
,
PatVec
,
PatWild
};
use
ast
::{
PolyTraitRef
,
QSelf
};
use
ast
::{
Return
,
BiShl
,
BiShr
,
Stmt
,
StmtDecl
};
use
ast
::{
StmtExpr
,
StmtSemi
,
StmtMac
,
VariantData
,
StructField
};
...
...
@@ -3078,7 +3077,7 @@ fn parse_pat_vec_elements(
self
.check
(
&
token
::
CloseDelim
(
token
::
Bracket
))
{
slice
=
Some
(
P
(
ast
::
Pat
{
id
:
ast
::
DUMMY_NODE_ID
,
node
:
PatWild
(
PatWildMulti
)
,
node
:
PatWild
,
span
:
self
.span
,
}));
before_slice
=
false
;
...
...
@@ -3215,7 +3214,7 @@ pub fn parse_pat_nopanic(&mut self) -> PResult<P<Pat>> {
token
::
Underscore
=>
{
// Parse _
try!
(
self
.bump
());
pat
=
PatWild
(
PatWildSingle
)
;
pat
=
PatWild
;
}
token
::
BinOp
(
token
::
And
)
|
token
::
AndAnd
=>
{
// Parse &pat / &mut pat
...
...
src/libsyntax/print/pprust.rs
浏览文件 @
3468b8d4
...
...
@@ -2406,8 +2406,7 @@ pub fn print_pat(&mut self, pat: &ast::Pat) -> io::Result<()> {
/* Pat isn't normalized, but the beauty of it
is that it doesn't matter */
match
pat
.node
{
ast
::
PatWild
(
ast
::
PatWildSingle
)
=>
try!
(
word
(
&
mut
self
.s
,
"_"
)),
ast
::
PatWild
(
ast
::
PatWildMulti
)
=>
try!
(
word
(
&
mut
self
.s
,
".."
)),
ast
::
PatWild
=>
try!
(
word
(
&
mut
self
.s
,
"_"
)),
ast
::
PatIdent
(
binding_mode
,
ref
path1
,
ref
sub
)
=>
{
match
binding_mode
{
ast
::
BindByRef
(
mutbl
)
=>
{
...
...
@@ -2503,13 +2502,10 @@ pub fn print_pat(&mut self, pat: &ast::Pat) -> io::Result<()> {
|
s
,
p
|
s
.print_pat
(
&**
p
)));
if
let
Some
(
ref
p
)
=
*
slice
{
if
!
before
.is_empty
()
{
try!
(
self
.word_space
(
","
));
}
try!
(
self
.print_pat
(
&**
p
));
match
**
p
{
ast
::
Pat
{
node
:
ast
::
PatWild
(
ast
::
PatWildMulti
),
..
}
=>
{
// this case is handled by print_pat
}
_
=>
try!
(
word
(
&
mut
self
.s
,
".."
)),
if
p
.node
!=
ast
::
PatWild
{
try!
(
self
.print_pat
(
&**
p
));
}
try!
(
word
(
&
mut
self
.s
,
".."
));
if
!
after
.is_empty
()
{
try!
(
self
.word_space
(
","
));
}
}
try!
(
self
.commasep
(
Inconsistent
,
...
...
src/libsyntax/visit.rs
浏览文件 @
3468b8d4
...
...
@@ -451,7 +451,7 @@ pub fn walk_pat<'v, V: Visitor<'v>>(visitor: &mut V, pattern: &'v Pat) {
visitor
.visit_expr
(
lower_bound
);
visitor
.visit_expr
(
upper_bound
)
}
PatWild
(
_
)
=>
(),
PatWild
=>
(),
PatVec
(
ref
prepatterns
,
ref
slice_pattern
,
ref
postpatterns
)
=>
{
walk_list!
(
visitor
,
visit_pat
,
prepatterns
);
walk_list!
(
visitor
,
visit_pat
,
slice_pattern
);
...
...
src/test/run-make/graphviz-flowgraph/f07.dot-expected.dot
浏览文件 @
3468b8d4
...
...
@@ -10,7 +10,7 @@ digraph block {
N8
[
label
=
"(dummy_node)"
]
;
N9
[
label
=
"local x"
]
;
N10
[
label
=
"local y"
]
;
N11
[
label
=
"pat
..
"
]
;
N11
[
label
=
"pat
_
"
]
;
N12
[
label
=
"pat [x, y, ..]"
]
;
N13
[
label
=
"expr x"
]
;
N14
[
label
=
"expr y"
]
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录