Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
5bea48ba
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,发现更多精彩内容 >>
提交
5bea48ba
编写于
8月 02, 2023
作者:
M
Michael Goulet
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
separate calculation and interning of external query constraints
上级
defed625
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
28 addition
and
27 deletion
+28
-27
compiler/rustc_trait_selection/src/solve/eval_ctxt/canonical.rs
...er/rustc_trait_selection/src/solve/eval_ctxt/canonical.rs
+28
-27
未找到文件。
compiler/rustc_trait_selection/src/solve/eval_ctxt/canonical.rs
浏览文件 @
5bea48ba
...
...
@@ -18,7 +18,7 @@
use
rustc_infer
::
infer
::
canonical
::{
CanonicalExt
,
QueryRegionConstraints
};
use
rustc_middle
::
traits
::
query
::
NoSolution
;
use
rustc_middle
::
traits
::
solve
::{
ExternalConstraints
,
ExternalConstraintsData
,
MaybeCause
,
PredefinedOpaquesData
,
QueryInput
,
ExternalConstraintsData
,
MaybeCause
,
PredefinedOpaquesData
,
QueryInput
,
};
use
rustc_middle
::
ty
::{
self
,
BoundVar
,
GenericArgKind
,
Ty
,
TyCtxt
,
TypeFoldable
};
use
rustc_span
::
DUMMY_SP
;
...
...
@@ -69,35 +69,36 @@ pub(in crate::solve) fn evaluate_added_goals_and_make_canonical_response(
previous call to `try_evaluate_added_goals!`"
);
let
certainty
=
certainty
.unify_with
(
goals_certainty
);
if
let
Certainty
::
OVERFLOW
=
certainty
{
// If we have overflow, it's probable that we're substituting a type
// into itself infinitely and any partial substitutions in the query
// response are probably not useful anyways, so just return an empty
// query response.
//
// This may prevent us from potentially useful inference, e.g.
// 2 candidates, one ambiguous and one overflow, which both
// have the same inference constraints.
//
// Changing this to retain some constraints in the future
// won't be a breaking change, so this is good enough for now.
return
Ok
(
self
.make_ambiguous_response_no_constraints
(
MaybeCause
::
Overflow
));
}
let
response
=
match
certainty
{
Certainty
::
Yes
|
Certainty
::
Maybe
(
MaybeCause
::
Ambiguity
)
=>
{
let
external_constraints
=
self
.compute_external_query_constraints
()
?
;
Response
{
var_values
:
self
.var_values
,
external_constraints
,
certainty
}
}
Certainty
::
Maybe
(
MaybeCause
::
Overflow
)
=>
{
// If we have overflow, it's probable that we're substituting a type
// into itself infinitely and any partial substitutions in the query
// response are probably not useful anyways, so just return an empty
// query response.
//
// This may prevent us from potentially useful inference, e.g.
// 2 candidates, one ambiguous and one overflow, which both
// have the same inference constraints.
//
// Changing this to retain some constraints in the future
// won't be a breaking change, so this is good enough for now.
return
Ok
(
self
.make_ambiguous_response_no_constraints
(
MaybeCause
::
Overflow
));
}
};
let
certainty
=
certainty
.unify_with
(
goals_certainty
);
let
var_values
=
self
.var_values
;
let
external_constraints
=
self
.compute_external_query_constraints
()
?
;
let
canonical
=
Canonicalizer
::
canonicalize
(
self
.infcx
,
CanonicalizeMode
::
Response
{
max_input_universe
:
self
.max_input_universe
},
&
mut
Default
::
default
(),
response
,
Response
{
var_values
,
certainty
,
external_constraints
:
self
.tcx
()
.mk_external_constraints
(
external_constraints
),
},
);
Ok
(
canonical
)
}
...
...
@@ -143,7 +144,9 @@ pub(in crate::solve) fn make_ambiguous_response_no_constraints(
/// further constrained by inference, that will be passed back in the var
/// values.
#[instrument(level
=
"debug"
,
skip(self),
ret)]
fn
compute_external_query_constraints
(
&
self
)
->
Result
<
ExternalConstraints
<
'tcx
>
,
NoSolution
>
{
fn
compute_external_query_constraints
(
&
self
,
)
->
Result
<
ExternalConstraintsData
<
'tcx
>
,
NoSolution
>
{
// We only check for leaks from universes which were entered inside
// of the query.
self
.infcx
.leak_check
(
self
.max_input_universe
,
None
)
.map_err
(|
e
|
{
...
...
@@ -173,9 +176,7 @@ fn compute_external_query_constraints(&self) -> Result<ExternalConstraints<'tcx>
self
.predefined_opaques_in_body.opaque_types
.iter
()
.all
(|(
pa
,
_
)|
pa
!=
a
)
});
Ok
(
self
.tcx
()
.mk_external_constraints
(
ExternalConstraintsData
{
region_constraints
,
opaque_types
}))
Ok
(
ExternalConstraintsData
{
region_constraints
,
opaque_types
})
}
/// After calling a canonical query, we apply the constraints returned
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录