Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
561483e4
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,发现更多精彩内容 >>
提交
561483e4
编写于
1月 11, 2019
作者:
M
Mazdak Farrokhzad
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
stabilize top level or-pats in if/while let.
上级
b4398618
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
18 addition
and
44 deletion
+18
-44
src/librustc_mir/lib.rs
src/librustc_mir/lib.rs
+1
-1
src/libsyntax/feature_gate.rs
src/libsyntax/feature_gate.rs
+2
-9
src/libsyntax/parse/parser.rs
src/libsyntax/parse/parser.rs
+3
-2
src/test/run-pass/rfcs/rfc-2175-or-if-while-let/basic.rs
src/test/run-pass/rfcs/rfc-2175-or-if-while-let/basic.rs
+12
-1
src/test/ui/feature-gates/feature-gate-if_while_or_patterns.rs
...est/ui/feature-gates/feature-gate-if_while_or_patterns.rs
+0
-8
src/test/ui/feature-gates/feature-gate-if_while_or_patterns.stderr
...ui/feature-gates/feature-gate-if_while_or_patterns.stderr
+0
-23
未找到文件。
src/librustc_mir/lib.rs
浏览文件 @
561483e4
...
...
@@ -24,7 +24,7 @@
#![feature(unicode_internals)]
#![feature(step_trait)]
#![feature(slice_concat_ext)]
#![
feature(if_while_or_patterns
)]
#![
cfg_attr(stage0,
feature(if_while_or_patterns)
)]
#![feature(try_from)]
#![feature(reverse_bits)]
#![cfg_attr(stage0,
feature(underscore_imports))]
...
...
src/libsyntax/feature_gate.rs
浏览文件 @
561483e4
...
...
@@ -384,9 +384,6 @@ pub fn walk_feature_fields<F>(&self, mut f: F)
// Infer static outlives requirements (RFC 2093).
(
active
,
infer_static_outlives_requirements
,
"1.26.0"
,
Some
(
54185
),
None
),
// Multiple patterns with `|` in `if let` and `while let`.
(
active
,
if_while_or_patterns
,
"1.26.0"
,
Some
(
48215
),
None
),
// Allows macro invocations in `extern {}` blocks.
(
active
,
macros_in_extern
,
"1.27.0"
,
Some
(
49476
),
None
),
...
...
@@ -688,6 +685,8 @@ pub fn walk_feature_fields<F>(&self, mut f: F)
(
accepted
,
min_const_unsafe_fn
,
"1.33.0"
,
Some
(
55607
),
None
),
// `#[cfg_attr(predicate, multiple, attributes, here)]`
(
accepted
,
cfg_attr_multi
,
"1.33.0"
,
Some
(
54881
),
None
),
// Top level or-patterns (`p | q`) in `if let` and `while let`.
(
accepted
,
if_while_or_patterns
,
"1.33.0"
,
Some
(
48215
),
None
),
);
// If you change this, please modify `src/doc/unstable-book` as well. You must
...
...
@@ -1701,12 +1700,6 @@ fn visit_expr(&mut self, e: &'a ast::Expr) {
ast
::
ExprKind
::
TryBlock
(
_
)
=>
{
gate_feature_post!
(
&
self
,
try_blocks
,
e
.span
,
"`try` expression is experimental"
);
}
ast
::
ExprKind
::
IfLet
(
ref
pats
,
..
)
|
ast
::
ExprKind
::
WhileLet
(
ref
pats
,
..
)
=>
{
if
pats
.len
()
>
1
{
gate_feature_post!
(
&
self
,
if_while_or_patterns
,
e
.span
,
"multiple patterns in `if let` and `while let` are unstable"
);
}
}
ast
::
ExprKind
::
Block
(
_
,
opt_label
)
=>
{
if
let
Some
(
label
)
=
opt_label
{
gate_feature_post!
(
&
self
,
label_break_value
,
label
.ident.span
,
...
...
src/libsyntax/parse/parser.rs
浏览文件 @
561483e4
...
...
@@ -3660,8 +3660,6 @@ fn parse_match_expr(&mut self, mut attrs: ThinVec<Attribute>) -> PResult<'a, P<E
maybe_whole!
(
self
,
NtArm
,
|
x
|
x
);
let
attrs
=
self
.parse_outer_attributes
()
?
;
// Allow a '|' before the pats (RFC 1925)
self
.eat
(
&
token
::
BinOp
(
token
::
Or
));
let
pats
=
self
.parse_pats
()
?
;
let
guard
=
if
self
.eat_keyword
(
keywords
::
If
)
{
Some
(
Guard
::
If
(
self
.parse_expr
()
?
))
...
...
@@ -3768,6 +3766,9 @@ fn parse_initializer(&mut self, skip_eq: bool) -> PResult<'a, Option<P<Expr>>> {
/// Parse patterns, separated by '|' s
fn
parse_pats
(
&
mut
self
)
->
PResult
<
'a
,
Vec
<
P
<
Pat
>>>
{
// Allow a '|' before the pats (RFC 1925 + RFC 2530)
self
.eat
(
&
token
::
BinOp
(
token
::
Or
));
let
mut
pats
=
Vec
::
new
();
loop
{
pats
.push
(
self
.parse_top_level_pat
()
?
);
...
...
src/test/run-pass/rfcs/rfc-2175-or-if-while-let/basic.rs
浏览文件 @
561483e4
// run-pass
#![allow(dead_code)]
#![feature(if_while_or_patterns)]
enum
E
{
V
(
u8
),
...
...
@@ -19,4 +18,16 @@ fn main() {
assert_eq!
(
x
,
10
);
e
=
W
;
}
// Accept leading `|`:
let
mut
e
=
V
(
10
);
if
let
|
V
(
x
)
|
U
(
x
)
=
e
{
assert_eq!
(
x
,
10
);
}
while
let
|
V
(
x
)
|
U
(
x
)
=
e
{
assert_eq!
(
x
,
10
);
e
=
W
;
}
}
src/test/ui/feature-gates/feature-gate-if_while_or_patterns.rs
已删除
100644 → 0
浏览文件 @
b4398618
fn
main
()
{
if
let
0
|
1
=
0
{
//~ ERROR multiple patterns in `if let` and `while let` are unstable
;
}
while
let
0
|
1
=
1
{
//~ ERROR multiple patterns in `if let` and `while let` are unstable
break
;
}
}
src/test/ui/feature-gates/feature-gate-if_while_or_patterns.stderr
已删除
100644 → 0
浏览文件 @
b4398618
error[E0658]: multiple patterns in `if let` and `while let` are unstable (see issue #48215)
--> $DIR/feature-gate-if_while_or_patterns.rs:2:5
|
LL | / if let 0 | 1 = 0 { //~ ERROR multiple patterns in `if let` and `while let` are unstable
LL | | ;
LL | | }
| |_____^
|
= help: add #![feature(if_while_or_patterns)] to the crate attributes to enable
error[E0658]: multiple patterns in `if let` and `while let` are unstable (see issue #48215)
--> $DIR/feature-gate-if_while_or_patterns.rs:5:5
|
LL | / while let 0 | 1 = 1 { //~ ERROR multiple patterns in `if let` and `while let` are unstable
LL | | break;
LL | | }
| |_____^
|
= help: add #![feature(if_while_or_patterns)] to the crate attributes to enable
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0658`.
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录