Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
2062f2ca
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,发现更多精彩内容 >>
提交
2062f2ca
编写于
7月 20, 2023
作者:
L
lcnr
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
review
上级
7c97a76b
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
37 addition
and
27 deletion
+37
-27
compiler/rustc_trait_selection/src/solve/assembly/mod.rs
compiler/rustc_trait_selection/src/solve/assembly/mod.rs
+4
-4
tests/ui/traits/new-solver/assembly/assemble-normalizing-self-ty-impl-ambiguity.rs
...r/assembly/assemble-normalizing-self-ty-impl-ambiguity.rs
+2
-0
tests/ui/traits/new-solver/assembly/assemble-normalizing-self-ty-impl-ambiguity.stderr
...sembly/assemble-normalizing-self-ty-impl-ambiguity.stderr
+0
-23
tests/ui/traits/new-solver/dont-normalize-proj-with-error.rs
tests/ui/traits/new-solver/dont-normalize-proj-with-error.rs
+22
-0
tests/ui/traits/new-solver/dont-normalize-proj-with-error.stderr
...i/traits/new-solver/dont-normalize-proj-with-error.stderr
+9
-0
未找到文件。
compiler/rustc_trait_selection/src/solve/assembly/mod.rs
浏览文件 @
2062f2ca
...
...
@@ -311,7 +311,7 @@ pub(super) fn assemble_and_evaluate_candidates<G: GoalKind<'tcx>>(
goal
:
Goal
<
'tcx
,
G
>
,
)
->
Vec
<
Candidate
<
'tcx
>>
{
debug_assert_eq!
(
goal
,
self
.resolve_vars_if_possible
(
goal
));
if
let
Some
(
ambig
)
=
self
.
self_ty_infer_ambiguity_hack
(
goal
)
{
if
let
Some
(
ambig
)
=
self
.
assemble_self_ty_infer_ambiguity_response
(
goal
)
{
return
ambig
;
}
...
...
@@ -324,13 +324,13 @@ pub(super) fn assemble_and_evaluate_candidates<G: GoalKind<'tcx>>(
candidates
}
///
HACK: `_
: Trait` is ambiguous, because it may be satisfied via a builtin rule,
///
`?0
: Trait` is ambiguous, because it may be satisfied via a builtin rule,
/// object bound, alias bound, etc. We are unable to determine this until we can at
/// least structurally resolve the type one layer.
///
/// It would also require us to consider all impls of the trait, which is both pretty
/// bad for perf and would also constrain the self type if there is just a single impl.
fn
self_ty_infer_ambiguity_hack
<
G
:
GoalKind
<
'tcx
>>
(
fn
assemble_self_ty_infer_ambiguity_response
<
G
:
GoalKind
<
'tcx
>>
(
&
mut
self
,
goal
:
Goal
<
'tcx
,
G
>
,
)
->
Option
<
Vec
<
Candidate
<
'tcx
>>>
{
...
...
@@ -353,7 +353,7 @@ fn assemble_candidates_via_self_ty<G: GoalKind<'tcx>>(
goal
:
Goal
<
'tcx
,
G
>
,
)
->
Vec
<
Candidate
<
'tcx
>>
{
debug_assert_eq!
(
goal
,
self
.resolve_vars_if_possible
(
goal
));
if
let
Some
(
ambig
)
=
self
.
self_ty_infer_ambiguity_hack
(
goal
)
{
if
let
Some
(
ambig
)
=
self
.
assemble_self_ty_infer_ambiguity_response
(
goal
)
{
return
ambig
;
}
...
...
tests/ui/traits/new-solver/assembly/assemble-normalizing-self-ty-impl-ambiguity.rs
浏览文件 @
2062f2ca
// compile-flags: -Ztrait-solver=next
// check-pass
// Checks that we do not get ambiguity by considering an impl
// multiple times if we're able to normalize the self type.
trait
Trait
<
'a
>
{}
impl
<
'a
,
T
:
'a
>
Trait
<
'a
>
for
T
{}
...
...
tests/ui/traits/new-solver/assembly/assemble-normalizing-self-ty-impl-ambiguity.stderr
已删除
100644 → 0
浏览文件 @
7c97a76b
error[E0283]: type annotations needed: cannot satisfy `<T as Id>::Assoc: Trait<'_>`
--> $DIR/assemble-normalizing-self-ty-impl-ambiguity.rs:19:5
|
LL | impls_trait::<<T as Id>::Assoc>();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: cannot satisfy `<T as Id>::Assoc: Trait<'_>`
note: required by a bound in `impls_trait`
--> $DIR/assemble-normalizing-self-ty-impl-ambiguity.rs:9:23
|
LL | fn impls_trait<'a, T: Trait<'a>>() {}
| ^^^^^^^^^ required by this bound in `impls_trait`
error[E0282]: type annotations needed
--> $DIR/assemble-normalizing-self-ty-impl-ambiguity.rs:24:5
|
LL | impls_trait::<<<() as Id>::Assoc as Id>::Assoc>();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type of the type parameter `T` declared on the function `impls_trait`
error: aborting due to 2 previous errors
Some errors have detailed explanations: E0282, E0283.
For more information about an error, try `rustc --explain E0282`.
tests/ui/traits/new-solver/dont-normalize-proj-with-error.rs
0 → 100644
浏览文件 @
2062f2ca
// compile-flags: -Ztrait-solver=next
// Test that we don't incorrectly leak unconstrained inference variables
// if the projection contained an error. This caused an ICE in writeback.
trait
Mirror
{
type
Assoc
:
?
Sized
;
}
struct
Wrapper
<
T
:
?
Sized
>
(
T
);
impl
<
T
:
?
Sized
>
Mirror
for
Wrapper
<
T
>
{
type
Assoc
=
T
;
}
fn
mirror
<
W
:
Mirror
>
(
_
:
W
)
->
Box
<
W
::
Assoc
>
{
todo!
()
}
fn
type_error
()
->
TypeError
{
todo!
()
}
//~^ ERROR cannot find type `TypeError` in this scope
fn
main
()
{
let
x
=
mirror
(
type_error
());
}
tests/ui/traits/new-solver/dont-normalize-proj-with-error.stderr
0 → 100644
浏览文件 @
2062f2ca
error[E0412]: cannot find type `TypeError` in this scope
--> $DIR/dont-normalize-proj-with-error.rs:17:20
|
LL | fn type_error() -> TypeError { todo!() }
| ^^^^^^^^^ not found in this scope
error: aborting due to previous error
For more information about this error, try `rustc --explain E0412`.
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录