Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
50f8ae36
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,发现更多精彩内容 >>
提交
50f8ae36
编写于
11月 17, 2018
作者:
S
scalexm
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add a def-id in `ty::ParamEnv`
上级
69007bd6
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
48 addition
and
18 deletion
+48
-18
src/librustc/ich/impls_ty.rs
src/librustc/ich/impls_ty.rs
+2
-1
src/librustc/traits/auto_trait.rs
src/librustc/traits/auto_trait.rs
+6
-1
src/librustc/traits/mod.rs
src/librustc/traits/mod.rs
+15
-5
src/librustc/ty/mod.rs
src/librustc/ty/mod.rs
+18
-8
src/librustc/ty/structural_impls.rs
src/librustc/ty/structural_impls.rs
+2
-1
src/librustc_typeck/check/compare_method.rs
src/librustc_typeck/check/compare_method.rs
+5
-2
未找到文件。
src/librustc/ich/impls_ty.rs
浏览文件 @
50f8ae36
...
...
@@ -885,7 +885,8 @@ fn hash_stable<W: StableHasherResult>(&self,
impl_stable_hash_for!
(
struct
ty
::
ParamEnv
<
'tcx
>
{
caller_bounds
,
reveal
reveal
,
def_id
});
impl_stable_hash_for!
(
enum
traits
::
Reveal
{
...
...
src/librustc/traits/auto_trait.rs
浏览文件 @
50f8ae36
...
...
@@ -388,12 +388,17 @@ pub fn evaluate_predicates<'b, 'gcx, 'c>(
computed_preds
.extend
(
user_computed_preds
.iter
()
.cloned
());
let
normalized_preds
=
elaborate_predicates
(
tcx
,
computed_preds
.clone
()
.into_iter
()
.collect
());
new_env
=
ty
::
ParamEnv
::
new
(
tcx
.mk_predicates
(
normalized_preds
),
param_env
.reveal
);
new_env
=
ty
::
ParamEnv
::
new
(
tcx
.mk_predicates
(
normalized_preds
),
param_env
.reveal
,
None
);
}
let
final_user_env
=
ty
::
ParamEnv
::
new
(
tcx
.mk_predicates
(
user_computed_preds
.into_iter
()),
user_env
.reveal
,
None
);
debug!
(
"evaluate_nested_obligations(ty_did={:?}, trait_did={:?}): succeeded with '{:?}'
\
...
...
src/librustc/traits/mod.rs
浏览文件 @
50f8ae36
...
...
@@ -804,8 +804,11 @@ pub fn normalize_param_env_or_error<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
debug!
(
"normalize_param_env_or_error: elaborated-predicates={:?}"
,
predicates
);
let
elaborated_env
=
ty
::
ParamEnv
::
new
(
tcx
.intern_predicates
(
&
predicates
),
unnormalized_env
.reveal
);
let
elaborated_env
=
ty
::
ParamEnv
::
new
(
tcx
.intern_predicates
(
&
predicates
),
unnormalized_env
.reveal
,
unnormalized_env
.def_id
);
// HACK: we are trying to normalize the param-env inside *itself*. The problem is that
// normalization expects its param-env to be already normalized, which means we have
...
...
@@ -852,8 +855,11 @@ pub fn normalize_param_env_or_error<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
// predicates here anyway. Keeping them here anyway because it seems safer.
let
outlives_env
:
Vec
<
_
>
=
non_outlives_predicates
.iter
()
.chain
(
&
outlives_predicates
)
.cloned
()
.collect
();
let
outlives_env
=
ty
::
ParamEnv
::
new
(
tcx
.intern_predicates
(
&
outlives_env
),
unnormalized_env
.reveal
);
let
outlives_env
=
ty
::
ParamEnv
::
new
(
tcx
.intern_predicates
(
&
outlives_env
),
unnormalized_env
.reveal
,
None
);
let
outlives_predicates
=
match
do_normalize_predicates
(
tcx
,
region_context
,
cause
,
outlives_env
,
outlives_predicates
)
{
...
...
@@ -869,7 +875,11 @@ pub fn normalize_param_env_or_error<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
let
mut
predicates
=
non_outlives_predicates
;
predicates
.extend
(
outlives_predicates
);
debug!
(
"normalize_param_env_or_error: final predicates={:?}"
,
predicates
);
ty
::
ParamEnv
::
new
(
tcx
.intern_predicates
(
&
predicates
),
unnormalized_env
.reveal
)
ty
::
ParamEnv
::
new
(
tcx
.intern_predicates
(
&
predicates
),
unnormalized_env
.reveal
,
unnormalized_env
.def_id
)
}
pub
fn
fully_normalize
<
'a
,
'gcx
,
'tcx
,
T
>
(
...
...
src/librustc/ty/mod.rs
浏览文件 @
50f8ae36
...
...
@@ -1617,6 +1617,11 @@ pub struct ParamEnv<'tcx> {
/// want `Reveal::All` -- note that this is always paired with an
/// empty environment. To get that, use `ParamEnv::reveal()`.
pub
reveal
:
traits
::
Reveal
,
/// If this `ParamEnv` comes from a call to `tcx.param_env(def_id)`,
/// register that `def_id` (useful for transitioning to the chalk trait
/// solver).
pub
def_id
:
Option
<
DefId
>
,
}
impl
<
'tcx
>
ParamEnv
<
'tcx
>
{
...
...
@@ -1626,7 +1631,7 @@ impl<'tcx> ParamEnv<'tcx> {
/// type-checking.
#[inline]
pub
fn
empty
()
->
Self
{
Self
::
new
(
List
::
empty
(),
Reveal
::
UserFacing
)
Self
::
new
(
List
::
empty
(),
Reveal
::
UserFacing
,
None
)
}
/// Construct a trait environment with no where clauses in scope
...
...
@@ -1638,15 +1643,17 @@ pub fn empty() -> Self {
/// or invoke `param_env.with_reveal_all()`.
#[inline]
pub
fn
reveal_all
()
->
Self
{
Self
::
new
(
List
::
empty
(),
Reveal
::
All
)
Self
::
new
(
List
::
empty
(),
Reveal
::
All
,
None
)
}
/// Construct a trait environment with the given set of predicates.
#[inline]
pub
fn
new
(
caller_bounds
:
&
'tcx
List
<
ty
::
Predicate
<
'tcx
>>
,
reveal
:
Reveal
)
->
Self
{
ty
::
ParamEnv
{
caller_bounds
,
reveal
}
pub
fn
new
(
caller_bounds
:
&
'tcx
List
<
ty
::
Predicate
<
'tcx
>>
,
reveal
:
Reveal
,
def_id
:
Option
<
DefId
>
)
->
Self
{
ty
::
ParamEnv
{
caller_bounds
,
reveal
,
def_id
}
}
/// Returns a new parameter environment with the same clauses, but
...
...
@@ -3148,8 +3155,11 @@ fn param_env<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
// are any errors at that point, so after type checking you can be
// sure that this will succeed without errors anyway.
let
unnormalized_env
=
ty
::
ParamEnv
::
new
(
tcx
.intern_predicates
(
&
predicates
),
traits
::
Reveal
::
UserFacing
);
let
unnormalized_env
=
ty
::
ParamEnv
::
new
(
tcx
.intern_predicates
(
&
predicates
),
traits
::
Reveal
::
UserFacing
,
Some
(
def_id
)
);
let
body_id
=
tcx
.hir
()
.as_local_node_id
(
def_id
)
.map_or
(
DUMMY_NODE_ID
,
|
id
|
{
tcx
.hir
()
.maybe_body_owned_by
(
id
)
.map_or
(
id
,
|
body
|
body
.node_id
)
...
...
src/librustc/ty/structural_impls.rs
浏览文件 @
50f8ae36
...
...
@@ -276,6 +276,7 @@ fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) -> Option<Self::Lif
ty
::
ParamEnv
{
reveal
:
self
.reveal
,
caller_bounds
,
def_id
:
self
.def_id
,
}
})
}
...
...
@@ -589,7 +590,7 @@ fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
}
BraceStructTypeFoldableImpl!
{
impl
<
'tcx
>
TypeFoldable
<
'tcx
>
for
ty
::
ParamEnv
<
'tcx
>
{
reveal
,
caller_bounds
}
impl
<
'tcx
>
TypeFoldable
<
'tcx
>
for
ty
::
ParamEnv
<
'tcx
>
{
reveal
,
caller_bounds
,
def_id
}
}
impl
<
'tcx
>
TypeFoldable
<
'tcx
>
for
&
'tcx
ty
::
List
<
ty
::
ExistentialPredicate
<
'tcx
>>
{
...
...
src/librustc_typeck/check/compare_method.rs
浏览文件 @
50f8ae36
...
...
@@ -206,8 +206,11 @@ fn compare_predicate_entailment<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
// The key step here is to update the caller_bounds's predicates to be
// the new hybrid bounds we computed.
let
normalize_cause
=
traits
::
ObligationCause
::
misc
(
impl_m_span
,
impl_m_node_id
);
let
param_env
=
ty
::
ParamEnv
::
new
(
tcx
.intern_predicates
(
&
hybrid_preds
.predicates
),
Reveal
::
UserFacing
);
let
param_env
=
ty
::
ParamEnv
::
new
(
tcx
.intern_predicates
(
&
hybrid_preds
.predicates
),
Reveal
::
UserFacing
,
None
);
let
param_env
=
traits
::
normalize_param_env_or_error
(
tcx
,
impl_m
.def_id
,
param_env
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录