Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
514ae7d9
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,发现更多精彩内容 >>
提交
514ae7d9
编写于
1月 29, 2018
作者:
N
Niko Matsakis
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
change `overlapping_impls` to take a tcx and create the infcx
上级
4c210afb
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
66 addition
and
72 deletion
+66
-72
src/librustc/traits/coherence.rs
src/librustc/traits/coherence.rs
+11
-9
src/librustc/traits/specialize/specialization_graph.rs
src/librustc/traits/specialize/specialization_graph.rs
+29
-33
src/librustc_typeck/coherence/inherent_impls_overlap.rs
src/librustc_typeck/coherence/inherent_impls_overlap.rs
+26
-30
未找到文件。
src/librustc/traits/coherence.rs
浏览文件 @
514ae7d9
...
...
@@ -19,7 +19,7 @@
use
ty
::
fold
::
TypeFoldable
;
use
ty
::
subst
::
Subst
;
use
infer
::{
Infer
Ctxt
,
Infer
Ok
};
use
infer
::{
InferOk
};
/// Whether we do the orphan check relative to this crate or
/// to some remote crate.
...
...
@@ -43,8 +43,8 @@ pub struct OverlapResult<'tcx> {
/// If there are types that satisfy both impls, invokes `on_overlap`
/// with a suitably-freshened `ImplHeader` with those types
/// substituted. Otherwise, invokes `no_overlap`.
pub
fn
overlapping_impls
<
F1
,
F2
,
R
>
(
infcx
:
&
InferCtxt
<
'_
,
'_
,
'_
>
,
pub
fn
overlapping_impls
<
'gcx
,
F1
,
F2
,
R
>
(
tcx
:
TyCtxt
<
'_
,
'gcx
,
'gcx
>
,
impl1_def_id
:
DefId
,
impl2_def_id
:
DefId
,
intercrate_mode
:
IntercrateMode
,
...
...
@@ -63,12 +63,14 @@ pub fn overlapping_impls<F1, F2, R>(
impl2_def_id
,
intercrate_mode
);
let
selcx
=
&
mut
SelectionContext
::
intercrate
(
infcx
,
intercrate_mode
);
if
let
Some
(
r
)
=
overlap
(
selcx
,
impl1_def_id
,
impl2_def_id
)
{
on_overlap
(
r
)
}
else
{
no_overlap
()
}
tcx
.infer_ctxt
()
.enter
(|
infcx
|
{
let
selcx
=
&
mut
SelectionContext
::
intercrate
(
&
infcx
,
intercrate_mode
);
if
let
Some
(
r
)
=
overlap
(
selcx
,
impl1_def_id
,
impl2_def_id
)
{
on_overlap
(
r
)
}
else
{
no_overlap
()
}
})
}
fn
with_fresh_ty_vars
<
'cx
,
'gcx
,
'tcx
>
(
selcx
:
&
mut
SelectionContext
<
'cx
,
'gcx
,
'tcx
>
,
...
...
src/librustc/traits/specialize/specialization_graph.rs
浏览文件 @
514ae7d9
...
...
@@ -133,29 +133,27 @@ fn insert(&mut self,
};
let
tcx
=
tcx
.global_tcx
();
let
(
le
,
ge
)
=
tcx
.infer_ctxt
()
.enter
(|
infcx
|
{
traits
::
overlapping_impls
(
&
infcx
,
possible_sibling
,
impl_def_id
,
traits
::
IntercrateMode
::
Issue43355
,
|
overlap
|
{
if
tcx
.impls_are_allowed_to_overlap
(
impl_def_id
,
possible_sibling
)
{
return
Ok
((
false
,
false
));
}
let
le
=
tcx
.specializes
((
impl_def_id
,
possible_sibling
));
let
ge
=
tcx
.specializes
((
possible_sibling
,
impl_def_id
));
if
le
==
ge
{
Err
(
overlap_error
(
overlap
))
}
else
{
Ok
((
le
,
ge
))
}
},
||
Ok
((
false
,
false
)),
)
})
?
;
let
(
le
,
ge
)
=
traits
::
overlapping_impls
(
tcx
,
possible_sibling
,
impl_def_id
,
traits
::
IntercrateMode
::
Issue43355
,
|
overlap
|
{
if
tcx
.impls_are_allowed_to_overlap
(
impl_def_id
,
possible_sibling
)
{
return
Ok
((
false
,
false
));
}
let
le
=
tcx
.specializes
((
impl_def_id
,
possible_sibling
));
let
ge
=
tcx
.specializes
((
possible_sibling
,
impl_def_id
));
if
le
==
ge
{
Err
(
overlap_error
(
overlap
))
}
else
{
Ok
((
le
,
ge
))
}
},
||
Ok
((
false
,
false
)),
)
?
;
if
le
&&
!
ge
{
debug!
(
"descending as child of TraitRef {:?}"
,
...
...
@@ -172,16 +170,14 @@ fn insert(&mut self,
return
Ok
(
Inserted
::
Replaced
(
possible_sibling
));
}
else
{
if
!
tcx
.impls_are_allowed_to_overlap
(
impl_def_id
,
possible_sibling
)
{
tcx
.infer_ctxt
()
.enter
(|
infcx
|
{
traits
::
overlapping_impls
(
&
infcx
,
possible_sibling
,
impl_def_id
,
traits
::
IntercrateMode
::
Fixed
,
|
overlap
|
last_lint
=
Some
(
overlap_error
(
overlap
)),
||
(),
)
});
traits
::
overlapping_impls
(
tcx
,
possible_sibling
,
impl_def_id
,
traits
::
IntercrateMode
::
Fixed
,
|
overlap
|
last_lint
=
Some
(
overlap_error
(
overlap
)),
||
(),
);
}
// no overlap (error bailed already via ?)
...
...
src/librustc_typeck/coherence/inherent_impls_overlap.rs
浏览文件 @
514ae7d9
...
...
@@ -82,41 +82,37 @@ fn check_for_overlapping_inherent_impls(&self, ty_def_id: DefId) {
for
(
i
,
&
impl1_def_id
)
in
impls
.iter
()
.enumerate
()
{
for
&
impl2_def_id
in
&
impls
[(
i
+
1
)
..
]
{
let
used_to_be_allowed
=
self
.tcx
.infer_ctxt
()
.enter
(|
infcx
|
{
let
used_to_be_allowed
=
traits
::
overlapping_impls
(
self
.tcx
,
impl1_def_id
,
impl2_def_id
,
IntercrateMode
::
Issue43355
,
|
overlap
|
{
self
.check_for_common_items_in_impls
(
impl1_def_id
,
impl2_def_id
,
overlap
,
false
,
);
false
},
||
true
,
);
if
used_to_be_allowed
{
traits
::
overlapping_impls
(
&
inf
cx
,
self
.t
cx
,
impl1_def_id
,
impl2_def_id
,
IntercrateMode
::
Issue43355
,
|
overlap
|
{
self
.check_for_common_items_in_impls
(
impl1_def_id
,
impl2_def_id
,
overlap
,
false
,
);
false
},
||
true
,
)
});
if
used_to_be_allowed
{
self
.tcx
.infer_ctxt
()
.enter
(|
infcx
|
{
traits
::
overlapping_impls
(
&
infcx
,
IntercrateMode
::
Fixed
,
|
overlap
|
self
.check_for_common_items_in_impls
(
impl1_def_id
,
impl2_def_id
,
IntercrateMode
::
Fixed
,
|
overlap
|
self
.check_for_common_items_in_impls
(
impl1_def_id
,
impl2_def_id
,
overlap
,
true
,
),
||
(),
);
});
overlap
,
true
,
),
||
(),
);
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录