Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
6755b2da
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,发现更多精彩内容 >>
提交
6755b2da
编写于
7月 19, 2021
作者:
L
lcnr
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
ignore const substs in `implicit_infer`
上级
caa975c8
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
28 addition
and
10 deletion
+28
-10
compiler/rustc_middle/src/ty/walk.rs
compiler/rustc_middle/src/ty/walk.rs
+22
-9
compiler/rustc_typeck/src/outlives/implicit_infer.rs
compiler/rustc_typeck/src/outlives/implicit_infer.rs
+6
-1
未找到文件。
compiler/rustc_middle/src/ty/walk.rs
浏览文件 @
6755b2da
...
...
@@ -11,7 +11,7 @@
type
TypeWalkerStack
<
'tcx
>
=
SmallVec
<
[
GenericArg
<
'tcx
>
;
8
]
>
;
pub
struct
TypeWalker
<
'tcx
>
{
tcx
:
TyCtxt
<
'tcx
>
,
expose_default_const_substs
:
Option
<
TyCtxt
<
'tcx
>
>
,
stack
:
TypeWalkerStack
<
'tcx
>
,
last_subtree
:
usize
,
pub
visited
:
SsoHashSet
<
GenericArg
<
'tcx
>>
,
...
...
@@ -26,8 +26,13 @@ pub struct TypeWalker<'tcx> {
/// It maintains a set of visited types and
/// skips any types that are already there.
impl
<
'tcx
>
TypeWalker
<
'tcx
>
{
fn
new
(
tcx
:
TyCtxt
<
'tcx
>
,
root
:
GenericArg
<
'tcx
>
)
->
Self
{
Self
{
tcx
,
stack
:
smallvec!
[
root
],
last_subtree
:
1
,
visited
:
SsoHashSet
::
new
()
}
fn
new
(
expose_default_const_substs
:
Option
<
TyCtxt
<
'tcx
>>
,
root
:
GenericArg
<
'tcx
>
)
->
Self
{
Self
{
expose_default_const_substs
,
stack
:
smallvec!
[
root
],
last_subtree
:
1
,
visited
:
SsoHashSet
::
new
(),
}
}
/// Skips the subtree corresponding to the last type
...
...
@@ -56,7 +61,7 @@ fn next(&mut self) -> Option<GenericArg<'tcx>> {
let
next
=
self
.stack
.pop
()
?
;
self
.last_subtree
=
self
.stack
.len
();
if
self
.visited
.insert
(
next
)
{
push_inner
(
self
.
tcx
,
&
mut
self
.stack
,
next
);
push_inner
(
self
.
expose_default_const_substs
,
&
mut
self
.stack
,
next
);
debug!
(
"next: stack={:?}"
,
self
.stack
);
return
Some
(
next
);
}
...
...
@@ -76,7 +81,7 @@ impl GenericArg<'tcx> {
/// [isize] => { [isize], isize }
/// ```
pub
fn
walk
(
self
,
tcx
:
TyCtxt
<
'tcx
>
)
->
TypeWalker
<
'tcx
>
{
TypeWalker
::
new
(
tcx
,
self
)
TypeWalker
::
new
(
Some
(
tcx
)
,
self
)
}
/// Iterator that walks the immediate children of `self`. Hence
...
...
@@ -92,13 +97,17 @@ pub fn walk_shallow(
visited
:
&
mut
SsoHashSet
<
GenericArg
<
'tcx
>>
,
)
->
impl
Iterator
<
Item
=
GenericArg
<
'tcx
>>
{
let
mut
stack
=
SmallVec
::
new
();
push_inner
(
tcx
,
&
mut
stack
,
self
);
push_inner
(
Some
(
tcx
)
,
&
mut
stack
,
self
);
stack
.retain
(|
a
|
visited
.insert
(
*
a
));
stack
.into_iter
()
}
}
impl
<
'tcx
>
super
::
TyS
<
'tcx
>
{
pub
fn
walk_ignoring_default_const_substs
(
&
'tcx
self
)
->
TypeWalker
<
'tcx
>
{
TypeWalker
::
new
(
None
,
self
.into
())
}
/// Iterator that walks `self` and any types reachable from
/// `self`, in depth-first order. Note that just walks the types
/// that appear in `self`, it does not descend into the fields of
...
...
@@ -110,7 +119,7 @@ impl<'tcx> super::TyS<'tcx> {
/// [isize] => { [isize], isize }
/// ```
pub
fn
walk
(
&
'tcx
self
,
tcx
:
TyCtxt
<
'tcx
>
)
->
TypeWalker
<
'tcx
>
{
TypeWalker
::
new
(
tcx
,
self
.into
())
TypeWalker
::
new
(
Some
(
tcx
)
,
self
.into
())
}
}
...
...
@@ -121,7 +130,7 @@ pub fn walk(&'tcx self, tcx: TyCtxt<'tcx>) -> TypeWalker<'tcx> {
/// natural order one would expect (basically, the order of the
/// types as they are written).
fn
push_inner
<
'tcx
>
(
tcx
:
TyCtxt
<
'tcx
>
,
expose_default_const_substs
:
Option
<
TyCtxt
<
'tcx
>
>
,
stack
:
&
mut
TypeWalkerStack
<
'tcx
>
,
parent
:
GenericArg
<
'tcx
>
,
)
{
...
...
@@ -202,7 +211,11 @@ fn push_inner<'tcx>(
|
ty
::
ConstKind
::
Error
(
_
)
=>
{}
ty
::
ConstKind
::
Unevaluated
(
ct
)
=>
{
stack
.extend
(
ct
.substs
(
tcx
)
.iter
()
.rev
());
if
let
Some
(
tcx
)
=
expose_default_const_substs
{
stack
.extend
(
ct
.substs
(
tcx
)
.iter
()
.rev
());
}
else
if
let
Some
(
substs
)
=
ct
.substs_
{
stack
.extend
(
substs
.iter
()
.rev
());
}
}
}
}
...
...
compiler/rustc_typeck/src/outlives/implicit_infer.rs
浏览文件 @
6755b2da
...
...
@@ -114,7 +114,12 @@ fn insert_required_predicates_to_be_wf<'tcx>(
required_predicates
:
&
mut
RequiredPredicates
<
'tcx
>
,
explicit_map
:
&
mut
ExplicitPredicatesMap
<
'tcx
>
,
)
{
for
arg
in
field_ty
.walk
(
tcx
)
{
// We must not look into the default substs of consts
// as computing those depends on the results of `predicates_of`.
//
// Luckily the only types contained in default substs are type
// parameters which don't matter here.
for
arg
in
field_ty
.walk_ignoring_default_const_substs
()
{
let
ty
=
match
arg
.unpack
()
{
GenericArgKind
::
Type
(
ty
)
=>
ty
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录