Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
3a07d3db
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,发现更多精彩内容 >>
提交
3a07d3db
编写于
9月 10, 2018
作者:
F
Felix S. Klock II
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
On nightly with NLL, suggest `#![feature(bind_by_move_pattern_guards)]` when it might fix the code.
上级
c50884c6
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
75 addition
and
8 deletion
+75
-8
src/librustc_mir/hair/pattern/check_match.rs
src/librustc_mir/hair/pattern/check_match.rs
+18
-8
src/test/ui/bind-by-move/bind-by-move-no-guards.nll.stderr
src/test/ui/bind-by-move/bind-by-move-no-guards.nll.stderr
+11
-0
src/test/ui/borrowck/borrowck-mutate-in-guard.nll.stderr
src/test/ui/borrowck/borrowck-mutate-in-guard.nll.stderr
+24
-0
src/test/ui/error-codes/E0008.nll.stderr
src/test/ui/error-codes/E0008.nll.stderr
+11
-0
src/test/ui/error-codes/E0301.nll.stderr
src/test/ui/error-codes/E0301.nll.stderr
+11
-0
未找到文件。
src/librustc_mir/hair/pattern/check_match.rs
浏览文件 @
3a07d3db
...
...
@@ -538,10 +538,14 @@ fn check_legality_of_move_bindings(cx: &MatchVisitor,
.span_label
(
p
.span
,
"binds an already bound by-move value by moving it"
)
.emit
();
}
else
if
has_guard
&&
!
cx
.tcx
.allow_bind_by_move_patterns_with_guards
()
{
struct_span_err!
(
cx
.tcx.sess
,
p
.span
,
E0008
,
"cannot bind by-move into a pattern guard"
)
.span_label
(
p
.span
,
"moves value into pattern guard"
)
.emit
();
let
mut
err
=
struct_span_err!
(
cx
.tcx.sess
,
p
.span
,
E0008
,
"cannot bind by-move into a pattern guard"
);
err
.span_label
(
p
.span
,
"moves value into pattern guard"
);
if
cx
.tcx.sess.opts.unstable_features
.is_nightly_build
()
&&
cx
.tcx
.use_mir_borrowck
()
{
err
.help
(
"add #![feature(bind_by_move_pattern_guards)] to the
\
crate attributes to enable"
);
}
err
.emit
();
}
else
if
let
Some
(
by_ref_span
)
=
by_ref_span
{
struct_span_err!
(
cx
.tcx.sess
,
...
...
@@ -613,10 +617,16 @@ fn borrow(&mut self,
_
:
LoanCause
)
{
match
kind
{
ty
::
MutBorrow
=>
{
struct_span_err!
(
self
.cx.tcx.sess
,
span
,
E0301
,
"cannot mutably borrow in a pattern guard"
)
.span_label
(
span
,
"borrowed mutably in pattern guard"
)
.emit
();
let
mut
err
=
struct_span_err!
(
self
.cx.tcx.sess
,
span
,
E0301
,
"cannot mutably borrow in a pattern guard"
);
err
.span_label
(
span
,
"borrowed mutably in pattern guard"
);
if
self
.cx.tcx.sess.opts.unstable_features
.is_nightly_build
()
&&
self
.cx.tcx
.use_mir_borrowck
()
{
err
.help
(
"add #![feature(bind_by_move_pattern_guards)] to the
\
crate attributes to enable"
);
}
err
.emit
();
}
ty
::
ImmBorrow
|
ty
::
UniqueImmBorrow
=>
{}
}
...
...
src/test/ui/bind-by-move/bind-by-move-no-guards.nll.stderr
0 → 100644
浏览文件 @
3a07d3db
error[E0008]: cannot bind by-move into a pattern guard
--> $DIR/bind-by-move-no-guards.rs:8:14
|
LL | Some(z) if z.recv().unwrap() => { panic!() },
| ^ moves value into pattern guard
|
= help: add #![feature(bind_by_move_pattern_guards)] to the crate attributes to enable
error: aborting due to previous error
For more information about this error, try `rustc --explain E0008`.
src/test/ui/borrowck/borrowck-mutate-in-guard.nll.stderr
0 → 100644
浏览文件 @
3a07d3db
error[E0302]: cannot assign in a pattern guard
--> $DIR/borrowck-mutate-in-guard.rs:20:25
|
LL | Enum::A(_) if { x = Enum::B(false); false } => 1,
| ^^^^^^^^^^^^^^^^^^ assignment in pattern guard
error[E0301]: cannot mutably borrow in a pattern guard
--> $DIR/borrowck-mutate-in-guard.rs:22:38
|
LL | Enum::A(_) if { let y = &mut x; *y = Enum::B(false); false } => 1,
| ^ borrowed mutably in pattern guard
|
= help: add #![feature(bind_by_move_pattern_guards)] to the crate attributes to enable
error[E0302]: cannot assign in a pattern guard
--> $DIR/borrowck-mutate-in-guard.rs:22:41
|
LL | Enum::A(_) if { let y = &mut x; *y = Enum::B(false); false } => 1,
| ^^^^^^^^^^^^^^^^^^^ assignment in pattern guard
error: aborting due to 3 previous errors
Some errors occurred: E0301, E0302.
For more information about an error, try `rustc --explain E0301`.
src/test/ui/error-codes/E0008.nll.stderr
0 → 100644
浏览文件 @
3a07d3db
error[E0008]: cannot bind by-move into a pattern guard
--> $DIR/E0008.rs:13:14
|
LL | Some(s) if s.len() == 0 => {},
| ^ moves value into pattern guard
|
= help: add #![feature(bind_by_move_pattern_guards)] to the crate attributes to enable
error: aborting due to previous error
For more information about this error, try `rustc --explain E0008`.
src/test/ui/error-codes/E0301.nll.stderr
0 → 100644
浏览文件 @
3a07d3db
error[E0301]: cannot mutably borrow in a pattern guard
--> $DIR/E0301.rs:14:19
|
LL | option if option.take().is_none() => {}, //~ ERROR E0301
| ^^^^^^ borrowed mutably in pattern guard
|
= help: add #![feature(bind_by_move_pattern_guards)] to the crate attributes to enable
error: aborting due to previous error
For more information about this error, try `rustc --explain E0301`.
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录