Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
d088d8a2
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,发现更多精彩内容 >>
未验证
提交
d088d8a2
编写于
1月 16, 2020
作者:
A
Aaron Hill
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Revert previous attempt at detecting unsatisfiable predicates
上级
48840618
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
14 addition
and
50 deletion
+14
-50
src/librustc/mir/mono.rs
src/librustc/mir/mono.rs
+1
-4
src/librustc/query/mod.rs
src/librustc/query/mod.rs
+3
-3
src/librustc/traits/fulfill.rs
src/librustc/traits/fulfill.rs
+2
-22
src/librustc/traits/mod.rs
src/librustc/traits/mod.rs
+8
-12
src/librustc/ty/query/keys.rs
src/librustc/ty/query/keys.rs
+0
-9
未找到文件。
src/librustc/mir/mono.rs
浏览文件 @
d088d8a2
use
crate
::
dep_graph
::{
DepConstructor
,
DepNode
,
WorkProduct
,
WorkProductId
};
use
crate
::
ich
::{
Fingerprint
,
NodeIdHashingMode
,
StableHashingContext
};
use
crate
::
session
::
config
::
OptLevel
;
use
crate
::
traits
::
TraitQueryMode
;
use
crate
::
ty
::
print
::
obsolete
::
DefPathBasedNames
;
use
crate
::
ty
::{
subst
::
InternalSubsts
,
Instance
,
InstanceDef
,
SymbolName
,
TyCtxt
};
use
rustc_data_structures
::
base_n
;
...
...
@@ -168,9 +167,7 @@ pub fn is_instantiable(&self, tcx: TyCtxt<'tcx>) -> bool {
MonoItem
::
GlobalAsm
(
..
)
=>
return
true
,
};
// We shouldn't encounter any overflow here, so we use TraitQueryMode::Standard\
// to report an error if overflow somehow occurs.
tcx
.substitute_normalize_and_test_predicates
((
def_id
,
&
substs
,
TraitQueryMode
::
Standard
))
tcx
.substitute_normalize_and_test_predicates
((
def_id
,
&
substs
))
}
pub
fn
to_string
(
&
self
,
tcx
:
TyCtxt
<
'tcx
>
,
debug
:
bool
)
->
String
{
...
...
src/librustc/query/mod.rs
浏览文件 @
d088d8a2
...
...
@@ -1148,11 +1148,11 @@ fn describe_as_module(def_id: DefId, tcx: TyCtxt<'_>) -> String {
desc
{
"normalizing `{:?}`"
,
goal
}
}
query
substitute_normalize_and_test_predicates
(
key
:
(
DefId
,
SubstsRef
<
'tcx
>
,
traits
::
TraitQueryMode
))
->
bool
{
query
substitute_normalize_and_test_predicates
(
key
:
(
DefId
,
SubstsRef
<
'tcx
>
))
->
bool
{
no_force
desc
{
|
tcx
|
"testing substituted normalized predicates
in mode {:?}
:`{}`"
,
key
.2
,
tcx
.def_path_str
(
key
.0
)
"testing substituted normalized predicates:`{}`"
,
tcx
.def_path_str
(
key
.0
)
}
}
...
...
src/librustc/traits/fulfill.rs
浏览文件 @
d088d8a2
...
...
@@ -16,7 +16,6 @@
use
super
::{
ConstEvalFailure
,
Unimplemented
};
use
super
::{
FulfillmentError
,
FulfillmentErrorCode
};
use
super
::{
ObligationCause
,
PredicateObligation
};
use
crate
::
traits
::
TraitQueryMode
;
impl
<
'tcx
>
ForestObligation
for
PendingPredicateObligation
<
'tcx
>
{
type
Predicate
=
ty
::
Predicate
<
'tcx
>
;
...
...
@@ -63,9 +62,6 @@ pub struct FulfillmentContext<'tcx> {
// a snapshot (they don't *straddle* a snapshot, so there
// is no trouble there).
usable_in_snapshot
:
bool
,
// The `TraitQueryMode` used when constructing a `SelectionContext`
query_mode
:
TraitQueryMode
,
}
#[derive(Clone,
Debug)]
...
...
@@ -79,26 +75,12 @@ pub struct PendingPredicateObligation<'tcx> {
static_assert_size!
(
PendingPredicateObligation
<
'_
>
,
136
);
impl
<
'a
,
'tcx
>
FulfillmentContext
<
'tcx
>
{
/// Creates a new fulfillment context with `TraitQueryMode::Standard`
/// You almost always want to use this instead of `with_query_mode`
/// Creates a new fulfillment context.
pub
fn
new
()
->
FulfillmentContext
<
'tcx
>
{
FulfillmentContext
{
predicates
:
ObligationForest
::
new
(),
register_region_obligations
:
true
,
usable_in_snapshot
:
false
,
query_mode
:
TraitQueryMode
::
Standard
,
}
}
/// Creates a new fulfillment context with the specified query mode.
/// This should only be used when you want to ignore overflow,
/// rather than reporting it as an error.
pub
fn
with_query_mode
(
query_mode
:
TraitQueryMode
)
->
FulfillmentContext
<
'tcx
>
{
FulfillmentContext
{
predicates
:
ObligationForest
::
new
(),
register_region_obligations
:
true
,
usable_in_snapshot
:
false
,
query_mode
,
}
}
...
...
@@ -107,7 +89,6 @@ pub fn new_in_snapshot() -> FulfillmentContext<'tcx> {
predicates
:
ObligationForest
::
new
(),
register_region_obligations
:
true
,
usable_in_snapshot
:
true
,
query_mode
:
TraitQueryMode
::
Standard
,
}
}
...
...
@@ -116,7 +97,6 @@ pub fn new_ignoring_regions() -> FulfillmentContext<'tcx> {
predicates
:
ObligationForest
::
new
(),
register_region_obligations
:
false
,
usable_in_snapshot
:
false
,
query_mode
:
TraitQueryMode
::
Standard
,
}
}
...
...
@@ -237,7 +217,7 @@ fn select_where_possible(
&
mut
self
,
infcx
:
&
InferCtxt
<
'_
,
'tcx
>
,
)
->
Result
<
(),
Vec
<
FulfillmentError
<
'tcx
>>>
{
let
mut
selcx
=
SelectionContext
::
with_query_mode
(
infcx
,
self
.query_mode
);
let
mut
selcx
=
SelectionContext
::
new
(
infcx
);
self
.select
(
&
mut
selcx
)
}
...
...
src/librustc/traits/mod.rs
浏览文件 @
d088d8a2
...
...
@@ -95,7 +95,7 @@ pub enum IntercrateMode {
}
/// The mode that trait queries run in.
#[derive(Copy,
Clone,
PartialEq,
Eq,
Debug
,
Hash,
HashStable
)]
#[derive(Copy,
Clone,
PartialEq,
Eq,
Debug)]
pub
enum
TraitQueryMode
{
// Standard/un-canonicalized queries get accurate
// spans etc. passed in and hence can do reasonable
...
...
@@ -1014,17 +1014,16 @@ pub fn fully_normalize<'a, 'tcx, T>(
/// environment. If this returns false, then either normalize
/// encountered an error or one of the predicates did not hold. Used
/// when creating vtables to check for unsatisfiable methods.
fn
normalize_and_test_predicates
<
'tcx
>
(
pub
fn
normalize_and_test_predicates
<
'tcx
>
(
tcx
:
TyCtxt
<
'tcx
>
,
predicates
:
Vec
<
ty
::
Predicate
<
'tcx
>>
,
mode
:
TraitQueryMode
,
)
->
bool
{
debug!
(
"normalize_and_test_predicates(predicates={:?}
, mode={:?})"
,
predicates
,
mode
);
debug!
(
"normalize_and_test_predicates(predicates={:?}
)"
,
predicates
);
let
result
=
tcx
.infer_ctxt
()
.enter
(|
infcx
|
{
let
param_env
=
ty
::
ParamEnv
::
reveal_all
();
let
mut
selcx
=
SelectionContext
::
with_query_mode
(
&
infcx
,
mode
);
let
mut
fulfill_cx
=
FulfillmentContext
::
with_query_mode
(
mode
);
let
mut
selcx
=
SelectionContext
::
new
(
&
infcx
);
let
mut
fulfill_cx
=
FulfillmentContext
::
new
(
);
let
cause
=
ObligationCause
::
dummy
();
let
Normalized
{
value
:
predicates
,
obligations
}
=
normalize
(
&
mut
selcx
,
param_env
,
cause
.clone
(),
&
predicates
);
...
...
@@ -1044,12 +1043,12 @@ fn normalize_and_test_predicates<'tcx>(
fn
substitute_normalize_and_test_predicates
<
'tcx
>
(
tcx
:
TyCtxt
<
'tcx
>
,
key
:
(
DefId
,
SubstsRef
<
'tcx
>
,
TraitQueryMode
),
key
:
(
DefId
,
SubstsRef
<
'tcx
>
),
)
->
bool
{
debug!
(
"substitute_normalize_and_test_predicates(key={:?})"
,
key
);
let
predicates
=
tcx
.predicates_of
(
key
.0
)
.instantiate
(
tcx
,
key
.1
)
.predicates
;
let
result
=
normalize_and_test_predicates
(
tcx
,
predicates
,
key
.2
);
let
result
=
normalize_and_test_predicates
(
tcx
,
predicates
);
debug!
(
"substitute_normalize_and_test_predicates(key={:?}) = {:?}"
,
key
,
result
);
result
...
...
@@ -1102,10 +1101,7 @@ fn vtable_methods<'tcx>(
// Note that this method could then never be called, so we
// do not want to try and codegen it, in that case (see #23435).
let
predicates
=
tcx
.predicates_of
(
def_id
)
.instantiate_own
(
tcx
,
substs
);
// We don't expect overflow here, so report an error if it somehow ends
// up happening.
if
!
normalize_and_test_predicates
(
tcx
,
predicates
.predicates
,
TraitQueryMode
::
Standard
)
{
if
!
normalize_and_test_predicates
(
tcx
,
predicates
.predicates
)
{
debug!
(
"vtable_methods: predicates do not hold"
);
return
None
;
}
...
...
src/librustc/ty/query/keys.rs
浏览文件 @
d088d8a2
...
...
@@ -125,15 +125,6 @@ fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
}
}
impl
<
'tcx
>
Key
for
(
DefId
,
SubstsRef
<
'tcx
>
,
traits
::
TraitQueryMode
)
{
fn
query_crate
(
&
self
)
->
CrateNum
{
self
.0
.krate
}
fn
default_span
(
&
self
,
tcx
:
TyCtxt
<
'_
>
)
->
Span
{
self
.0
.default_span
(
tcx
)
}
}
impl
<
'tcx
>
Key
for
(
ty
::
ParamEnv
<
'tcx
>
,
ty
::
PolyTraitRef
<
'tcx
>
)
{
fn
query_crate
(
&
self
)
->
CrateNum
{
self
.1
.def_id
()
.krate
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录