Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
9ffdc2de
R
Rust
项目概览
int
/
Rust
接近 1 年 前同步成功
通知
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,发现更多精彩内容 >>
未验证
提交
9ffdc2de
编写于
6月 17, 2022
作者:
A
Alan Egerton
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
impl TypeVisitable in type traversal macros
上级
e4b9625b
变更
14
显示空白变更内容
内联
并排
Showing
14 changed file
with
57 addition
and
35 deletion
+57
-35
compiler/rustc_middle/src/infer/canonical.rs
compiler/rustc_middle/src/infer/canonical.rs
+2
-2
compiler/rustc_middle/src/macros.rs
compiler/rustc_middle/src/macros.rs
+28
-18
compiler/rustc_middle/src/mir/graph_cyclic_cache.rs
compiler/rustc_middle/src/mir/graph_cyclic_cache.rs
+1
-1
compiler/rustc_middle/src/mir/interpret/error.rs
compiler/rustc_middle/src/mir/interpret/error.rs
+1
-1
compiler/rustc_middle/src/mir/mod.rs
compiler/rustc_middle/src/mir/mod.rs
+2
-2
compiler/rustc_middle/src/mir/predecessors.rs
compiler/rustc_middle/src/mir/predecessors.rs
+1
-1
compiler/rustc_middle/src/mir/switch_sources.rs
compiler/rustc_middle/src/mir/switch_sources.rs
+1
-1
compiler/rustc_middle/src/mir/traversal.rs
compiler/rustc_middle/src/mir/traversal.rs
+1
-1
compiler/rustc_middle/src/mir/type_foldable.rs
compiler/rustc_middle/src/mir/type_foldable.rs
+1
-1
compiler/rustc_middle/src/thir/abstract_const.rs
compiler/rustc_middle/src/thir/abstract_const.rs
+1
-1
compiler/rustc_middle/src/traits/select.rs
compiler/rustc_middle/src/traits/select.rs
+1
-1
compiler/rustc_middle/src/traits/structural_impls.rs
compiler/rustc_middle/src/traits/structural_impls.rs
+1
-1
compiler/rustc_middle/src/ty/binding.rs
compiler/rustc_middle/src/ty/binding.rs
+1
-1
compiler/rustc_middle/src/ty/structural_impls.rs
compiler/rustc_middle/src/ty/structural_impls.rs
+15
-3
未找到文件。
compiler/rustc_middle/src/infer/canonical.rs
浏览文件 @
9ffdc2de
...
...
@@ -293,7 +293,7 @@ pub fn unchecked_map<W>(self, map_op: impl FnOnce(V) -> W) -> Canonical<'tcx, W>
pub
type
QueryOutlivesConstraint
<
'tcx
>
=
ty
::
Binder
<
'tcx
,
ty
::
OutlivesPredicate
<
GenericArg
<
'tcx
>
,
Region
<
'tcx
>>>
;
TrivialType
Foldable
AndLiftImpls!
{
TrivialType
Traversal
AndLiftImpls!
{
for
<
'tcx
>
{
crate
::
infer
::
canonical
::
Certainty
,
crate
::
infer
::
canonical
::
CanonicalVarInfo
<
'tcx
>
,
...
...
@@ -301,7 +301,7 @@ pub fn unchecked_map<W>(self, map_op: impl FnOnce(V) -> W) -> Canonical<'tcx, W>
}
}
TrivialType
Foldable
Impls!
{
TrivialType
Traversal
Impls!
{
for
<
'tcx
>
{
crate
::
infer
::
canonical
::
CanonicalVarInfos
<
'tcx
>
,
}
...
...
compiler/rustc_middle/src/macros.rs
浏览文件 @
9ffdc2de
...
...
@@ -18,7 +18,7 @@
}
///////////////////////////////////////////////////////////////////////////
// Lift and TypeFoldable macros
// Lift and TypeFoldable
/TypeVisitable
macros
//
// When possible, use one of these (relatively) convenient macros to write
// the impls for you.
...
...
@@ -48,7 +48,7 @@ fn lift_to_tcx(self, _: $crate::ty::TyCtxt<$tcx>) -> Option<Self> {
/// Used for types that are `Copy` and which **do not care arena
/// allocated data** (i.e., don't need to be folded).
#[macro_export]
macro_rules!
TrivialType
Foldable
Impls
{
macro_rules!
TrivialType
Traversal
Impls
{
(
for
<
$tcx:lifetime
>
{
$
(
$ty:ty
,)
+
})
=>
{
$
(
impl
<
$tcx
>
$crate
::
ty
::
fold
::
TypeFoldable
<
$tcx
>
for
$ty
{
...
...
@@ -58,8 +58,10 @@ fn try_fold_with<F: $crate::ty::fold::FallibleTypeFolder<$tcx>>(
)
->
::
std
::
result
::
Result
<
$ty
,
F
::
Error
>
{
Ok
(
self
)
}
}
fn
visit_with
<
F
:
$crate
::
ty
::
fold
::
TypeVisitor
<
$tcx
>>
(
impl
<
$tcx
>
$crate
::
ty
::
visit
::
TypeVisitable
<
$tcx
>
for
$ty
{
fn
visit_with
<
F
:
$crate
::
ty
::
visit
::
TypeVisitor
<
$tcx
>>
(
&
self
,
_
:
&
mut
F
)
->
::
std
::
ops
::
ControlFlow
<
F
::
BreakTy
>
...
...
@@ -71,7 +73,7 @@ fn visit_with<F: $crate::ty::fold::TypeVisitor<$tcx>>(
};
(
$
(
$ty:ty
,)
+
)
=>
{
TrivialType
Foldable
Impls!
{
TrivialType
Traversal
Impls!
{
for
<
'tcx
>
{
$
(
$ty
,)
+
}
...
...
@@ -80,15 +82,15 @@ fn visit_with<F: $crate::ty::fold::TypeVisitor<$tcx>>(
}
#[macro_export]
macro_rules!
TrivialType
Foldable
AndLiftImpls
{
macro_rules!
TrivialType
Traversal
AndLiftImpls
{
(
$
(
$t:tt
)
*
)
=>
{
TrivialType
Foldable
Impls!
{
$
(
$t
)
*
}
TrivialType
Traversal
Impls!
{
$
(
$t
)
*
}
CloneLiftImpls!
{
$
(
$t
)
*
}
}
}
#[macro_export]
macro_rules!
EnumType
Foldable
Impl
{
macro_rules!
EnumType
Traversal
Impl
{
(
impl
<
$
(
$p:tt
),
*>
TypeFoldable
<
$tcx:tt
>
for
$s:path
{
$
(
$variants:tt
)
*
}
$
(
where
$
(
$wc:tt
)
*
)
*
)
=>
{
...
...
@@ -99,14 +101,22 @@ fn try_fold_with<V: $crate::ty::fold::FallibleTypeFolder<$tcx>>(
self
,
folder
:
&
mut
V
,
)
->
::
std
::
result
::
Result
<
Self
,
V
::
Error
>
{
EnumTypeFoldableImpl!
(
@
FoldVariants
(
self
,
folder
)
input
(
$
(
$variants
)
*
)
output
())
EnumTypeTraversalImpl!
(
@
FoldVariants
(
self
,
folder
)
input
(
$
(
$variants
)
*
)
output
())
}
}
};
fn
visit_with
<
V
:
$crate
::
ty
::
fold
::
TypeVisitor
<
$tcx
>>
(
(
impl
<
$
(
$p:tt
),
*>
TypeVisitable
<
$tcx:tt
>
for
$s:path
{
$
(
$variants:tt
)
*
}
$
(
where
$
(
$wc:tt
)
*
)
*
)
=>
{
impl
<
$
(
$p
),
*>
$crate
::
ty
::
visit
::
TypeVisitable
<
$tcx
>
for
$s
$
(
where
$
(
$wc
)
*
)
*
{
fn
visit_with
<
V
:
$crate
::
ty
::
visit
::
TypeVisitor
<
$tcx
>>
(
&
self
,
visitor
:
&
mut
V
,
)
->
::
std
::
ops
::
ControlFlow
<
V
::
BreakTy
>
{
EnumType
Foldable
Impl!
(
@
VisitVariants
(
self
,
visitor
)
input
(
$
(
$variants
)
*
)
output
())
EnumType
Traversal
Impl!
(
@
VisitVariants
(
self
,
visitor
)
input
(
$
(
$variants
)
*
)
output
())
}
}
};
...
...
@@ -120,7 +130,7 @@ fn visit_with<V: $crate::ty::fold::TypeVisitor<$tcx>>(
(
@
FoldVariants
(
$this:expr
,
$folder:expr
)
input
(
(
$variant:path
)
(
$
(
$variant_arg:ident
),
*
)
,
$
(
$input:tt
)
*
)
output
(
$
(
$output:tt
)
*
)
)
=>
{
EnumType
Foldable
Impl!
(
EnumType
Traversal
Impl!
(
@
FoldVariants
(
$this
,
$folder
)
input
(
$
(
$input
)
*
)
output
(
...
...
@@ -137,7 +147,7 @@ fn visit_with<V: $crate::ty::fold::TypeVisitor<$tcx>>(
(
@
FoldVariants
(
$this:expr
,
$folder:expr
)
input
(
(
$variant:path
)
{
$
(
$variant_arg:ident
),
*
$
(,)
?
}
,
$
(
$input:tt
)
*
)
output
(
$
(
$output:tt
)
*
)
)
=>
{
EnumType
Foldable
Impl!
(
EnumType
Traversal
Impl!
(
@
FoldVariants
(
$this
,
$folder
)
input
(
$
(
$input
)
*
)
output
(
...
...
@@ -155,7 +165,7 @@ fn visit_with<V: $crate::ty::fold::TypeVisitor<$tcx>>(
(
@
FoldVariants
(
$this:expr
,
$folder:expr
)
input
(
(
$variant:path
),
$
(
$input:tt
)
*
)
output
(
$
(
$output:tt
)
*
)
)
=>
{
EnumType
Foldable
Impl!
(
EnumType
Traversal
Impl!
(
@
FoldVariants
(
$this
,
$folder
)
input
(
$
(
$input
)
*
)
output
(
...
...
@@ -174,12 +184,12 @@ fn visit_with<V: $crate::ty::fold::TypeVisitor<$tcx>>(
(
@
VisitVariants
(
$this:expr
,
$visitor:expr
)
input
(
(
$variant:path
)
(
$
(
$variant_arg:ident
),
*
)
,
$
(
$input:tt
)
*
)
output
(
$
(
$output:tt
)
*
)
)
=>
{
EnumType
Foldable
Impl!
(
EnumType
Traversal
Impl!
(
@
VisitVariants
(
$this
,
$visitor
)
input
(
$
(
$input
)
*
)
output
(
$variant
(
$
(
$variant_arg
),
*
)
=>
{
$
(
$crate
::
ty
::
fold
::
TypeFold
able
::
visit_with
(
$
(
$crate
::
ty
::
visit
::
TypeVisit
able
::
visit_with
(
$variant_arg
,
$visitor
)
?
;)
*
::
std
::
ops
::
ControlFlow
::
CONTINUE
...
...
@@ -192,12 +202,12 @@ fn visit_with<V: $crate::ty::fold::TypeVisitor<$tcx>>(
(
@
VisitVariants
(
$this:expr
,
$visitor:expr
)
input
(
(
$variant:path
)
{
$
(
$variant_arg:ident
),
*
$
(,)
?
}
,
$
(
$input:tt
)
*
)
output
(
$
(
$output:tt
)
*
)
)
=>
{
EnumType
Foldable
Impl!
(
EnumType
Traversal
Impl!
(
@
VisitVariants
(
$this
,
$visitor
)
input
(
$
(
$input
)
*
)
output
(
$variant
{
$
(
$variant_arg
),
*
}
=>
{
$
(
$crate
::
ty
::
fold
::
TypeFold
able
::
visit_with
(
$
(
$crate
::
ty
::
visit
::
TypeVisit
able
::
visit_with
(
$variant_arg
,
$visitor
)
?
;)
*
::
std
::
ops
::
ControlFlow
::
CONTINUE
...
...
@@ -210,7 +220,7 @@ fn visit_with<V: $crate::ty::fold::TypeVisitor<$tcx>>(
(
@
VisitVariants
(
$this:expr
,
$visitor:expr
)
input
(
(
$variant:path
),
$
(
$input:tt
)
*
)
output
(
$
(
$output:tt
)
*
)
)
=>
{
EnumType
Foldable
Impl!
(
EnumType
Traversal
Impl!
(
@
VisitVariants
(
$this
,
$visitor
)
input
(
$
(
$input
)
*
)
output
(
...
...
compiler/rustc_middle/src/mir/graph_cyclic_cache.rs
浏览文件 @
9ffdc2de
...
...
@@ -58,6 +58,6 @@ fn hash_stable(&self, _: &mut CTX, _: &mut StableHasher) {
}
}
TrivialType
Foldable
AndLiftImpls!
{
TrivialType
Traversal
AndLiftImpls!
{
GraphIsCyclicCache
,
}
compiler/rustc_middle/src/mir/interpret/error.rs
浏览文件 @
9ffdc2de
...
...
@@ -29,7 +29,7 @@ fn from(err: ErrorGuaranteed) -> ErrorHandled {
}
}
TrivialType
Foldable
AndLiftImpls!
{
TrivialType
Traversal
AndLiftImpls!
{
ErrorHandled
,
}
...
...
compiler/rustc_middle/src/mir/mod.rs
浏览文件 @
9ffdc2de
...
...
@@ -762,7 +762,7 @@ pub enum ImplicitSelfKind {
None
,
}
TrivialType
Foldable
AndLiftImpls!
{
BindingForm
<
'tcx
>
,
}
TrivialType
Traversal
AndLiftImpls!
{
BindingForm
<
'tcx
>
,
}
mod
binding_form_impl
{
use
rustc_data_structures
::
stable_hasher
::{
HashStable
,
StableHasher
};
...
...
@@ -2641,7 +2641,7 @@ pub(crate) fn variant(
}
}
TrivialType
Foldable
AndLiftImpls!
{
ProjectionKind
,
}
TrivialType
Traversal
AndLiftImpls!
{
ProjectionKind
,
}
impl
<
'tcx
>
TypeFoldable
<
'tcx
>
for
UserTypeProjection
{
fn
try_fold_with
<
F
:
FallibleTypeFolder
<
'tcx
>>
(
self
,
folder
:
&
mut
F
)
->
Result
<
Self
,
F
::
Error
>
{
...
...
compiler/rustc_middle/src/mir/predecessors.rs
浏览文件 @
9ffdc2de
...
...
@@ -73,6 +73,6 @@ fn hash_stable(&self, _: &mut CTX, _: &mut StableHasher) {
}
}
TrivialType
Foldable
AndLiftImpls!
{
TrivialType
Traversal
AndLiftImpls!
{
PredecessorCache
,
}
compiler/rustc_middle/src/mir/switch_sources.rs
浏览文件 @
9ffdc2de
...
...
@@ -73,6 +73,6 @@ fn hash_stable(&self, _: &mut CTX, _: &mut StableHasher) {
}
}
TrivialType
Foldable
AndLiftImpls!
{
TrivialType
Traversal
AndLiftImpls!
{
SwitchSourceCache
,
}
compiler/rustc_middle/src/mir/traversal.rs
浏览文件 @
9ffdc2de
...
...
@@ -384,6 +384,6 @@ fn hash_stable(&self, _: &mut CTX, _: &mut StableHasher) {
}
}
TrivialType
Foldable
AndLiftImpls!
{
TrivialType
Traversal
AndLiftImpls!
{
PostorderCache
,
}
compiler/rustc_middle/src/mir/type_foldable.rs
浏览文件 @
9ffdc2de
...
...
@@ -4,7 +4,7 @@
use
crate
::
ty
;
use
rustc_data_structures
::
functor
::
IdFunctor
;
TrivialType
Foldable
AndLiftImpls!
{
TrivialType
Traversal
AndLiftImpls!
{
BlockTailInfo
,
MirPhase
,
SourceInfo
,
...
...
compiler/rustc_middle/src/thir/abstract_const.rs
浏览文件 @
9ffdc2de
...
...
@@ -42,7 +42,7 @@ fn from(e: ErrorGuaranteed) -> NotConstEvaluatable {
}
}
TrivialType
Foldable
AndLiftImpls!
{
TrivialType
Traversal
AndLiftImpls!
{
NotConstEvaluatable
,
}
...
...
compiler/rustc_middle/src/traits/select.rs
浏览文件 @
9ffdc2de
...
...
@@ -283,7 +283,7 @@ fn from(e: ErrorGuaranteed) -> OverflowError {
}
}
TrivialType
Foldable
AndLiftImpls!
{
TrivialType
Traversal
AndLiftImpls!
{
OverflowError
,
}
...
...
compiler/rustc_middle/src/traits/structural_impls.rs
浏览文件 @
9ffdc2de
...
...
@@ -129,7 +129,7 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
///////////////////////////////////////////////////////////////////////////
// Lift implementations
TrivialType
Foldable
AndLiftImpls!
{
TrivialType
Traversal
AndLiftImpls!
{
super
::
IfExpressionCause
,
super
::
ImplSourceDiscriminantKindData
,
super
::
ImplSourcePointeeData
,
...
...
compiler/rustc_middle/src/ty/binding.rs
浏览文件 @
9ffdc2de
...
...
@@ -8,7 +8,7 @@ pub enum BindingMode {
BindByValue
(
Mutability
),
}
TrivialType
Foldable
AndLiftImpls!
{
BindingMode
,
}
TrivialType
Traversal
AndLiftImpls!
{
BindingMode
,
}
impl
BindingMode
{
pub
fn
convert
(
ba
:
BindingAnnotation
)
->
BindingMode
{
...
...
compiler/rustc_middle/src/ty/structural_impls.rs
浏览文件 @
9ffdc2de
...
...
@@ -183,7 +183,7 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
// For things that don't carry any arena-allocated data (and are
// copy...), just add them to this list.
TrivialType
Foldable
AndLiftImpls!
{
TrivialType
Traversal
AndLiftImpls!
{
(),
bool
,
usize
,
...
...
@@ -692,19 +692,31 @@ fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::Br
}
}
EnumType
Foldable
Impl!
{
EnumType
Traversal
Impl!
{
impl
<
'tcx
,
T
>
TypeFoldable
<
'tcx
>
for
Option
<
T
>
{
(
Some
)(
a
),
(
None
),
}
where
T
:
TypeFoldable
<
'tcx
>
}
EnumTypeTraversalImpl!
{
impl
<
'tcx
,
T
>
TypeVisitable
<
'tcx
>
for
Option
<
T
>
{
(
Some
)(
a
),
(
None
),
}
where
T
:
TypeVisitable
<
'tcx
>
}
EnumType
Foldable
Impl!
{
EnumType
Traversal
Impl!
{
impl
<
'tcx
,
T
,
E
>
TypeFoldable
<
'tcx
>
for
Result
<
T
,
E
>
{
(
Ok
)(
a
),
(
Err
)(
a
),
}
where
T
:
TypeFoldable
<
'tcx
>
,
E
:
TypeFoldable
<
'tcx
>
,
}
EnumTypeTraversalImpl!
{
impl
<
'tcx
,
T
,
E
>
TypeVisitable
<
'tcx
>
for
Result
<
T
,
E
>
{
(
Ok
)(
a
),
(
Err
)(
a
),
}
where
T
:
TypeVisitable
<
'tcx
>
,
E
:
TypeVisitable
<
'tcx
>
,
}
impl
<
'tcx
,
T
:
TypeFoldable
<
'tcx
>>
TypeFoldable
<
'tcx
>
for
Rc
<
T
>
{
fn
try_fold_with
<
F
:
FallibleTypeFolder
<
'tcx
>>
(
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录