Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
6cf4e14a
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,发现更多精彩内容 >>
提交
6cf4e14a
编写于
8月 13, 2018
作者:
A
ashtneoi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Coalesce var-is-not-Copy notes per move
上级
20ae08bd
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
60 addition
and
150 deletion
+60
-150
src/librustc_mir/borrow_check/move_errors.rs
src/librustc_mir/borrow_check/move_errors.rs
+20
-9
src/test/ui/suggestions/dont-suggest-ref.stderr
src/test/ui/suggestions/dont-suggest-ref.stderr
+40
-141
未找到文件。
src/librustc_mir/borrow_check/move_errors.rs
浏览文件 @
6cf4e14a
...
...
@@ -380,8 +380,6 @@ fn add_move_hints(
}
}
// FIXME: Move the loop outside this method and add_move_error_labels()
// so they can share it.
fn
add_move_error_suggestions
(
&
self
,
err
:
&
mut
DiagnosticBuilder
<
'a
>
,
...
...
@@ -433,6 +431,7 @@ fn add_move_error_labels(
err
:
&
mut
DiagnosticBuilder
<
'a
>
,
binds_to
:
&
[
Local
],
)
{
let
mut
noncopy_var_spans
=
Vec
::
new
();
for
(
j
,
local
)
in
binds_to
.into_iter
()
.enumerate
()
{
let
bind_to
=
&
self
.mir.local_decls
[
*
local
];
let
binding_span
=
bind_to
.source_info.span
;
...
...
@@ -443,6 +442,7 @@ fn add_move_error_labels(
err
.span_label
(
binding_span
,
format!
(
"... and here"
));
}
if
binds_to
.len
()
==
1
{
err
.span_note
(
binding_span
,
&
format!
(
...
...
@@ -452,6 +452,17 @@ fn add_move_error_labels(
bind_to
.ty
),
);
}
else
{
noncopy_var_spans
.push
(
binding_span
);
}
}
if
binds_to
.len
()
>
1
{
err
.span_note
(
noncopy_var_spans
,
"move occurs because these variables have types that
\
don't implement the `Copy` trait"
,
);
}
}
}
src/test/ui/suggestions/dont-suggest-ref.stderr
浏览文件 @
6cf4e14a
...
...
@@ -526,14 +526,12 @@ LL | &mut Either::One(_t) => (),
LL | &mut Either::Two(_t) => (),
| -- ... and here
|
note: move occurs because
`_t` has type `X`, which does no
t implement the `Copy` trait
note: move occurs because
these variables have types that don'
t implement the `Copy` trait
--> $DIR/dont-suggest-ref.rs:233:26
|
LL | &mut Either::One(_t) => (),
| ^^
note: move occurs because `_t` has type `X`, which does not implement the `Copy` trait
--> $DIR/dont-suggest-ref.rs:236:26
|
...
LL | &mut Either::Two(_t) => (),
| ^^
help: consider removing the `&mut`
...
...
@@ -825,16 +823,11 @@ LL | let &(X(_t), X(_u)) = &(x.clone(), x.clone());
| | data moved here
| help: consider removing the `&`: `(X(_t), X(_u))`
|
note: move occurs because
`_t` has type `Y`, which does no
t implement the `Copy` trait
note: move occurs because
these variables have types that don'
t implement the `Copy` trait
--> $DIR/dont-suggest-ref.rs:347:13
|
LL | let &(X(_t), X(_u)) = &(x.clone(), x.clone());
| ^^
note: move occurs because `_u` has type `Y`, which does not implement the `Copy` trait
--> $DIR/dont-suggest-ref.rs:347:20
|
LL | let &(X(_t), X(_u)) = &(x.clone(), x.clone());
| ^^
| ^^ ^^
error[E0507]: cannot move out of borrowed content
--> $DIR/dont-suggest-ref.rs:351:50
...
...
@@ -846,16 +839,11 @@ LL | if let &(Either::One(_t), Either::Two(_u)) = &(e.clone(), e.clone()) {
| | data moved here
| help: consider removing the `&`: `(Either::One(_t), Either::Two(_u))`
|
note: move occurs because
`_t` has type `X`, which does no
t implement the `Copy` trait
note: move occurs because
these variables have types that don'
t implement the `Copy` trait
--> $DIR/dont-suggest-ref.rs:351:26
|
LL | if let &(Either::One(_t), Either::Two(_u)) = &(e.clone(), e.clone()) { }
| ^^
note: move occurs because `_u` has type `X`, which does not implement the `Copy` trait
--> $DIR/dont-suggest-ref.rs:351:43
|
LL | if let &(Either::One(_t), Either::Two(_u)) = &(e.clone(), e.clone()) { }
| ^^
| ^^ ^^
error[E0507]: cannot move out of borrowed content
--> $DIR/dont-suggest-ref.rs:355:53
...
...
@@ -867,16 +855,11 @@ LL | while let &(Either::One(_t), Either::Two(_u)) = &(e.clone(), e.clone())
| | data moved here
| help: consider removing the `&`: `(Either::One(_t), Either::Two(_u))`
|
note: move occurs because
`_t` has type `X`, which does no
t implement the `Copy` trait
note: move occurs because
these variables have types that don'
t implement the `Copy` trait
--> $DIR/dont-suggest-ref.rs:355:29
|
LL | while let &(Either::One(_t), Either::Two(_u)) = &(e.clone(), e.clone()) { }
| ^^
note: move occurs because `_u` has type `X`, which does not implement the `Copy` trait
--> $DIR/dont-suggest-ref.rs:355:46
|
LL | while let &(Either::One(_t), Either::Two(_u)) = &(e.clone(), e.clone()) { }
| ^^
| ^^ ^^
error[E0507]: cannot move out of borrowed content
--> $DIR/dont-suggest-ref.rs:359:11
...
...
@@ -892,26 +875,14 @@ LL | &(Either::One(_t), Either::Two(_u)) => (),
LL | &(Either::Two(_t), Either::One(_u)) => (),
| -- ... and here -- ... and here
|
note: move occurs because
`_t` has type `X`, which does no
t implement the `Copy` trait
note: move occurs because
these variables have types that don'
t implement the `Copy` trait
--> $DIR/dont-suggest-ref.rs:361:23
|
LL | &(Either::One(_t), Either::Two(_u)) => (),
| ^^
note: move occurs because `_u` has type `X`, which does not implement the `Copy` trait
--> $DIR/dont-suggest-ref.rs:361:40
|
LL | &(Either::One(_t), Either::Two(_u)) => (),
| ^^
note: move occurs because `_t` has type `X`, which does not implement the `Copy` trait
--> $DIR/dont-suggest-ref.rs:364:23
|
LL | &(Either::Two(_t), Either::One(_u)) => (),
| ^^
note: move occurs because `_u` has type `X`, which does not implement the `Copy` trait
--> $DIR/dont-suggest-ref.rs:364:40
|
| ^^ ^^
...
LL | &(Either::Two(_t), Either::One(_u)) => (),
|
^^
|
^^
^^
help: consider removing the `&`
|
LL | (Either::One(_t), Either::Two(_u)) => (),
...
...
@@ -934,16 +905,11 @@ LL | &(Either::One(_t), Either::Two(_u))
| | data moved here
| help: consider removing the `&`: `(Either::One(_t), Either::Two(_u))`
|
note: move occurs because
`_t` has type `X`, which does no
t implement the `Copy` trait
note: move occurs because
these variables have types that don'
t implement the `Copy` trait
--> $DIR/dont-suggest-ref.rs:371:23
|
LL | &(Either::One(_t), Either::Two(_u))
| ^^
note: move occurs because `_u` has type `X`, which does not implement the `Copy` trait
--> $DIR/dont-suggest-ref.rs:371:40
|
LL | &(Either::One(_t), Either::Two(_u))
| ^^
| ^^ ^^
error[E0507]: cannot move out of borrowed content
--> $DIR/dont-suggest-ref.rs:378:11
...
...
@@ -958,16 +924,11 @@ LL | &(Either::One(_t), Either::Two(_u)) => (),
| | data moved here
| help: consider removing the `&`: `(Either::One(_t), Either::Two(_u))`
|
note: move occurs because
`_t` has type `X`, which does no
t implement the `Copy` trait
note: move occurs because
these variables have types that don'
t implement the `Copy` trait
--> $DIR/dont-suggest-ref.rs:380:23
|
LL | &(Either::One(_t), Either::Two(_u)) => (),
| ^^
note: move occurs because `_u` has type `X`, which does not implement the `Copy` trait
--> $DIR/dont-suggest-ref.rs:380:40
|
LL | &(Either::One(_t), Either::Two(_u)) => (),
| ^^
| ^^ ^^
error[E0507]: cannot move out of borrowed content
--> $DIR/dont-suggest-ref.rs:386:11
...
...
@@ -982,16 +943,11 @@ LL | &(Either::One(_t), Either::Two(_u)) => (),
| | data moved here
| help: consider removing the `&`: `(Either::One(_t), Either::Two(_u))`
|
note: move occurs because
`_t` has type `X`, which does no
t implement the `Copy` trait
note: move occurs because
these variables have types that don'
t implement the `Copy` trait
--> $DIR/dont-suggest-ref.rs:388:23
|
LL | &(Either::One(_t), Either::Two(_u)) => (),
| ^^
note: move occurs because `_u` has type `X`, which does not implement the `Copy` trait
--> $DIR/dont-suggest-ref.rs:388:40
|
LL | &(Either::One(_t), Either::Two(_u)) => (),
| ^^
| ^^ ^^
error[E0507]: cannot move out of borrowed content
--> $DIR/dont-suggest-ref.rs:399:31
...
...
@@ -1003,16 +959,11 @@ LL | let &mut (X(_t), X(_u)) = &mut (xm.clone(), xm.clone());
| | data moved here
| help: consider removing the `&mut`: `(X(_t), X(_u))`
|
note: move occurs because
`_t` has type `Y`, which does no
t implement the `Copy` trait
note: move occurs because
these variables have types that don'
t implement the `Copy` trait
--> $DIR/dont-suggest-ref.rs:399:17
|
LL | let &mut (X(_t), X(_u)) = &mut (xm.clone(), xm.clone());
| ^^
note: move occurs because `_u` has type `Y`, which does not implement the `Copy` trait
--> $DIR/dont-suggest-ref.rs:399:24
|
LL | let &mut (X(_t), X(_u)) = &mut (xm.clone(), xm.clone());
| ^^
| ^^ ^^
error[E0507]: cannot move out of borrowed content
--> $DIR/dont-suggest-ref.rs:403:54
...
...
@@ -1024,16 +975,11 @@ LL | if let &mut (Either::One(_t), Either::Two(_u)) = &mut (em.clone(), em.c
| | data moved here
| help: consider removing the `&mut`: `(Either::One(_t), Either::Two(_u))`
|
note: move occurs because
`_t` has type `X`, which does no
t implement the `Copy` trait
note: move occurs because
these variables have types that don'
t implement the `Copy` trait
--> $DIR/dont-suggest-ref.rs:403:30
|
LL | if let &mut (Either::One(_t), Either::Two(_u)) = &mut (em.clone(), em.clone()) { }
| ^^
note: move occurs because `_u` has type `X`, which does not implement the `Copy` trait
--> $DIR/dont-suggest-ref.rs:403:47
|
LL | if let &mut (Either::One(_t), Either::Two(_u)) = &mut (em.clone(), em.clone()) { }
| ^^
| ^^ ^^
error[E0507]: cannot move out of borrowed content
--> $DIR/dont-suggest-ref.rs:407:57
...
...
@@ -1045,16 +991,11 @@ LL | while let &mut (Either::One(_t), Either::Two(_u)) = &mut (em.clone(), e
| | data moved here
| help: consider removing the `&mut`: `(Either::One(_t), Either::Two(_u))`
|
note: move occurs because
`_t` has type `X`, which does no
t implement the `Copy` trait
note: move occurs because
these variables have types that don'
t implement the `Copy` trait
--> $DIR/dont-suggest-ref.rs:407:33
|
LL | while let &mut (Either::One(_t), Either::Two(_u)) = &mut (em.clone(), em.clone()) { }
| ^^
note: move occurs because `_u` has type `X`, which does not implement the `Copy` trait
--> $DIR/dont-suggest-ref.rs:407:50
|
LL | while let &mut (Either::One(_t), Either::Two(_u)) = &mut (em.clone(), em.clone()) { }
| ^^
| ^^ ^^
error[E0507]: cannot move out of borrowed content
--> $DIR/dont-suggest-ref.rs:411:11
...
...
@@ -1070,26 +1011,14 @@ LL | &mut (Either::One(_t), Either::Two(_u)) => (),
LL | &mut (Either::Two(_t), Either::One(_u)) => (),
| -- ... and here -- ... and here
|
note: move occurs because
`_t` has type `X`, which does no
t implement the `Copy` trait
note: move occurs because
these variables have types that don'
t implement the `Copy` trait
--> $DIR/dont-suggest-ref.rs:413:27
|
LL | &mut (Either::One(_t), Either::Two(_u)) => (),
| ^^
note: move occurs because `_u` has type `X`, which does not implement the `Copy` trait
--> $DIR/dont-suggest-ref.rs:413:44
|
LL | &mut (Either::One(_t), Either::Two(_u)) => (),
| ^^
note: move occurs because `_t` has type `X`, which does not implement the `Copy` trait
--> $DIR/dont-suggest-ref.rs:416:27
|
LL | &mut (Either::Two(_t), Either::One(_u)) => (),
| ^^
note: move occurs because `_u` has type `X`, which does not implement the `Copy` trait
--> $DIR/dont-suggest-ref.rs:416:44
|
| ^^ ^^
...
LL | &mut (Either::Two(_t), Either::One(_u)) => (),
|
^^
|
^^
^^
help: consider removing the `&mut`
|
LL | (Either::One(_t), Either::Two(_u)) => (),
...
...
@@ -1112,16 +1041,11 @@ LL | &mut (Either::One(_t), Either::Two(_u))
| | data moved here
| help: consider removing the `&mut`: `(Either::One(_t), Either::Two(_u))`
|
note: move occurs because
`_t` has type `X`, which does no
t implement the `Copy` trait
note: move occurs because
these variables have types that don'
t implement the `Copy` trait
--> $DIR/dont-suggest-ref.rs:423:27
|
LL | &mut (Either::One(_t), Either::Two(_u))
| ^^
note: move occurs because `_u` has type `X`, which does not implement the `Copy` trait
--> $DIR/dont-suggest-ref.rs:423:44
|
LL | &mut (Either::One(_t), Either::Two(_u))
| ^^
| ^^ ^^
error[E0507]: cannot move out of borrowed content
--> $DIR/dont-suggest-ref.rs:430:11
...
...
@@ -1136,16 +1060,11 @@ LL | &mut (Either::One(_t), Either::Two(_u)) => (),
| | data moved here
| help: consider removing the `&mut`: `(Either::One(_t), Either::Two(_u))`
|
note: move occurs because
`_t` has type `X`, which does no
t implement the `Copy` trait
note: move occurs because
these variables have types that don'
t implement the `Copy` trait
--> $DIR/dont-suggest-ref.rs:432:27
|
LL | &mut (Either::One(_t), Either::Two(_u)) => (),
| ^^
note: move occurs because `_u` has type `X`, which does not implement the `Copy` trait
--> $DIR/dont-suggest-ref.rs:432:44
|
LL | &mut (Either::One(_t), Either::Two(_u)) => (),
| ^^
| ^^ ^^
error[E0507]: cannot move out of borrowed content
--> $DIR/dont-suggest-ref.rs:438:11
...
...
@@ -1160,16 +1079,11 @@ LL | &mut (Either::One(_t), Either::Two(_u)) => (),
| | data moved here
| help: consider removing the `&mut`: `(Either::One(_t), Either::Two(_u))`
|
note: move occurs because
`_t` has type `X`, which does no
t implement the `Copy` trait
note: move occurs because
these variables have types that don'
t implement the `Copy` trait
--> $DIR/dont-suggest-ref.rs:440:27
|
LL | &mut (Either::One(_t), Either::Two(_u)) => (),
| ^^
note: move occurs because `_u` has type `X`, which does not implement the `Copy` trait
--> $DIR/dont-suggest-ref.rs:440:44
|
LL | &mut (Either::One(_t), Either::Two(_u)) => (),
| ^^
| ^^ ^^
error[E0507]: cannot move out of borrowed content
--> $DIR/dont-suggest-ref.rs:446:11
...
...
@@ -1184,16 +1098,11 @@ LL | &mut (Either::One(_t), Either::Two(_u)) => (),
| | data moved here
| help: consider removing the `&mut`: `(Either::One(_t), Either::Two(_u))`
|
note: move occurs because
`_t` has type `X`, which does no
t implement the `Copy` trait
note: move occurs because
these variables have types that don'
t implement the `Copy` trait
--> $DIR/dont-suggest-ref.rs:448:27
|
LL | &mut (Either::One(_t), Either::Two(_u)) => (),
| ^^
note: move occurs because `_u` has type `X`, which does not implement the `Copy` trait
--> $DIR/dont-suggest-ref.rs:448:44
|
LL | &mut (Either::One(_t), Either::Two(_u)) => (),
| ^^
| ^^ ^^
error[E0507]: cannot move out of borrowed content
--> $DIR/dont-suggest-ref.rs:214:11
...
...
@@ -1238,16 +1147,11 @@ LL | fn f3(&(X(_t), X(_u)): &(X, X)) { }
| cannot move out of borrowed content
| help: consider removing the `&`: `(X(_t), X(_u))`
|
note: move occurs because
`_t` has type `Y`, which does no
t implement the `Copy` trait
note: move occurs because
these variables have types that don'
t implement the `Copy` trait
--> $DIR/dont-suggest-ref.rs:394:15
|
LL | fn f3(&(X(_t), X(_u)): &(X, X)) { }
| ^^
note: move occurs because `_u` has type `Y`, which does not implement the `Copy` trait
--> $DIR/dont-suggest-ref.rs:394:22
|
LL | fn f3(&(X(_t), X(_u)): &(X, X)) { }
| ^^
| ^^ ^^
error[E0507]: cannot move out of borrowed content
--> $DIR/dont-suggest-ref.rs:454:11
...
...
@@ -1260,16 +1164,11 @@ LL | fn f4(&mut (X(_t), X(_u)): &mut (X, X)) { }
| cannot move out of borrowed content
| help: consider removing the `&mut`: `(X(_t), X(_u))`
|
note: move occurs because
`_t` has type `Y`, which does no
t implement the `Copy` trait
note: move occurs because
these variables have types that don'
t implement the `Copy` trait
--> $DIR/dont-suggest-ref.rs:454:19
|
LL | fn f4(&mut (X(_t), X(_u)): &mut (X, X)) { }
| ^^
note: move occurs because `_u` has type `Y`, which does not implement the `Copy` trait
--> $DIR/dont-suggest-ref.rs:454:26
|
LL | fn f4(&mut (X(_t), X(_u)): &mut (X, X)) { }
| ^^
| ^^ ^^
error: aborting due to 67 previous errors
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录