Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
76625eb0
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,发现更多精彩内容 >>
提交
76625eb0
编写于
8月 28, 2019
作者:
M
Mazdak Farrokhzad
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
or-patterns: syntax: adjust derive, format, and building.
上级
424492ac
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
14 addition
and
18 deletion
+14
-18
src/libsyntax/ext/build.rs
src/libsyntax/ext/build.rs
+5
-5
src/libsyntax_ext/deriving/cmp/ord.rs
src/libsyntax_ext/deriving/cmp/ord.rs
+2
-4
src/libsyntax_ext/deriving/cmp/partial_ord.rs
src/libsyntax_ext/deriving/cmp/partial_ord.rs
+2
-2
src/libsyntax_ext/deriving/decodable.rs
src/libsyntax_ext/deriving/decodable.rs
+1
-3
src/libsyntax_ext/deriving/generic/mod.rs
src/libsyntax_ext/deriving/generic/mod.rs
+3
-3
src/libsyntax_ext/format.rs
src/libsyntax_ext/format.rs
+1
-1
未找到文件。
src/libsyntax/ext/build.rs
浏览文件 @
76625eb0
...
...
@@ -537,9 +537,9 @@ pub fn expr_try(&self, sp: Span, head: P<ast::Expr>) -> P<ast::Expr> {
let
err_expr
=
self
.expr
(
sp
,
ast
::
ExprKind
::
Ret
(
Some
(
err_inner_expr
)));
// `Ok(__try_var) => __try_var`
let
ok_arm
=
self
.arm
(
sp
,
vec!
[
ok_pat
]
,
binding_expr
);
let
ok_arm
=
self
.arm
(
sp
,
ok_pat
,
binding_expr
);
// `Err(__try_var) => return Err(__try_var)`
let
err_arm
=
self
.arm
(
sp
,
vec!
[
err_pat
]
,
err_expr
);
let
err_arm
=
self
.arm
(
sp
,
err_pat
,
err_expr
);
// `match head { Ok() => ..., Err() => ... }`
self
.expr_match
(
sp
,
head
,
vec!
[
ok_arm
,
err_arm
])
...
...
@@ -606,10 +606,10 @@ pub fn pat_err(&self, span: Span, pat: P<ast::Pat>) -> P<ast::Pat> {
self
.pat_tuple_struct
(
span
,
path
,
vec!
[
pat
])
}
pub
fn
arm
(
&
self
,
span
:
Span
,
pat
s
:
Vec
<
P
<
ast
::
Pat
>
>
,
expr
:
P
<
ast
::
Expr
>
)
->
ast
::
Arm
{
pub
fn
arm
(
&
self
,
span
:
Span
,
pat
:
P
<
ast
::
Pat
>
,
expr
:
P
<
ast
::
Expr
>
)
->
ast
::
Arm
{
ast
::
Arm
{
attrs
:
vec!
[],
pat
s
,
pat
,
guard
:
None
,
body
:
expr
,
span
,
...
...
@@ -618,7 +618,7 @@ pub fn arm(&self, span: Span, pats: Vec<P<ast::Pat>>, expr: P<ast::Expr>) -> ast
}
pub
fn
arm_unreachable
(
&
self
,
span
:
Span
)
->
ast
::
Arm
{
self
.arm
(
span
,
vec!
[
self
.pat_wild
(
span
)]
,
self
.expr_unreachable
(
span
))
self
.arm
(
span
,
self
.pat_wild
(
span
)
,
self
.expr_unreachable
(
span
))
}
pub
fn
expr_match
(
&
self
,
span
:
Span
,
arg
:
P
<
ast
::
Expr
>
,
arms
:
Vec
<
ast
::
Arm
>
)
->
P
<
Expr
>
{
...
...
src/libsyntax_ext/deriving/cmp/ord.rs
浏览文件 @
76625eb0
...
...
@@ -95,11 +95,9 @@ pub fn cs_cmp(cx: &mut ExtCtxt<'_>, span: Span, substr: &Substructure<'_>) -> P<
cx
.expr_call_global
(
span
,
cmp_path
.clone
(),
args
)
};
let
eq_arm
=
cx
.arm
(
span
,
vec!
[
cx
.pat_path
(
span
,
equals_path
.clone
())],
old
);
let
eq_arm
=
cx
.arm
(
span
,
cx
.pat_path
(
span
,
equals_path
.clone
()),
old
);
let
neq_arm
=
cx
.arm
(
span
,
vec!
[
cx
.pat_ident
(
span
,
test_id
)]
,
cx
.pat_ident
(
span
,
test_id
)
,
cx
.expr_ident
(
span
,
test_id
));
cx
.expr_match
(
span
,
new
,
vec!
[
eq_arm
,
neq_arm
])
...
...
src/libsyntax_ext/deriving/cmp/partial_ord.rs
浏览文件 @
76625eb0
...
...
@@ -160,10 +160,10 @@ pub fn cs_partial_cmp(cx: &mut ExtCtxt<'_>, span: Span, substr: &Substructure<'_
};
let
eq_arm
=
cx
.arm
(
span
,
vec!
[
cx
.pat_some
(
span
,
cx
.pat_path
(
span
,
ordering
.clone
()))]
,
cx
.pat_some
(
span
,
cx
.pat_path
(
span
,
ordering
.clone
()))
,
old
);
let
neq_arm
=
cx
.arm
(
span
,
vec!
[
cx
.pat_ident
(
span
,
test_id
)]
,
cx
.pat_ident
(
span
,
test_id
)
,
cx
.expr_ident
(
span
,
test_id
));
cx
.expr_match
(
span
,
new
,
vec!
[
eq_arm
,
neq_arm
])
...
...
src/libsyntax_ext/deriving/decodable.rs
浏览文件 @
76625eb0
...
...
@@ -119,9 +119,7 @@ fn decodable_substructure(cx: &mut ExtCtxt<'_>,
vec!
[
idx
,
exprdecode
.clone
()]))
});
arms
.push
(
cx
.arm
(
v_span
,
vec!
[
cx
.pat_lit
(
v_span
,
cx
.expr_usize
(
v_span
,
i
))],
decoded
));
arms
.push
(
cx
.arm
(
v_span
,
cx
.pat_lit
(
v_span
,
cx
.expr_usize
(
v_span
,
i
)),
decoded
));
}
arms
.push
(
cx
.arm_unreachable
(
trait_span
));
...
...
src/libsyntax_ext/deriving/generic/mod.rs
浏览文件 @
76625eb0
...
...
@@ -1071,7 +1071,7 @@ fn expand_struct_method_body<'b>(&self,
for
(
arg_expr
,
pat
)
in
self_args
.iter
()
.zip
(
patterns
)
{
body
=
cx
.expr_match
(
trait_
.span
,
arg_expr
.clone
(),
vec!
[
cx
.arm
(
trait_
.span
,
vec!
[
pat
.clone
()]
,
body
)])
vec!
[
cx
.arm
(
trait_
.span
,
pat
.clone
()
,
body
)])
}
body
...
...
@@ -1311,7 +1311,7 @@ fn build_enum_match_tuple<'b>(&self,
nonself_args
,
&
substructure
);
cx
.arm
(
sp
,
vec!
[
single_pat
]
,
arm_expr
)
cx
.arm
(
sp
,
single_pat
,
arm_expr
)
})
.collect
();
...
...
@@ -1337,7 +1337,7 @@ fn build_enum_match_tuple<'b>(&self,
_
=>
None
,
};
if
let
Some
(
arm
)
=
default
{
match_arms
.push
(
cx
.arm
(
sp
,
vec!
[
cx
.pat_wild
(
sp
)]
,
arm
));
match_arms
.push
(
cx
.arm
(
sp
,
cx
.pat_wild
(
sp
)
,
arm
));
}
// We will usually need the catch-all after matching the
...
...
src/libsyntax_ext/format.rs
浏览文件 @
76625eb0
...
...
@@ -716,7 +716,7 @@ fn into_expr(self) -> P<ast::Expr> {
// But the nested match expression is proved to perform not as well
// as series of let's; the first approach does.
let
pat
=
self
.ecx
.pat_tuple
(
self
.fmtsp
,
pats
);
let
arm
=
self
.ecx
.arm
(
self
.fmtsp
,
vec!
[
pat
]
,
args_array
);
let
arm
=
self
.ecx
.arm
(
self
.fmtsp
,
pat
,
args_array
);
let
head
=
self
.ecx
.expr
(
self
.fmtsp
,
ast
::
ExprKind
::
Tup
(
heads
));
let
result
=
self
.ecx
.expr_match
(
self
.fmtsp
,
head
,
vec!
[
arm
]);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录