Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
50e95ea4
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,发现更多精彩内容 >>
提交
50e95ea4
编写于
6月 21, 2013
作者:
N
Niko Matsakis
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix pretty printer, which was ignoring `ref` in irrefutable patterns
上级
682e7467
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
26 addition
and
41 deletion
+26
-41
src/libsyntax/print/pprust.rs
src/libsyntax/print/pprust.rs
+23
-38
src/test/bench/shootout-k-nucleotide-pipes.rs
src/test/bench/shootout-k-nucleotide-pipes.rs
+2
-2
src/test/run-pass-fulldeps/qquote.rs
src/test/run-pass-fulldeps/qquote.rs
+1
-1
未找到文件。
src/libsyntax/print/pprust.rs
浏览文件 @
50e95ea4
...
@@ -147,7 +147,7 @@ pub fn ty_to_str(ty: &ast::Ty, intr: @ident_interner) -> ~str {
...
@@ -147,7 +147,7 @@ pub fn ty_to_str(ty: &ast::Ty, intr: @ident_interner) -> ~str {
}
}
pub
fn
pat_to_str
(
pat
:
&
ast
::
pat
,
intr
:
@
ident_interner
)
->
~
str
{
pub
fn
pat_to_str
(
pat
:
&
ast
::
pat
,
intr
:
@
ident_interner
)
->
~
str
{
to_str
(
pat
,
print_
irrefutable_
pat
,
intr
)
to_str
(
pat
,
print_pat
,
intr
)
}
}
pub
fn
expr_to_str
(
e
:
&
ast
::
expr
,
intr
:
@
ident_interner
)
->
~
str
{
pub
fn
expr_to_str
(
e
:
&
ast
::
expr
,
intr
:
@
ident_interner
)
->
~
str
{
...
@@ -1240,7 +1240,7 @@ fn print_field(s: @ps, field: &ast::field) {
...
@@ -1240,7 +1240,7 @@ fn print_field(s: @ps, field: &ast::field) {
if
first
{
if
first
{
first
=
false
;
first
=
false
;
}
else
{
space
(
s
.s
);
word_space
(
s
,
"|"
);
}
}
else
{
space
(
s
.s
);
word_space
(
s
,
"|"
);
}
print_
refutable_
pat
(
s
,
*
p
);
print_pat
(
s
,
*
p
);
}
}
space
(
s
.s
);
space
(
s
.s
);
match
arm
.guard
{
match
arm
.guard
{
...
@@ -1434,7 +1434,7 @@ fn print_field(s: @ps, field: &ast::field) {
...
@@ -1434,7 +1434,7 @@ fn print_field(s: @ps, field: &ast::field) {
}
}
pub
fn
print_local_decl
(
s
:
@
ps
,
loc
:
&
ast
::
local
)
{
pub
fn
print_local_decl
(
s
:
@
ps
,
loc
:
&
ast
::
local
)
{
print_
irrefutable_
pat
(
s
,
loc
.node.pat
);
print_pat
(
s
,
loc
.node.pat
);
match
loc
.node.ty.node
{
match
loc
.node.ty.node
{
ast
::
ty_infer
=>
(),
ast
::
ty_infer
=>
(),
_
=>
{
word_space
(
s
,
":"
);
print_type
(
s
,
&
loc
.node.ty
);
}
_
=>
{
word_space
(
s
,
":"
);
print_type
(
s
,
&
loc
.node.ty
);
}
...
@@ -1521,20 +1521,7 @@ pub fn print_path(s: @ps, path: &ast::Path, colons_before_params: bool) {
...
@@ -1521,20 +1521,7 @@ pub fn print_path(s: @ps, path: &ast::Path, colons_before_params: bool) {
print_path_
(
s
,
path
,
colons_before_params
,
&
None
)
print_path_
(
s
,
path
,
colons_before_params
,
&
None
)
}
}
pub
fn
print_bounded_path
(
s
:
@
ps
,
path
:
&
ast
::
Path
,
pub
fn
print_pat
(
s
:
@
ps
,
pat
:
&
ast
::
pat
)
{
bounds
:
&
Option
<
OptVec
<
ast
::
TyParamBound
>>
)
{
print_path_
(
s
,
path
,
false
,
bounds
)
}
pub
fn
print_irrefutable_pat
(
s
:
@
ps
,
pat
:
&
ast
::
pat
)
{
print_pat
(
s
,
pat
,
false
)
}
pub
fn
print_refutable_pat
(
s
:
@
ps
,
pat
:
&
ast
::
pat
)
{
print_pat
(
s
,
pat
,
true
)
}
pub
fn
print_pat
(
s
:
@
ps
,
pat
:
&
ast
::
pat
,
refutable
:
bool
)
{
maybe_print_comment
(
s
,
pat
.span.lo
);
maybe_print_comment
(
s
,
pat
.span.lo
);
let
ann_node
=
node_pat
(
s
,
pat
);
let
ann_node
=
node_pat
(
s
,
pat
);
(
s
.ann.pre
)(
ann_node
);
(
s
.ann.pre
)(
ann_node
);
...
@@ -1543,20 +1530,18 @@ pub fn print_pat(s: @ps, pat: &ast::pat, refutable: bool) {
...
@@ -1543,20 +1530,18 @@ pub fn print_pat(s: @ps, pat: &ast::pat, refutable: bool) {
match
pat
.node
{
match
pat
.node
{
ast
::
pat_wild
=>
word
(
s
.s
,
"_"
),
ast
::
pat_wild
=>
word
(
s
.s
,
"_"
),
ast
::
pat_ident
(
binding_mode
,
ref
path
,
sub
)
=>
{
ast
::
pat_ident
(
binding_mode
,
ref
path
,
sub
)
=>
{
if
refutable
{
match
binding_mode
{
match
binding_mode
{
ast
::
bind_by_ref
(
mutbl
)
=>
{
ast
::
bind_by_ref
(
mutbl
)
=>
{
word_nbsp
(
s
,
"ref"
);
word_nbsp
(
s
,
"ref"
);
print_mutability
(
s
,
mutbl
);
print_mutability
(
s
,
mutbl
);
}
ast
::
bind_infer
=>
{}
}
}
ast
::
bind_infer
=>
{}
}
}
print_path
(
s
,
path
,
true
);
print_path
(
s
,
path
,
true
);
match
sub
{
match
sub
{
Some
(
p
)
=>
{
Some
(
p
)
=>
{
word
(
s
.s
,
"@"
);
word
(
s
.s
,
"@"
);
print_pat
(
s
,
p
,
refutable
);
print_pat
(
s
,
p
);
}
}
None
=>
()
None
=>
()
}
}
...
@@ -1569,7 +1554,7 @@ pub fn print_pat(s: @ps, pat: &ast::pat, refutable: bool) {
...
@@ -1569,7 +1554,7 @@ pub fn print_pat(s: @ps, pat: &ast::pat, refutable: bool) {
if
!
args
.is_empty
()
{
if
!
args
.is_empty
()
{
popen
(
s
);
popen
(
s
);
commasep
(
s
,
inconsistent
,
*
args
,
commasep
(
s
,
inconsistent
,
*
args
,
|
s
,
&
p
|
print_pat
(
s
,
p
,
refutable
));
|
s
,
&
p
|
print_pat
(
s
,
p
));
pclose
(
s
);
pclose
(
s
);
}
else
{
}
}
else
{
}
}
}
...
@@ -1578,16 +1563,16 @@ pub fn print_pat(s: @ps, pat: &ast::pat, refutable: bool) {
...
@@ -1578,16 +1563,16 @@ pub fn print_pat(s: @ps, pat: &ast::pat, refutable: bool) {
ast
::
pat_struct
(
ref
path
,
ref
fields
,
etc
)
=>
{
ast
::
pat_struct
(
ref
path
,
ref
fields
,
etc
)
=>
{
print_path
(
s
,
path
,
true
);
print_path
(
s
,
path
,
true
);
word
(
s
.s
,
"{"
);
word
(
s
.s
,
"{"
);
fn
print_field
(
s
:
@
ps
,
f
:
&
ast
::
field_pat
,
refutable
:
bool
)
{
fn
print_field
(
s
:
@
ps
,
f
:
&
ast
::
field_pat
)
{
cbox
(
s
,
indent_unit
);
cbox
(
s
,
indent_unit
);
print_ident
(
s
,
f
.ident
);
print_ident
(
s
,
f
.ident
);
word_space
(
s
,
":"
);
word_space
(
s
,
":"
);
print_pat
(
s
,
f
.pat
,
refutable
);
print_pat
(
s
,
f
.pat
);
end
(
s
);
end
(
s
);
}
}
fn
get_span
(
f
:
&
ast
::
field_pat
)
->
codemap
::
span
{
return
f
.pat.span
;
}
fn
get_span
(
f
:
&
ast
::
field_pat
)
->
codemap
::
span
{
return
f
.pat.span
;
}
commasep_cmnt
(
s
,
consistent
,
*
fields
,
commasep_cmnt
(
s
,
consistent
,
*
fields
,
|
s
,
f
|
print_field
(
s
,
f
,
refutable
),
|
s
,
f
|
print_field
(
s
,
f
),
get_span
);
get_span
);
if
etc
{
if
etc
{
if
fields
.len
()
!=
0u
{
word_space
(
s
,
","
);
}
if
fields
.len
()
!=
0u
{
word_space
(
s
,
","
);
}
...
@@ -1597,7 +1582,7 @@ fn print_field(s: @ps, f: &ast::field_pat, refutable: bool) {
...
@@ -1597,7 +1582,7 @@ fn print_field(s: @ps, f: &ast::field_pat, refutable: bool) {
}
}
ast
::
pat_tup
(
ref
elts
)
=>
{
ast
::
pat_tup
(
ref
elts
)
=>
{
popen
(
s
);
popen
(
s
);
commasep
(
s
,
inconsistent
,
*
elts
,
|
s
,
&
p
|
print_pat
(
s
,
p
,
refutable
));
commasep
(
s
,
inconsistent
,
*
elts
,
|
s
,
&
p
|
print_pat
(
s
,
p
));
if
elts
.len
()
==
1
{
if
elts
.len
()
==
1
{
word
(
s
.s
,
","
);
word
(
s
.s
,
","
);
}
}
...
@@ -1605,15 +1590,15 @@ fn print_field(s: @ps, f: &ast::field_pat, refutable: bool) {
...
@@ -1605,15 +1590,15 @@ fn print_field(s: @ps, f: &ast::field_pat, refutable: bool) {
}
}
ast
::
pat_box
(
inner
)
=>
{
ast
::
pat_box
(
inner
)
=>
{
word
(
s
.s
,
"@"
);
word
(
s
.s
,
"@"
);
print_pat
(
s
,
inner
,
refutable
);
print_pat
(
s
,
inner
);
}
}
ast
::
pat_uniq
(
inner
)
=>
{
ast
::
pat_uniq
(
inner
)
=>
{
word
(
s
.s
,
"~"
);
word
(
s
.s
,
"~"
);
print_pat
(
s
,
inner
,
refutable
);
print_pat
(
s
,
inner
);
}
}
ast
::
pat_region
(
inner
)
=>
{
ast
::
pat_region
(
inner
)
=>
{
word
(
s
.s
,
"&"
);
word
(
s
.s
,
"&"
);
print_pat
(
s
,
inner
,
refutable
);
print_pat
(
s
,
inner
);
}
}
ast
::
pat_lit
(
e
)
=>
print_expr
(
s
,
e
),
ast
::
pat_lit
(
e
)
=>
print_expr
(
s
,
e
),
ast
::
pat_range
(
begin
,
end
)
=>
{
ast
::
pat_range
(
begin
,
end
)
=>
{
...
@@ -1625,16 +1610,16 @@ fn print_field(s: @ps, f: &ast::field_pat, refutable: bool) {
...
@@ -1625,16 +1610,16 @@ fn print_field(s: @ps, f: &ast::field_pat, refutable: bool) {
ast
::
pat_vec
(
ref
before
,
slice
,
ref
after
)
=>
{
ast
::
pat_vec
(
ref
before
,
slice
,
ref
after
)
=>
{
word
(
s
.s
,
"["
);
word
(
s
.s
,
"["
);
do
commasep
(
s
,
inconsistent
,
*
before
)
|
s
,
&
p
|
{
do
commasep
(
s
,
inconsistent
,
*
before
)
|
s
,
&
p
|
{
print_pat
(
s
,
p
,
refutable
);
print_pat
(
s
,
p
);
}
}
for
slice
.iter
()
.advance
|
&
p
|
{
for
slice
.iter
()
.advance
|
&
p
|
{
if
!
before
.is_empty
()
{
word_space
(
s
,
","
);
}
if
!
before
.is_empty
()
{
word_space
(
s
,
","
);
}
word
(
s
.s
,
".."
);
word
(
s
.s
,
".."
);
print_pat
(
s
,
p
,
refutable
);
print_pat
(
s
,
p
);
if
!
after
.is_empty
()
{
word_space
(
s
,
","
);
}
if
!
after
.is_empty
()
{
word_space
(
s
,
","
);
}
}
}
do
commasep
(
s
,
inconsistent
,
*
after
)
|
s
,
&
p
|
{
do
commasep
(
s
,
inconsistent
,
*
after
)
|
s
,
&
p
|
{
print_pat
(
s
,
p
,
refutable
);
print_pat
(
s
,
p
);
}
}
word
(
s
.s
,
"]"
);
word
(
s
.s
,
"]"
);
}
}
...
@@ -1888,7 +1873,7 @@ pub fn print_arg(s: @ps, input: &ast::arg) {
...
@@ -1888,7 +1873,7 @@ pub fn print_arg(s: @ps, input: &ast::arg) {
word_space
(
s
,
"mut"
);
word_space
(
s
,
"mut"
);
}
}
match
input
.ty.node
{
match
input
.ty.node
{
ast
::
ty_infer
=>
print_
irrefutable_
pat
(
s
,
input
.pat
),
ast
::
ty_infer
=>
print_pat
(
s
,
input
.pat
),
_
=>
{
_
=>
{
match
input
.pat.node
{
match
input
.pat.node
{
ast
::
pat_ident
(
_
,
ref
path
,
_
)
if
ast
::
pat_ident
(
_
,
ref
path
,
_
)
if
...
@@ -1897,7 +1882,7 @@ pub fn print_arg(s: @ps, input: &ast::arg) {
...
@@ -1897,7 +1882,7 @@ pub fn print_arg(s: @ps, input: &ast::arg) {
// Do nothing.
// Do nothing.
}
}
_
=>
{
_
=>
{
print_
irrefutable_
pat
(
s
,
input
.pat
);
print_pat
(
s
,
input
.pat
);
word
(
s
.s
,
":"
);
word
(
s
.s
,
":"
);
space
(
s
.s
);
space
(
s
.s
);
}
}
...
...
src/test/bench/shootout-k-nucleotide-pipes.rs
浏览文件 @
50e95ea4
...
@@ -56,8 +56,8 @@ fn sortKV<TT:Copy + Ord,UU:Copy + Ord>(orig: ~[(TT,UU)]) -> ~[(TT,UU)] {
...
@@ -56,8 +56,8 @@ fn sortKV<TT:Copy + Ord,UU:Copy + Ord>(orig: ~[(TT,UU)]) -> ~[(TT,UU)] {
let
mut
pairs
=
~
[];
let
mut
pairs
=
~
[];
// map -> [(k,%)]
// map -> [(k,%)]
for
mm
.iter
()
.advance
|(
&
key
,
&
val
)|
{
for
mm
.iter
()
.advance
|(
key
,
&
val
)|
{
pairs
.push
((
key
,
pct
(
val
,
total
)));
pairs
.push
((
copy
*
key
,
pct
(
val
,
total
)));
}
}
let
pairs_sorted
=
sortKV
(
pairs
);
let
pairs_sorted
=
sortKV
(
pairs
);
...
...
src/test/run-pass-fulldeps/qquote.rs
浏览文件 @
50e95ea4
...
@@ -68,7 +68,7 @@ fn main() {
...
@@ -68,7 +68,7 @@ fn main() {
check_pp
(
ext_cx
,
*
stmt
,
pprust
::
print_stmt
,
~
"let x = 20;"
);
check_pp
(
ext_cx
,
*
stmt
,
pprust
::
print_stmt
,
~
"let x = 20;"
);
let
pat
=
quote_pat!
(
Some
(
_
));
let
pat
=
quote_pat!
(
Some
(
_
));
check_pp
(
ext_cx
,
pat
,
pprust
::
print_
refutable_
pat
,
~
"Some(_)"
);
check_pp
(
ext_cx
,
pat
,
pprust
::
print_pat
,
~
"Some(_)"
);
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录