Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
eef34a64
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,发现更多精彩内容 >>
提交
eef34a64
编写于
7月 01, 2022
作者:
L
lcnr
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
stop suggesting things inside of macros
上级
f1836c45
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
29 addition
and
10 deletion
+29
-10
compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs
...r/rustc_infer/src/infer/error_reporting/need_type_info.rs
+23
-2
src/test/ui/type/type-check/cannot_infer_local_or_vec_in_tuples.stderr
...ype/type-check/cannot_infer_local_or_vec_in_tuples.stderr
+6
-8
未找到文件。
compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs
浏览文件 @
eef34a64
...
...
@@ -532,6 +532,22 @@ enum InferSourceKind<'tcx> {
},
}
impl
<
'tcx
>
InferSource
<
'tcx
>
{
/// Returns the span where we're going to insert our suggestion.
///
/// Used when computing the cost of this infer source to check whether
/// we're inside of a macro expansion.
fn
main_insert_span
(
&
self
)
->
Span
{
match
self
.kind
{
InferSourceKind
::
LetBinding
{
insert_span
,
..
}
=>
insert_span
,
InferSourceKind
::
ClosureArg
{
insert_span
,
..
}
=>
insert_span
,
InferSourceKind
::
GenericArg
{
insert_span
,
..
}
=>
insert_span
,
InferSourceKind
::
FullyQualifiedMethodCall
{
receiver
,
..
}
=>
receiver
.span
,
InferSourceKind
::
ClosureReturn
{
data
,
..
}
=>
data
.span
(),
}
}
}
impl
<
'tcx
>
InferSourceKind
<
'tcx
>
{
fn
ty_msg
(
&
self
,
infcx
:
&
InferCtxt
<
'_
,
'tcx
>
)
->
String
{
match
*
self
{
...
...
@@ -638,7 +654,7 @@ fn ty_cost(self, ty: Ty<'tcx>) -> usize {
// The sources are listed in order of preference here.
let
tcx
=
self
.infcx.tcx
;
let
ctx
=
CostCtxt
{
tcx
};
match
source
.kind
{
let
base_cost
=
match
source
.kind
{
InferSourceKind
::
LetBinding
{
ty
,
..
}
=>
ctx
.ty_cost
(
ty
),
InferSourceKind
::
ClosureArg
{
ty
,
..
}
=>
ctx
.ty_cost
(
ty
),
InferSourceKind
::
GenericArg
{
def_id
,
generic_args
,
..
}
=>
{
...
...
@@ -655,7 +671,12 @@ fn ty_cost(self, ty: Ty<'tcx>) -> usize {
InferSourceKind
::
ClosureReturn
{
ty
,
should_wrap_expr
,
..
}
=>
{
30
+
ctx
.ty_cost
(
ty
)
+
if
should_wrap_expr
.is_some
()
{
10
}
else
{
0
}
}
}
};
let
suggestion_may_apply
=
if
source
.main_insert_span
()
.can_be_used_for_suggestions
()
{
0
}
else
{
10000
};
base_cost
+
suggestion_may_apply
}
/// Uses `fn source_cost` to determine whether this inference source is preferable to
...
...
src/test/ui/type/type-check/cannot_infer_local_or_vec_in_tuples.stderr
浏览文件 @
eef34a64
error[E0282]: type annotations needed
--> $DIR/cannot_infer_local_or_vec_in_tuples.rs:2:
18
error[E0282]: type annotations needed
for `(Vec<T>,)`
--> $DIR/cannot_infer_local_or_vec_in_tuples.rs:2:
9
|
LL | let (x, ) = (vec![], );
|
^^^^^^ cannot infer type of the type parameter `T` declared on the struct `Vec`
|
^^^^^
|
= note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider specifying the generic argument
--> $SRC_DIR/alloc/src/macros.rs:LL:COL
help: consider giving this pattern a type, where the type for type parameter `T` is specified
|
LL |
$crate::__rust_force_expr!($crate::vec::Vec::<T>::new())
|
+++++
LL |
let (x, ): (Vec<T>,) = (vec![], );
|
++++++
+++++
error: aborting due to previous error
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录