Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
d38dc68a
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,发现更多精彩内容 >>
提交
d38dc68a
编写于
10月 19, 2022
作者:
M
Michael Goulet
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use already checked RHS ty for LHS deref suggestions
上级
a24a020e
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
219 addition
and
5 deletion
+219
-5
compiler/rustc_hir_analysis/src/check/expr.rs
compiler/rustc_hir_analysis/src/check/expr.rs
+6
-5
src/test/ui/typeck/slow-lhs-suggestion.rs
src/test/ui/typeck/slow-lhs-suggestion.rs
+26
-0
src/test/ui/typeck/slow-lhs-suggestion.stderr
src/test/ui/typeck/slow-lhs-suggestion.stderr
+187
-0
未找到文件。
compiler/rustc_hir_analysis/src/check/expr.rs
浏览文件 @
d38dc68a
...
...
@@ -1130,11 +1130,6 @@ fn check_expr_assign(
}
};
self
.check_lhs_assignable
(
lhs
,
"E0070"
,
span
,
|
err
|
{
let
rhs_ty
=
self
.check_expr
(
&
rhs
);
suggest_deref_binop
(
err
,
rhs_ty
);
});
// This is (basically) inlined `check_expr_coercable_to_type`, but we want
// to suggest an additional fixup here in `suggest_deref_binop`.
let
rhs_ty
=
self
.check_expr_with_hint
(
&
rhs
,
lhs_ty
);
...
...
@@ -1145,6 +1140,12 @@ fn check_expr_assign(
diag
.emit
();
}
self
.check_lhs_assignable
(
lhs
,
"E0070"
,
span
,
|
err
|
{
if
let
Some
(
rhs_ty
)
=
self
.typeck_results
.borrow
()
.expr_ty_opt
(
rhs
)
{
suggest_deref_binop
(
err
,
rhs_ty
);
}
});
self
.require_type_is_sized
(
lhs_ty
,
lhs
.span
,
traits
::
AssignmentLhsSized
);
if
lhs_ty
.references_error
()
||
rhs_ty
.references_error
()
{
...
...
src/test/ui/typeck/slow-lhs-suggestion.rs
0 → 100644
浏览文件 @
d38dc68a
fn
main
()
{
1
=
1
=
1
=
1
=
1
=
1
=
1
=
1
=
1
=
1
=
1
=
1
=
1
=
1
=
1
=
1
=
1
=
1
=
1
=
1
=
1
=
1
=
1
=
1
;
//~^ ERROR invalid left-hand side of assignment
//~| ERROR invalid left-hand side of assignment
//~| ERROR invalid left-hand side of assignment
//~| ERROR invalid left-hand side of assignment
//~| ERROR invalid left-hand side of assignment
//~| ERROR invalid left-hand side of assignment
//~| ERROR invalid left-hand side of assignment
//~| ERROR invalid left-hand side of assignment
//~| ERROR invalid left-hand side of assignment
//~| ERROR invalid left-hand side of assignment
//~| ERROR invalid left-hand side of assignment
//~| ERROR invalid left-hand side of assignment
//~| ERROR invalid left-hand side of assignment
//~| ERROR invalid left-hand side of assignment
//~| ERROR invalid left-hand side of assignment
//~| ERROR invalid left-hand side of assignment
//~| ERROR invalid left-hand side of assignment
//~| ERROR invalid left-hand side of assignment
//~| ERROR invalid left-hand side of assignment
//~| ERROR invalid left-hand side of assignment
//~| ERROR invalid left-hand side of assignment
//~| ERROR invalid left-hand side of assignment
//~| ERROR invalid left-hand side of assignment
}
src/test/ui/typeck/slow-lhs-suggestion.stderr
0 → 100644
浏览文件 @
d38dc68a
error[E0070]: invalid left-hand side of assignment
--> $DIR/slow-lhs-suggestion.rs:2:95
|
LL | 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1;
| - ^
| |
| cannot assign to this expression
error[E0070]: invalid left-hand side of assignment
--> $DIR/slow-lhs-suggestion.rs:2:91
|
LL | 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1;
| - ^
| |
| cannot assign to this expression
error[E0070]: invalid left-hand side of assignment
--> $DIR/slow-lhs-suggestion.rs:2:87
|
LL | 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1;
| - ^
| |
| cannot assign to this expression
error[E0070]: invalid left-hand side of assignment
--> $DIR/slow-lhs-suggestion.rs:2:83
|
LL | 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1;
| - ^
| |
| cannot assign to this expression
error[E0070]: invalid left-hand side of assignment
--> $DIR/slow-lhs-suggestion.rs:2:79
|
LL | 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1;
| - ^
| |
| cannot assign to this expression
error[E0070]: invalid left-hand side of assignment
--> $DIR/slow-lhs-suggestion.rs:2:75
|
LL | 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1;
| - ^
| |
| cannot assign to this expression
error[E0070]: invalid left-hand side of assignment
--> $DIR/slow-lhs-suggestion.rs:2:71
|
LL | 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1;
| - ^
| |
| cannot assign to this expression
error[E0070]: invalid left-hand side of assignment
--> $DIR/slow-lhs-suggestion.rs:2:67
|
LL | 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1;
| - ^
| |
| cannot assign to this expression
error[E0070]: invalid left-hand side of assignment
--> $DIR/slow-lhs-suggestion.rs:2:63
|
LL | 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1;
| - ^
| |
| cannot assign to this expression
error[E0070]: invalid left-hand side of assignment
--> $DIR/slow-lhs-suggestion.rs:2:59
|
LL | 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1;
| - ^
| |
| cannot assign to this expression
error[E0070]: invalid left-hand side of assignment
--> $DIR/slow-lhs-suggestion.rs:2:55
|
LL | 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1;
| - ^
| |
| cannot assign to this expression
error[E0070]: invalid left-hand side of assignment
--> $DIR/slow-lhs-suggestion.rs:2:51
|
LL | 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1;
| - ^
| |
| cannot assign to this expression
error[E0070]: invalid left-hand side of assignment
--> $DIR/slow-lhs-suggestion.rs:2:47
|
LL | 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1;
| - ^
| |
| cannot assign to this expression
error[E0070]: invalid left-hand side of assignment
--> $DIR/slow-lhs-suggestion.rs:2:43
|
LL | 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1;
| - ^
| |
| cannot assign to this expression
error[E0070]: invalid left-hand side of assignment
--> $DIR/slow-lhs-suggestion.rs:2:39
|
LL | 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1;
| - ^
| |
| cannot assign to this expression
error[E0070]: invalid left-hand side of assignment
--> $DIR/slow-lhs-suggestion.rs:2:35
|
LL | 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1;
| - ^
| |
| cannot assign to this expression
error[E0070]: invalid left-hand side of assignment
--> $DIR/slow-lhs-suggestion.rs:2:31
|
LL | 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1;
| - ^
| |
| cannot assign to this expression
error[E0070]: invalid left-hand side of assignment
--> $DIR/slow-lhs-suggestion.rs:2:27
|
LL | 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1;
| - ^
| |
| cannot assign to this expression
error[E0070]: invalid left-hand side of assignment
--> $DIR/slow-lhs-suggestion.rs:2:23
|
LL | 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1;
| - ^
| |
| cannot assign to this expression
error[E0070]: invalid left-hand side of assignment
--> $DIR/slow-lhs-suggestion.rs:2:19
|
LL | 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1;
| - ^
| |
| cannot assign to this expression
error[E0070]: invalid left-hand side of assignment
--> $DIR/slow-lhs-suggestion.rs:2:15
|
LL | 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1;
| - ^
| |
| cannot assign to this expression
error[E0070]: invalid left-hand side of assignment
--> $DIR/slow-lhs-suggestion.rs:2:11
|
LL | 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1;
| - ^
| |
| cannot assign to this expression
error[E0070]: invalid left-hand side of assignment
--> $DIR/slow-lhs-suggestion.rs:2:7
|
LL | 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1;
| - ^
| |
| cannot assign to this expression
error: aborting due to 23 previous errors
For more information about this error, try `rustc --explain E0070`.
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录