Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
4eb7362c
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,发现更多精彩内容 >>
提交
4eb7362c
编写于
8月 08, 2016
作者:
N
Niko Matsakis
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
simplify DepNode for trait selection
上级
b44d94a5
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
33 addition
and
39 deletion
+33
-39
src/librustc/dep_graph/dep_node.rs
src/librustc/dep_graph/dep_node.rs
+3
-4
src/librustc/infer/mod.rs
src/librustc/infer/mod.rs
+23
-33
src/librustc/ty/mod.rs
src/librustc/ty/mod.rs
+2
-1
src/librustc_trans/common.rs
src/librustc_trans/common.rs
+1
-1
src/librustc_trans/monomorphize.rs
src/librustc_trans/monomorphize.rs
+4
-0
未找到文件。
src/librustc/dep_graph/dep_node.rs
浏览文件 @
4eb7362c
...
...
@@ -132,7 +132,7 @@ pub enum DepNode<D: Clone + Debug> {
// which would yield an overly conservative dep-graph.
TraitItems
(
D
),
ReprHints
(
D
),
TraitSelect
(
D
,
Vec
<
D
>
),
TraitSelect
(
Vec
<
D
>
),
}
impl
<
D
:
Clone
+
Debug
>
DepNode
<
D
>
{
...
...
@@ -237,10 +237,9 @@ pub fn map_def<E, OP>(&self, mut op: OP) -> Option<DepNode<E>>
TraitImpls
(
ref
d
)
=>
op
(
d
)
.map
(
TraitImpls
),
TraitItems
(
ref
d
)
=>
op
(
d
)
.map
(
TraitItems
),
ReprHints
(
ref
d
)
=>
op
(
d
)
.map
(
ReprHints
),
TraitSelect
(
ref
d
,
ref
type_ds
)
=>
{
let
d
=
try_opt!
(
op
(
d
));
TraitSelect
(
ref
type_ds
)
=>
{
let
type_ds
=
try_opt!
(
type_ds
.iter
()
.map
(|
d
|
op
(
d
))
.collect
());
Some
(
TraitSelect
(
d
,
type_ds
))
Some
(
TraitSelect
(
type_ds
))
}
}
}
...
...
src/librustc/infer/mod.rs
浏览文件 @
4eb7362c
...
...
@@ -670,6 +670,15 @@ fn normalize_projections_in<T>(&self, value: &T) -> T::Lifted
self
.drain_fulfillment_cx_or_panic
(
DUMMY_SP
,
&
mut
fulfill_cx
,
&
result
)
}
/// Finishes processes any obligations that remain in the
/// fulfillment context, and then returns the result with all type
/// variables removed and regions erased. Because this is intended
/// for use after type-check has completed, if any errors occur,
/// it will panic. It is used during normalization and other cases
/// where processing the obligations in `fulfill_cx` may cause
/// type inference variables that appear in `result` to be
/// unified, and hence we need to process those obligations to get
/// the complete picture of the type.
pub
fn
drain_fulfillment_cx_or_panic
<
T
>
(
&
self
,
span
:
Span
,
fulfill_cx
:
&
mut
traits
::
FulfillmentContext
<
'tcx
>
,
...
...
@@ -679,47 +688,28 @@ pub fn drain_fulfillment_cx_or_panic<T>(&self,
{
debug!
(
"drain_fulfillment_cx_or_panic()"
);
let
when
=
"resolving bounds after type-checking"
;
let
v
=
match
self
.drain_fulfillment_cx
(
fulfill_cx
,
result
)
{
Ok
(
v
)
=>
v
,
// In principle, we only need to do this so long as `result`
// contains unbound type parameters. It could be a slight
// optimization to stop iterating early.
match
fulfill_cx
.select_all_or_error
(
self
)
{
Ok
(())
=>
{
}
Err
(
errors
)
=>
{
span_bug!
(
span
,
"Encountered errors `{:?}` {}"
,
errors
,
when
);
span_bug!
(
span
,
"Encountered errors `{:?}` resolving bounds after type-checking"
,
errors
);
}
}
;
}
match
self
.tcx
.lift_to_global
(
&
v
)
{
Some
(
v
)
=>
v
,
let
result
=
self
.resolve_type_vars_if_possible
(
result
);
let
result
=
self
.tcx
.erase_regions
(
&
result
);
match
self
.tcx
.lift_to_global
(
&
result
)
{
Some
(
result
)
=>
result
,
None
=>
{
span_bug!
(
span
,
"Uninferred types/regions in `{:?}`
{}"
,
v
,
when
);
span_bug!
(
span
,
"Uninferred types/regions in `{:?}`
"
,
result
);
}
}
}
/// Finishes processes any obligations that remain in the fulfillment
/// context, and then "freshens" and returns `result`. This is
/// primarily used during normalization and other cases where
/// processing the obligations in `fulfill_cx` may cause type
/// inference variables that appear in `result` to be unified, and
/// hence we need to process those obligations to get the complete
/// picture of the type.
pub
fn
drain_fulfillment_cx
<
T
>
(
&
self
,
fulfill_cx
:
&
mut
traits
::
FulfillmentContext
<
'tcx
>
,
result
:
&
T
)
->
Result
<
T
,
Vec
<
traits
::
FulfillmentError
<
'tcx
>>>
where
T
:
TypeFoldable
<
'tcx
>
{
debug!
(
"drain_fulfillment_cx(result={:?})"
,
result
);
// In principle, we only need to do this so long as `result`
// contains unbound type parameters. It could be a slight
// optimization to stop iterating early.
fulfill_cx
.select_all_or_error
(
self
)
?
;
let
result
=
self
.resolve_type_vars_if_possible
(
result
);
Ok
(
self
.tcx
.erase_regions
(
&
result
))
}
pub
fn
projection_mode
(
&
self
)
->
Reveal
{
self
.projection_mode
}
...
...
src/librustc/ty/mod.rs
浏览文件 @
4eb7362c
...
...
@@ -958,8 +958,9 @@ fn dep_node(&self) -> DepNode<DefId> {
_
=>
None
})
.chain
(
iter
::
once
(
self
.def_id
()))
.collect
();
DepNode
::
TraitSelect
(
self
.def_id
(),
def_ids
)
DepNode
::
TraitSelect
(
def_ids
)
}
pub
fn
input_types
<
'a
>
(
&
'a
self
)
->
impl
DoubleEndedIterator
<
Item
=
Ty
<
'tcx
>>
+
'a
{
...
...
src/librustc_trans/common.rs
浏览文件 @
4eb7362c
...
...
@@ -1028,7 +1028,7 @@ pub fn normalize_and_test_predicates<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
fulfill_cx
.register_predicate_obligation
(
&
infcx
,
obligation
);
}
fulfill_cx
.select_all_or_error
(
infcx
)
.is_ok
()
fulfill_cx
.select_all_or_error
(
&
infcx
)
.is_ok
()
})
}
...
...
src/librustc_trans/monomorphize.rs
浏览文件 @
4eb7362c
...
...
@@ -48,7 +48,11 @@ pub fn apply_param_substs<'a, 'tcx, T>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
->
T
where
T
:
TransNormalize
<
'tcx
>
{
debug!
(
"apply_param_substs(param_substs={:?}, value={:?})"
,
param_substs
,
value
);
let
substituted
=
value
.subst
(
tcx
,
param_substs
);
debug!
(
"apply_param_substs: substituted={:?}{}"
,
substituted
,
if
substituted
.has_projection_types
()
{
" [needs projection]"
}
else
{
""
});
tcx
.normalize_associated_type
(
&
substituted
)
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录