Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
51762886
R
Rust
项目概览
int
/
Rust
12 个月 前同步成功
通知
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,发现更多精彩内容 >>
提交
51762886
编写于
8月 08, 2023
作者:
L
lcnr
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
lower `evaluate_goal` stability check to `warn`
上级
9eeaf1fd
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
56 addition
and
36 deletion
+56
-36
compiler/rustc_trait_selection/src/solve/eval_ctxt.rs
compiler/rustc_trait_selection/src/solve/eval_ctxt.rs
+49
-33
compiler/rustc_trait_selection/src/solve/search_graph/mod.rs
compiler/rustc_trait_selection/src/solve/search_graph/mod.rs
+7
-3
未找到文件。
compiler/rustc_trait_selection/src/solve/eval_ctxt.rs
浏览文件 @
51762886
...
...
@@ -388,44 +388,60 @@ fn evaluate_goal(
&&
is_normalizes_to_hack
==
IsNormalizesToHack
::
No
&&
!
self
.search_graph
.in_cycle
()
{
debug!
(
"rerunning goal to check result is stable"
);
self
.search_graph
.reset_encountered_overflow
(
encountered_overflow
);
let
(
_
orig_values
,
canonical_goal
)
=
self
.canonicalize_goal
(
goal
);
let
Ok
(
new_canonical_response
)
=
EvalCtxt
::
evaluate_canonical_goal
(
self
.tcx
(),
self
.search_graph
,
canonical_goal
,
// FIXME(-Ztrait-solver=next): we do not track what happens in `evaluate_canonical_goal`
&
mut
ProofTreeBuilder
::
new_noop
(),
)
else
{
bug!
(
"goal went from {certainty:?} to error: re-canonicalized goal={canonical_goal:#?}
\
first_response={canonical_response:#?},
second response was error"
);
};
// We only check for modulo regions as we convert all regions in
// the input to new existentials, even if they're expected to be
// `'static` or a placeholder region.
if
!
new_canonical_response
.value.var_values
.is_identity_modulo_regions
()
{
bug!
(
"unstable result: re-canonicalized goal={canonical_goal:#?}
\
first_response={canonical_response:#?}
\
second_response={new_canonical_response:#?}"
);
}
if
certainty
!=
new_canonical_response
.value.certainty
{
bug!
(
"unstable certainty: {certainty:#?} re-canonicalized goal={canonical_goal:#?}
\
first_response={canonical_response:#?}
\
second_response={new_canonical_response:#?}"
);
}
// The nested evaluation has to happen with the original state
// of `encountered_overflow`.
let
from_original_evaluation
=
self
.search_graph
.reset_encountered_overflow
(
encountered_overflow
);
self
.check_evaluate_goal_stable_result
(
goal
,
canonical_goal
,
canonical_response
);
// In case the evaluation was unstable, we manually make sure that this
// debug check does not influence the result of the parent goal.
self
.search_graph
.reset_encountered_overflow
(
from_original_evaluation
);
}
Ok
((
has_changed
,
certainty
,
nested_goals
))
}
fn
check_evaluate_goal_stable_result
(
&
mut
self
,
goal
:
Goal
<
'tcx
,
ty
::
Predicate
<
'tcx
>>
,
original_input
:
CanonicalInput
<
'tcx
>
,
original_result
:
CanonicalResponse
<
'tcx
>
,
)
{
let
(
_
orig_values
,
canonical_goal
)
=
self
.canonicalize_goal
(
goal
);
let
result
=
EvalCtxt
::
evaluate_canonical_goal
(
self
.tcx
(),
self
.search_graph
,
canonical_goal
,
// FIXME(-Ztrait-solver=next): we do not track what happens in `evaluate_canonical_goal`
&
mut
ProofTreeBuilder
::
new_noop
(),
);
macro_rules!
fail
{
(
$msg:expr
)
=>
{{
let
msg
=
$msg
;
warn!
(
"unstable result: {msg}
\n
\
original goal: {original_input:?},
\n
\
original result: {original_result:?}
\n
\
re-canonicalized goal: {canonical_goal:?}
\n
\
second response: {result:?}"
);
return
;
}};
}
let
Ok
(
new_canonical_response
)
=
result
else
{
fail
!
(
"second response was error"
)
};
// We only check for modulo regions as we convert all regions in
// the input to new existentials, even if they're expected to be
// `'static` or a placeholder region.
if
!
new_canonical_response
.value.var_values
.is_identity_modulo_regions
()
{
fail
!
(
"additional constraints from second response"
)
}
if
original_result
.value.certainty
!=
new_canonical_response
.value.certainty
{
fail
!
(
"unstable certainty"
)
}
}
fn
compute_goal
(
&
mut
self
,
goal
:
Goal
<
'tcx
,
ty
::
Predicate
<
'tcx
>>
)
->
QueryResult
<
'tcx
>
{
let
Goal
{
param_env
,
predicate
}
=
goal
;
let
kind
=
predicate
.kind
();
...
...
compiler/rustc_trait_selection/src/solve/search_graph/mod.rs
浏览文件 @
51762886
...
...
@@ -134,9 +134,13 @@ pub(super) fn encountered_overflow(&self) -> bool {
/// Resets `encountered_overflow` of the current goal.
///
/// This should only be used for the check in `evaluate_goal`.
pub
(
super
)
fn
reset_encountered_overflow
(
&
mut
self
,
encountered_overflow
:
bool
)
{
if
encountered_overflow
{
self
.stack.raw
.last_mut
()
.unwrap
()
.encountered_overflow
=
true
;
pub
(
super
)
fn
reset_encountered_overflow
(
&
mut
self
,
encountered_overflow
:
bool
)
->
bool
{
if
let
Some
(
last
)
=
self
.stack.raw
.last_mut
()
{
let
prev
=
last
.encountered_overflow
;
last
.encountered_overflow
=
encountered_overflow
;
prev
}
else
{
false
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录