Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
7bf175f3
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,发现更多精彩内容 >>
提交
7bf175f3
编写于
2月 28, 2019
作者:
G
Gabriel Smith
提交者:
varkor
5月 01, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
impl fold_const for RegionFudger
Signed-off-by:
N
Gabriel Smith
<
ga29smith@gmail.com
>
上级
ef1b2acf
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
58 addition
and
1 deletion
+58
-1
src/librustc/infer/const_variable.rs
src/librustc/infer/const_variable.rs
+29
-0
src/librustc/infer/fudge.rs
src/librustc/infer/fudge.rs
+29
-1
未找到文件。
src/librustc/infer/const_variable.rs
浏览文件 @
7bf175f3
...
...
@@ -5,6 +5,7 @@
use
std
::
cmp
;
use
std
::
marker
::
PhantomData
;
use
rustc_data_structures
::
fx
::
FxHashMap
;
use
rustc_data_structures
::
snapshot_vec
as
sv
;
use
rustc_data_structures
::
unify
as
ut
;
...
...
@@ -23,6 +24,8 @@ pub enum ConstVariableOrigin {
SubstitutionPlaceholder
(
Span
),
}
pub
type
ConstVariableMap
<
'tcx
>
=
FxHashMap
<
ty
::
ConstVid
<
'tcx
>
,
ConstVariableOrigin
>
;
struct
ConstVariableData
{
origin
:
ConstVariableOrigin
,
}
...
...
@@ -184,6 +187,32 @@ pub fn commit(&mut self, s: Snapshot<'tcx>) {
self
.values
.commit
(
snapshot
);
self
.relations
.commit
(
relation_snapshot
);
}
/// Returns a map `{V1 -> V2}`, where the keys `{V1}` are
/// const-variables created during the snapshot, and the values
/// `{V2}` are the root variables that they were unified with,
/// along with their origin.
pub
fn
consts_created_since_snapshot
(
&
mut
self
,
s
:
&
Snapshot
<
'tcx
>
)
->
ConstVariableMap
<
'tcx
>
{
let
actions_since_snapshot
=
self
.values
.actions_since_snapshot
(
&
s
.snapshot
);
actions_since_snapshot
.iter
()
.filter_map
(|
action
|
match
action
{
&
sv
::
UndoLog
::
NewElem
(
index
)
=>
Some
(
ty
::
ConstVid
{
index
:
index
as
u32
,
phantom
:
PhantomData
,
}),
_
=>
None
,
})
.map
(|
vid
|
{
let
origin
=
self
.values
.get
(
vid
.index
as
usize
)
.origin
.clone
();
(
vid
,
origin
)
})
.collect
()
}
}
impl
<
'tcx
>
ut
::
UnifyKey
for
ty
::
ConstVid
<
'tcx
>
{
...
...
src/librustc/infer/fudge.rs
浏览文件 @
7bf175f3
use
crate
::
ty
::{
self
,
Ty
,
TyCtxt
,
TyVid
,
IntVid
,
FloatVid
,
RegionVid
};
use
crate
::
ty
::
fold
::{
TypeFoldable
,
TypeFolder
};
use
crate
::
mir
::
interpret
::
ConstValue
;
use
super
::
InferCtxt
;
use
super
::
RegionVariableOrigin
;
...
...
@@ -176,6 +177,33 @@ fn fold_region(&mut self, r: ty::Region<'tcx>) -> ty::Region<'tcx> {
}
fn
fold_const
(
&
mut
self
,
ct
:
&
'tcx
ty
::
LazyConst
<
'tcx
>
)
->
&
'tcx
ty
::
LazyConst
<
'tcx
>
{
ct
// FIXME(const_generics)
if
let
ty
::
LazyConst
::
Evaluated
(
ty
::
Const
{
val
:
ConstValue
::
Infer
(
ty
::
InferConst
::
Var
(
vid
)),
ty
,
})
=
*
ct
{
match
self
.const_variables
.get
(
&
vid
)
{
None
=>
{
// This variable was created before the
// "fudging". Since we refresh all
// variables to their binding anyhow, we know
// that it is unbound, so we can just return
// it.
debug_assert!
(
self
.infcx.const_unification_table
.borrow_mut
()
.probe
(
vid
)
.is_unknown
()
);
ct
}
Some
(
&
origin
)
=>
{
// This variable was created during the
// fudging. Recreate it with a fresh variable
// here.
self
.infcx
.next_const_var
(
ty
,
origin
)
}
}
}
else
{
ct
.super_fold_with
(
self
)
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录