Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
d7ecc8c9
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,发现更多精彩内容 >>
提交
d7ecc8c9
编写于
3月 23, 2020
作者:
B
Bastian Kauschke
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
query normalize_generic_arg_after_erasing_regions
上级
bda976d4
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
49 addition
and
21 deletion
+49
-21
src/librustc/dep_graph/dep_node.rs
src/librustc/dep_graph/dep_node.rs
+1
-1
src/librustc/query/mod.rs
src/librustc/query/mod.rs
+4
-4
src/librustc/ty/normalize_erasing_regions.rs
src/librustc/ty/normalize_erasing_regions.rs
+11
-3
src/librustc/ty/query/keys.rs
src/librustc/ty/query/keys.rs
+12
-1
src/librustc/ty/query/mod.rs
src/librustc/ty/query/mod.rs
+1
-1
src/librustc/ty/subst.rs
src/librustc/ty/subst.rs
+8
-0
src/librustc_session/session.rs
src/librustc_session/session.rs
+4
-4
src/librustc_traits/normalize_erasing_regions.rs
src/librustc_traits/normalize_erasing_regions.rs
+8
-7
未找到文件。
src/librustc/dep_graph/dep_node.rs
浏览文件 @
d7ecc8c9
...
...
@@ -59,7 +59,7 @@
CanonicalTypeOpAscribeUserTypeGoal
,
CanonicalTypeOpEqGoal
,
CanonicalTypeOpNormalizeGoal
,
CanonicalTypeOpProvePredicateGoal
,
CanonicalTypeOpSubtypeGoal
,
};
use
crate
::
ty
::
subst
::
SubstsRef
;
use
crate
::
ty
::
subst
::
{
GenericArg
,
SubstsRef
}
;
use
crate
::
ty
::{
self
,
ParamEnvAnd
,
Ty
,
TyCtxt
};
use
rustc_data_structures
::
stable_hasher
::{
HashStable
,
StableHasher
};
...
...
src/librustc/query/mod.rs
浏览文件 @
d7ecc8c9
...
...
@@ -9,7 +9,7 @@
};
use
crate
::
ty
::
query
::
queries
;
use
crate
::
ty
::
query
::
QueryDescription
;
use
crate
::
ty
::
subst
::
SubstsRef
;
use
crate
::
ty
::
subst
::
{
GenericArg
,
SubstsRef
}
;
use
crate
::
ty
::{
self
,
ParamEnvAnd
,
Ty
,
TyCtxt
};
use
rustc_hir
::
def_id
::{
CrateNum
,
DefId
,
LocalDefId
};
...
...
@@ -1114,9 +1114,9 @@ fn describe_as_module(def_id: DefId, tcx: TyCtxt<'_>) -> String {
}
/// Do not call this query directly: invoke `normalize_erasing_regions` instead.
query
normalize_
ty
_after_erasing_regions
(
goal
:
ParamEnvAnd
<
'tcx
,
Ty
<
'tcx
>>
)
->
Ty
<
'tcx
>
{
query
normalize_
generic_arg
_after_erasing_regions
(
goal
:
ParamEnvAnd
<
'tcx
,
GenericArg
<
'tcx
>>
)
->
GenericArg
<
'tcx
>
{
desc
{
"normalizing `{:?}`"
,
goal
}
}
...
...
src/librustc/ty/normalize_erasing_regions.rs
浏览文件 @
d7ecc8c9
...
...
@@ -4,8 +4,8 @@
//!
//! The methods in this file use a `TypeFolder` to recursively process
//! contents, invoking the underlying
//! `normalize_
ty_after_erasing_regions` query for each type found
//! within. (This underlying query is what is cached.)
//! `normalize_
generic_arg_after_erasing_regions` query for each type
//!
or constant found
within. (This underlying query is what is cached.)
use
crate
::
ty
::
fold
::{
TypeFoldable
,
TypeFolder
};
use
crate
::
ty
::
subst
::{
Subst
,
SubstsRef
};
...
...
@@ -94,6 +94,14 @@ fn tcx(&self) -> TyCtxt<'tcx> {
}
fn
fold_ty
(
&
mut
self
,
ty
:
Ty
<
'tcx
>
)
->
Ty
<
'tcx
>
{
self
.tcx
.normalize_ty_after_erasing_regions
(
self
.param_env
.and
(
ty
))
self
.tcx
.normalize_generic_arg_after_erasing_regions
(
self
.param_env
.and
(
ty
.into
()))
.expect_ty
()
}
fn
fold_const
(
&
mut
self
,
c
:
&
'tcx
ty
::
Const
<
'tcx
>
)
->
&
'tcx
ty
::
Const
<
'tcx
>
{
self
.tcx
.normalize_generic_arg_after_erasing_regions
(
self
.param_env
.and
(
c
.into
()))
.expect_const
()
}
}
src/librustc/ty/query/keys.rs
浏览文件 @
d7ecc8c9
...
...
@@ -5,7 +5,7 @@
use
crate
::
traits
;
use
crate
::
ty
::
fast_reject
::
SimplifiedType
;
use
crate
::
ty
::
query
::
caches
::
DefaultCacheSelector
;
use
crate
::
ty
::
subst
::
SubstsRef
;
use
crate
::
ty
::
subst
::
{
GenericArg
,
SubstsRef
}
;
use
crate
::
ty
::{
self
,
Ty
,
TyCtxt
};
use
rustc_hir
::
def_id
::{
CrateNum
,
DefId
,
LocalDefId
,
LOCAL_CRATE
};
use
rustc_span
::
symbol
::
Symbol
;
...
...
@@ -194,6 +194,17 @@ fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
}
}
impl
<
'tcx
>
Key
for
GenericArg
<
'tcx
>
{
type
CacheSelector
=
DefaultCacheSelector
;
fn
query_crate
(
&
self
)
->
CrateNum
{
LOCAL_CRATE
}
fn
default_span
(
&
self
,
_
:
TyCtxt
<
'_
>
)
->
Span
{
DUMMY_SP
}
}
impl
<
'tcx
>
Key
for
&
'tcx
ty
::
Const
<
'tcx
>
{
type
CacheSelector
=
DefaultCacheSelector
;
...
...
src/librustc/ty/query/mod.rs
浏览文件 @
d7ecc8c9
...
...
@@ -31,7 +31,7 @@
use
crate
::
traits
::
Clauses
;
use
crate
::
traits
::{
self
,
Vtable
};
use
crate
::
ty
::
steal
::
Steal
;
use
crate
::
ty
::
subst
::
SubstsRef
;
use
crate
::
ty
::
subst
::
{
GenericArg
,
SubstsRef
}
;
use
crate
::
ty
::
util
::
AlwaysRequiresDrop
;
use
crate
::
ty
::{
self
,
AdtSizedConstraint
,
CrateInherentImpls
,
ParamEnvAnd
,
Ty
,
TyCtxt
};
use
crate
::
util
::
common
::
ErrorReported
;
...
...
src/librustc/ty/subst.rs
浏览文件 @
d7ecc8c9
...
...
@@ -128,6 +128,14 @@ pub fn expect_ty(self) -> Ty<'tcx> {
_
=>
bug!
(
"expected a type, but found another kind"
),
}
}
/// Unpack the `GenericArg` as a const when it is known certainly to be a const.
pub
fn
expect_const
(
self
)
->
&
'tcx
ty
::
Const
<
'tcx
>
{
match
self
.unpack
()
{
GenericArgKind
::
Const
(
c
)
=>
c
,
_
=>
bug!
(
"expected a const, but found another kind"
),
}
}
}
impl
<
'a
,
'tcx
>
Lift
<
'tcx
>
for
GenericArg
<
'a
>
{
...
...
src/librustc_session/session.rs
浏览文件 @
d7ecc8c9
...
...
@@ -150,7 +150,7 @@ pub struct PerfStats {
/// Total number of values canonicalized queries constructed.
pub
queries_canonicalized
:
AtomicUsize
,
/// Number of times this query is invoked.
pub
normalize_
ty
_after_erasing_regions
:
AtomicUsize
,
pub
normalize_
generic_arg
_after_erasing_regions
:
AtomicUsize
,
/// Number of times this query is invoked.
pub
normalize_projection_ty
:
AtomicUsize
,
}
...
...
@@ -707,8 +707,8 @@ pub fn print_perf_stats(&self) {
self
.perf_stats.queries_canonicalized
.load
(
Ordering
::
Relaxed
)
);
println!
(
"normalize_
ty_after_erasing_regions:
{}"
,
self
.perf_stats.normalize_
ty
_after_erasing_regions
.load
(
Ordering
::
Relaxed
)
"normalize_
generic_arg_after_erasing_regions:
{}"
,
self
.perf_stats.normalize_
generic_arg
_after_erasing_regions
.load
(
Ordering
::
Relaxed
)
);
println!
(
"normalize_projection_ty: {}"
,
...
...
@@ -1080,7 +1080,7 @@ fn build_session_(
symbol_hash_time
:
Lock
::
new
(
Duration
::
from_secs
(
0
)),
decode_def_path_tables_time
:
Lock
::
new
(
Duration
::
from_secs
(
0
)),
queries_canonicalized
:
AtomicUsize
::
new
(
0
),
normalize_
ty
_after_erasing_regions
:
AtomicUsize
::
new
(
0
),
normalize_
generic_arg
_after_erasing_regions
:
AtomicUsize
::
new
(
0
),
normalize_projection_ty
:
AtomicUsize
::
new
(
0
),
},
code_stats
:
Default
::
default
(),
...
...
src/librustc_traits/normalize_erasing_regions.rs
浏览文件 @
d7ecc8c9
use
rustc
::
traits
::
query
::
NoSolution
;
use
rustc
::
ty
::
query
::
Providers
;
use
rustc
::
ty
::{
self
,
ParamEnvAnd
,
Ty
,
TyCtxt
};
use
rustc
::
ty
::
subst
::
GenericArg
;
use
rustc
::
ty
::{
self
,
ParamEnvAnd
,
TyCtxt
};
use
rustc_infer
::
infer
::
TyCtxtInferExt
;
use
rustc_trait_selection
::
traits
::
query
::
normalize
::
AtExt
;
use
rustc_trait_selection
::
traits
::{
Normalized
,
ObligationCause
};
use
std
::
sync
::
atomic
::
Ordering
;
crate
fn
provide
(
p
:
&
mut
Providers
<
'_
>
)
{
*
p
=
Providers
{
normalize_
ty
_after_erasing_regions
,
..*
p
};
*
p
=
Providers
{
normalize_
generic_arg
_after_erasing_regions
,
..*
p
};
}
fn
normalize_
ty
_after_erasing_regions
<
'tcx
>
(
fn
normalize_
generic_arg
_after_erasing_regions
<
'tcx
>
(
tcx
:
TyCtxt
<
'tcx
>
,
goal
:
ParamEnvAnd
<
'tcx
,
Ty
<
'tcx
>>
,
)
->
Ty
<
'tcx
>
{
debug!
(
"normalize_
ty
_after_erasing_regions(goal={:#?})"
,
goal
);
goal
:
ParamEnvAnd
<
'tcx
,
GenericArg
<
'tcx
>>
,
)
->
GenericArg
<
'tcx
>
{
debug!
(
"normalize_
generic_arg
_after_erasing_regions(goal={:#?})"
,
goal
);
let
ParamEnvAnd
{
param_env
,
value
}
=
goal
;
tcx
.sess.perf_stats.normalize_
ty
_after_erasing_regions
.fetch_add
(
1
,
Ordering
::
Relaxed
);
tcx
.sess.perf_stats.normalize_
generic_arg
_after_erasing_regions
.fetch_add
(
1
,
Ordering
::
Relaxed
);
tcx
.infer_ctxt
()
.enter
(|
infcx
|
{
let
cause
=
ObligationCause
::
dummy
();
match
infcx
.at
(
&
cause
,
param_env
)
.normalize
(
&
value
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录