Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
688cbad9
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,发现更多精彩内容 >>
提交
688cbad9
编写于
3月 25, 2019
作者:
V
varkor
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Lookup region variable origin instead of choosing one
上级
2d48ffa9
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
18 addition
and
15 deletion
+18
-15
src/librustc/infer/fudge.rs
src/librustc/infer/fudge.rs
+6
-9
src/librustc/infer/region_constraints/mod.rs
src/librustc/infer/region_constraints/mod.rs
+10
-3
src/librustc_typeck/check/mod.rs
src/librustc_typeck/check/mod.rs
+2
-3
未找到文件。
src/librustc/infer/fudge.rs
浏览文件 @
688cbad9
...
...
@@ -50,13 +50,12 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
/// unified.
pub
fn
fudge_inference_if_ok
<
T
,
E
,
F
>
(
&
self
,
origin
:
&
RegionVariableOrigin
,
f
:
F
,
)
->
Result
<
T
,
E
>
where
F
:
FnOnce
()
->
Result
<
T
,
E
>
,
T
:
TypeFoldable
<
'tcx
>
,
{
debug!
(
"fudge_inference_if_ok(
origin={:?})"
,
origin
);
debug!
(
"fudge_inference_if_ok(
)"
);
let
(
mut
fudger
,
value
)
=
self
.probe
(|
snapshot
|
{
match
f
()
{
...
...
@@ -88,7 +87,6 @@ pub fn fudge_inference_if_ok<T, E, F>(
int_vars
,
float_vars
,
region_vars
,
origin
,
};
Ok
((
fudger
,
value
))
...
...
@@ -120,8 +118,7 @@ pub struct InferenceFudger<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
type_vars
:
FxHashMap
<
TyVid
,
TypeVariableOrigin
>
,
int_vars
:
Range
<
IntVid
>
,
float_vars
:
Range
<
FloatVid
>
,
region_vars
:
Range
<
RegionVid
>
,
origin
:
&
'a
RegionVariableOrigin
,
region_vars
:
FxHashMap
<
RegionVid
,
RegionVariableOrigin
>
,
}
impl
<
'a
,
'gcx
,
'tcx
>
TypeFolder
<
'gcx
,
'tcx
>
for
InferenceFudger
<
'a
,
'gcx
,
'tcx
>
{
...
...
@@ -167,11 +164,11 @@ fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> {
}
fn
fold_region
(
&
mut
self
,
r
:
ty
::
Region
<
'tcx
>
)
->
ty
::
Region
<
'tcx
>
{
match
*
r
{
ty
::
ReVar
(
vid
)
if
self
.region_vars
.contains
(
&
vid
)
=>
{
self
.infcx
.next_region_var
(
self
.origin
.clone
())
if
let
ty
::
ReVar
(
vid
)
=
r
{
if
let
Some
(
&
origin
)
=
self
.region_vars
.get
(
&
vid
)
{
return
self
.infcx
.next_region_var
(
origin
);
}
_
=>
r
,
}
r
}
}
src/librustc/infer/region_constraints/mod.rs
浏览文件 @
688cbad9
...
...
@@ -16,7 +16,6 @@
use
std
::
collections
::
BTreeMap
;
use
std
::{
cmp
,
fmt
,
mem
,
u32
};
use
std
::
ops
::
Range
;
mod
leak_check
;
...
...
@@ -841,8 +840,16 @@ pub fn universe(&self, region: Region<'tcx>) -> ty::UniverseIndex {
}
}
pub
fn
vars_since_snapshot
(
&
self
,
mark
:
&
RegionSnapshot
)
->
Range
<
RegionVid
>
{
self
.unification_table
.vars_since_snapshot
(
&
mark
.region_snapshot
)
pub
fn
vars_since_snapshot
(
&
self
,
mark
:
&
RegionSnapshot
,
)
->
FxHashMap
<
RegionVid
,
RegionVariableOrigin
>
{
let
range
=
self
.unification_table
.vars_since_snapshot
(
&
mark
.region_snapshot
);
(
range
.start
.index
()
..
range
.end
.index
())
.map
(|
index
|
{
let
vid
=
ty
::
RegionVid
::
from
(
index
);
let
origin
=
self
.var_infos
[
vid
]
.origin
.clone
();
(
vid
,
origin
)
})
.collect
()
}
/// See [`RegionInference::region_constraints_added_in_snapshot`].
...
...
src/librustc_typeck/check/mod.rs
浏览文件 @
688cbad9
...
...
@@ -92,7 +92,7 @@
use
rustc
::
hir
::
itemlikevisit
::
ItemLikeVisitor
;
use
crate
::
middle
::
lang_items
;
use
crate
::
namespace
::
Namespace
;
use
rustc
::
infer
::{
self
,
InferCtxt
,
InferOk
,
InferResult
,
RegionVariableOrigin
};
use
rustc
::
infer
::{
self
,
InferCtxt
,
InferOk
,
InferResult
};
use
rustc
::
infer
::
canonical
::{
Canonical
,
OriginalQueryValues
,
QueryResponse
};
use
rustc_data_structures
::
indexed_vec
::
Idx
;
use
rustc_data_structures
::
sync
::
Lrc
;
...
...
@@ -3229,8 +3229,7 @@ fn expected_inputs_for_expected_output(&self,
Some
(
ret
)
=>
ret
,
None
=>
return
Vec
::
new
()
};
let
origin
=
RegionVariableOrigin
::
Coercion
(
call_span
);
let
expect_args
=
self
.fudge_inference_if_ok
(
&
origin
,
||
{
let
expect_args
=
self
.fudge_inference_if_ok
(||
{
// 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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录