Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
1f9a2326
R
Rust
项目概览
int
/
Rust
12 个月 前同步成功
通知
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,发现更多精彩内容 >>
提交
1f9a2326
编写于
3月 21, 2019
作者:
V
varkor
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Rename `RegionFudger` to `InferenceFudger`
上级
6cc09fc8
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
8 addition
and
8 deletion
+8
-8
src/librustc/infer/fudge.rs
src/librustc/infer/fudge.rs
+7
-7
src/librustc_typeck/check/mod.rs
src/librustc_typeck/check/mod.rs
+1
-1
未找到文件。
src/librustc/infer/fudge.rs
浏览文件 @
1f9a2326
...
...
@@ -18,7 +18,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
/// from `&[u32; 3]` to `&[u32]` and make the users life more
/// pleasant.
///
/// The way we do this is using `fudge_
regions
_if_ok`. What the
/// The way we do this is using `fudge_
inference
_if_ok`. What the
/// routine actually does is to start a snapshot and execute the
/// closure `f`. In our example above, what this closure will do
/// is to unify the expectation (`Option<&[u32]>`) with the actual
...
...
@@ -27,7 +27,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
/// with `&?a [u32]`, where `?a` is a fresh lifetime variable. The
/// input type (`?T`) is then returned by `f()`.
///
/// At this point, `fudge_
regions
_if_ok` will normalize all type
/// At this point, `fudge_
inference
_if_ok` will normalize all type
/// variables, converting `?T` to `&?a [u32]` and end the
/// snapshot. The problem is that we can't just return this type
/// out, because it references the region variable `?a`, and that
...
...
@@ -46,7 +46,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
/// the actual types (`?T`, `Option<?T>`) -- and remember that
/// after the snapshot is popped, the variable `?T` is no longer
/// unified.
pub
fn
fudge_
regions
_if_ok
<
T
,
E
,
F
>
(
pub
fn
fudge_
inference
_if_ok
<
T
,
E
,
F
>
(
&
self
,
origin
:
&
RegionVariableOrigin
,
f
:
F
,
...
...
@@ -54,7 +54,7 @@ pub fn fudge_regions_if_ok<T, E, F>(
F
:
FnOnce
()
->
Result
<
T
,
E
>
,
T
:
TypeFoldable
<
'tcx
>
,
{
debug!
(
"fudge_
regions
_if_ok(origin={:?})"
,
origin
);
debug!
(
"fudge_
inference
_if_ok(origin={:?})"
,
origin
);
let
(
type_variables
,
region_vars
,
value
)
=
self
.probe
(|
snapshot
|
{
match
f
()
{
...
...
@@ -91,7 +91,7 @@ pub fn fudge_regions_if_ok<T, E, F>(
return
Ok
(
value
);
}
let
mut
fudger
=
Region
Fudger
{
let
mut
fudger
=
Inference
Fudger
{
infcx
:
self
,
type_variables
:
&
type_variables
,
region_vars
:
&
region_vars
,
...
...
@@ -102,14 +102,14 @@ pub fn fudge_regions_if_ok<T, E, F>(
}
}
pub
struct
Region
Fudger
<
'a
,
'gcx
:
'a
+
'tcx
,
'tcx
:
'a
>
{
pub
struct
Inference
Fudger
<
'a
,
'gcx
:
'a
+
'tcx
,
'tcx
:
'a
>
{
infcx
:
&
'a
InferCtxt
<
'a
,
'gcx
,
'tcx
>
,
type_variables
:
&
'a
Range
<
TyVid
>
,
region_vars
:
&
'a
Range
<
RegionVid
>
,
origin
:
&
'a
RegionVariableOrigin
,
}
impl
<
'a
,
'gcx
,
'tcx
>
TypeFolder
<
'gcx
,
'tcx
>
for
Region
Fudger
<
'a
,
'gcx
,
'tcx
>
{
impl
<
'a
,
'gcx
,
'tcx
>
TypeFolder
<
'gcx
,
'tcx
>
for
Inference
Fudger
<
'a
,
'gcx
,
'tcx
>
{
fn
tcx
<
'b
>
(
&
'b
self
)
->
TyCtxt
<
'b
,
'gcx
,
'tcx
>
{
self
.infcx.tcx
}
...
...
src/librustc_typeck/check/mod.rs
浏览文件 @
1f9a2326
...
...
@@ -3231,7 +3231,7 @@ fn expected_inputs_for_expected_output(&self,
Some
(
ret
)
=>
ret
,
None
=>
return
Vec
::
new
()
};
let
expect_args
=
self
.fudge_
regions
_if_ok
(
&
RegionVariableOrigin
::
Coercion
(
call_span
),
||
{
let
expect_args
=
self
.fudge_
inference
_if_ok
(
&
RegionVariableOrigin
::
Coercion
(
call_span
),
||
{
// Attempt to apply a subtyping relationship between the formal
// return type (likely containing type variables if the function
// is polymorphic) and the expected return type.
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录