Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
2140016d
R
Rust
项目概览
int
/
Rust
11 个月 前同步成功
通知
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,发现更多精彩内容 >>
提交
2140016d
编写于
7月 19, 2021
作者:
L
lcnr
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
don't just compare `ty::Const`
上级
ab9108b7
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
46 addition
and
0 deletion
+46
-0
compiler/rustc_infer/src/infer/combine.rs
compiler/rustc_infer/src/infer/combine.rs
+2
-0
compiler/rustc_middle/src/ty/fold.rs
compiler/rustc_middle/src/ty/fold.rs
+40
-0
compiler/rustc_middle/src/ty/structural_impls.rs
compiler/rustc_middle/src/ty/structural_impls.rs
+4
-0
未找到文件。
compiler/rustc_infer/src/infer/combine.rs
浏览文件 @
2140016d
...
...
@@ -129,6 +129,8 @@ pub fn super_combine_consts<R>(
where
R
:
ConstEquateRelation
<
'tcx
>
,
{
let
a
=
self
.tcx
.expose_default_const_substs
(
a
);
let
b
=
self
.tcx
.expose_default_const_substs
(
b
);
debug!
(
"{}.consts({:?}, {:?})"
,
relation
.tag
(),
a
,
b
);
if
a
==
b
{
return
Ok
(
a
);
...
...
compiler/rustc_middle/src/ty/fold.rs
浏览文件 @
2140016d
...
...
@@ -213,6 +213,10 @@ fn fold_const(&mut self, c: &'tcx ty::Const<'tcx>) -> &'tcx ty::Const<'tcx> {
c
.super_fold_with
(
self
)
}
fn
fold_predicate
(
&
mut
self
,
p
:
ty
::
Predicate
<
'tcx
>
)
->
ty
::
Predicate
<
'tcx
>
{
p
.super_fold_with
(
self
)
}
fn
fold_mir_const
(
&
mut
self
,
c
:
mir
::
ConstantKind
<
'tcx
>
)
->
mir
::
ConstantKind
<
'tcx
>
{
bug!
(
"most type folders should not be folding MIR datastructures: {:?}"
,
c
)
}
...
...
@@ -1205,6 +1209,42 @@ fn visit_predicate(&mut self, predicate: ty::Predicate<'tcx>) -> ControlFlow<Sel
}
}
impl
<
'tcx
>
TyCtxt
<
'tcx
>
{
/// This is a HACK(const_generics) and should probably not be needed.
/// Might however be perf relevant, so who knows.
///
/// FIXME(@lcnr): explain this function a bit more
pub
fn
expose_default_const_substs
<
T
:
TypeFoldable
<
'tcx
>>
(
self
,
v
:
T
)
->
T
{
v
.fold_with
(
&
mut
ExposeDefaultConstSubstsFolder
{
tcx
:
self
})
}
}
struct
ExposeDefaultConstSubstsFolder
<
'tcx
>
{
tcx
:
TyCtxt
<
'tcx
>
,
}
impl
<
'tcx
>
TypeFolder
<
'tcx
>
for
ExposeDefaultConstSubstsFolder
<
'tcx
>
{
fn
tcx
(
&
self
)
->
TyCtxt
<
'tcx
>
{
self
.tcx
}
fn
fold_ty
(
&
mut
self
,
ty
:
Ty
<
'tcx
>
)
->
Ty
<
'tcx
>
{
if
ty
.flags
()
.intersects
(
TypeFlags
::
HAS_UNKNOWN_DEFAULT_CONST_SUBSTS
)
{
ty
.super_fold_with
(
self
)
}
else
{
ty
}
}
fn
fold_predicate
(
&
mut
self
,
pred
:
ty
::
Predicate
<
'tcx
>
)
->
ty
::
Predicate
<
'tcx
>
{
if
pred
.inner.flags
.intersects
(
TypeFlags
::
HAS_UNKNOWN_DEFAULT_CONST_SUBSTS
)
{
pred
.super_fold_with
(
self
)
}
else
{
pred
}
}
}
/// Collects all the late-bound regions at the innermost binding level
/// into a hash set.
struct
LateBoundRegionsCollector
<
'tcx
>
{
...
...
compiler/rustc_middle/src/ty/structural_impls.rs
浏览文件 @
2140016d
...
...
@@ -974,6 +974,10 @@ fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::Br
}
impl
<
'tcx
>
TypeFoldable
<
'tcx
>
for
ty
::
Predicate
<
'tcx
>
{
fn
fold_with
<
F
:
TypeFolder
<
'tcx
>>
(
self
,
folder
:
&
mut
F
)
->
Self
{
folder
.fold_predicate
(
self
)
}
fn
super_fold_with
<
F
:
TypeFolder
<
'tcx
>>
(
self
,
folder
:
&
mut
F
)
->
Self
{
let
new
=
self
.inner.kind
.fold_with
(
folder
);
folder
.tcx
()
.reuse_or_mk_predicate
(
self
,
new
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录