Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
f3cd4a7f
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,发现更多精彩内容 >>
提交
f3cd4a7f
编写于
12月 13, 2017
作者:
L
leonardo.yvens
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Refactor away `fn default_type_parameters`
It had only one caller.
上级
3d83fc91
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
17 addition
and
29 deletion
+17
-29
src/librustc_typeck/check/mod.rs
src/librustc_typeck/check/mod.rs
+17
-29
未找到文件。
src/librustc_typeck/check/mod.rs
浏览文件 @
f3cd4a7f
...
...
@@ -2127,34 +2127,6 @@ fn resolve_generator_interiors(&self, def_id: DefId) {
}
}
/// Apply "fallbacks" to some types
/// unconstrained types get replaced with ! or () (depending on whether
/// feature(never_type) is enabled), unconstrained ints with i32, and
/// unconstrained floats with f64.
fn
default_type_parameters
(
&
self
)
{
// Defaulting inference variables becomes very dubious if we have
// encountered type-checking errors. Therefore, if we think we saw
// some errors in this function, just resolve all uninstanted type
// varibles to TyError.
if
self
.is_tainted_by_errors
()
{
for
ty
in
&
self
.unsolved_variables
()
{
if
let
ty
::
TyInfer
(
_
)
=
self
.shallow_resolve
(
ty
)
.sty
{
debug!
(
"default_type_parameters: defaulting `{:?}` to error"
,
ty
);
self
.demand_eqtype
(
syntax_pos
::
DUMMY_SP
,
*
ty
,
self
.tcx
()
.types.err
);
}
}
return
;
}
for
ty
in
&
self
.unsolved_variables
()
{
let
resolved
=
self
.resolve_type_vars_if_possible
(
ty
);
if
resolved
.is_ty_infer
()
{
self
.apply_diverging_fallback_to_type
(
ty
);
self
.apply_numeric_fallback_to_type
(
ty
);
}
}
}
fn
apply_diverging_fallback_to_type
(
&
self
,
ty
:
Ty
<
'tcx
>
)
{
assert
!
(
ty
.is_ty_infer
());
if
self
.type_var_diverges
(
ty
)
{
...
...
@@ -2185,7 +2157,23 @@ fn select_all_obligations_or_error(&self) {
assert
!
(
self
.deferred_call_resolutions
.borrow
()
.is_empty
());
self
.select_obligations_where_possible
();
self
.default_type_parameters
();
// Apply fallbacks to unsolved variables.
// Non-numerics get replaced with ! or () (depending on whether
// feature(never_type) is enabled), unconstrained ints with i32,
// unconstrained floats with f64.
for
ty
in
&
self
.unsolved_variables
()
{
if
self
.is_tainted_by_errors
()
{
// Defaulting inference variables becomes very dubious if we have
// encountered type-checking errors. In that case,
// just resolve all uninstanted type variables to TyError.
debug!
(
"default_type_parameters: defaulting `{:?}` to error"
,
ty
);
self
.demand_eqtype
(
syntax_pos
::
DUMMY_SP
,
*
ty
,
self
.tcx
()
.types.err
);
}
else
{
self
.apply_diverging_fallback_to_type
(
ty
);
self
.apply_numeric_fallback_to_type
(
ty
);
}
}
let
mut
fulfillment_cx
=
self
.fulfillment_cx
.borrow_mut
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录