Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
669a4035
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,发现更多精彩内容 >>
提交
669a4035
编写于
10月 22, 2019
作者:
E
Esteban Küber
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
review comments: move code, fix indentation and change span
上级
0118278c
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
77 addition
and
69 deletion
+77
-69
src/librustc/ty/wf.rs
src/librustc/ty/wf.rs
+51
-39
src/test/ui/associated-types/point-at-type-on-obligation-failure-2.stderr
...ciated-types/point-at-type-on-obligation-failure-2.stderr
+6
-7
src/test/ui/associated-types/point-at-type-on-obligation-failure.stderr
...sociated-types/point-at-type-on-obligation-failure.stderr
+6
-8
src/test/ui/issues/issue-43784-associated-type.stderr
src/test/ui/issues/issue-43784-associated-type.stderr
+8
-8
src/test/ui/traits/cycle-cache-err-60010.stderr
src/test/ui/traits/cycle-cache-err-60010.stderr
+6
-7
未找到文件。
src/librustc/ty/wf.rs
浏览文件 @
669a4035
...
...
@@ -170,55 +170,67 @@ fn compute_trait_ref(&mut self, trait_ref: &ty::TraitRef<'tcx>, elaborate: Elabo
let
cause
=
self
.cause
(
traits
::
MiscObligation
);
let
param_env
=
self
.param_env
;
if
let
Elaborate
::
All
=
elaborate
{
let
trait_assoc_items
=
tcx
.associated_items
(
trait_ref
.def_id
);
let
predicates
=
obligations
.iter
()
.map
(|
obligation
|
obligation
.predicate
.clone
())
.collect
();
let
implied_obligations
=
traits
::
elaborate_predicates
(
tcx
,
predicates
);
let
item_span
:
Option
<
Span
>
=
self
.item
.map
(|
i
|
i
.span
);
let
item
=
&
self
.item
;
let
implied_obligations
=
implied_obligations
.map
(|
pred
|
{
let
mut
cause
=
cause
.clone
();
match
&
pred
{
ty
::
Predicate
::
Projection
(
proj
)
=>
{
if
let
Some
(
hir
::
ItemKind
::
Impl
(
..
,
impl_items
))
=
item
.map
(|
i
|
&
i
.kind
)
{
let
trait_assoc_item
=
tcx
.associated_item
(
proj
.projection_def_id
());
if
let
Some
(
impl_item
)
=
impl_items
.iter
()
.filter
(|
item
|
{
item
.ident
==
trait_assoc_item
.ident
})
.next
()
{
cause
.span
=
impl_item
.span
;
cause
.code
=
traits
::
AssocTypeBound
(
item_span
,
trait_assoc_item
.ident.span
,
);
}
let
item
=
&
self
.item
;
let
extend_cause_with_original_assoc_item_obligation
=
|
cause
:
&
mut
traits
::
ObligationCause
<
'_
>
,
pred
:
&
ty
::
Predicate
<
'_
>
,
trait_assoc_items
:
ty
::
AssocItemsIterator
<
'_
>
,
|
{
let
item_span
=
item
.map
(|
i
|
tcx
.sess
.source_map
()
.def_span
(
i
.span
));
match
pred
{
ty
::
Predicate
::
Projection
(
proj
)
=>
{
if
let
Some
(
hir
::
ItemKind
::
Impl
(
..
,
impl_items
))
=
item
.map
(|
i
|
&
i
.kind
)
{
let
trait_assoc_item
=
tcx
.associated_item
(
proj
.projection_def_id
());
if
let
Some
(
impl_item
)
=
impl_items
.iter
()
.filter
(|
item
|
{
item
.ident
==
trait_assoc_item
.ident
})
.next
()
{
cause
.span
=
impl_item
.span
;
cause
.code
=
traits
::
AssocTypeBound
(
item_span
,
trait_assoc_item
.ident.span
,
);
}
}
ty
::
Predicate
::
Trait
(
proj
)
=>
{
}
ty
::
Predicate
::
Trait
(
proj
)
=>
{
if
let
(
ty
::
Projection
(
ty
::
ProjectionTy
{
item_def_id
,
..
}),
Some
(
hir
::
ItemKind
::
Impl
(
..
,
impl_items
)),
)
=
(
&
proj
.skip_binder
()
.self_ty
()
.kind
,
item
.map
(|
i
|
&
i
.kind
))
{
if
let
Some
((
impl_item
,
trait_assoc_item
))
=
trait_assoc_items
.clone
()
Some
(
hir
::
ItemKind
::
Impl
(
..
,
impl_items
)),
)
=
(
&
proj
.skip_binder
()
.self_ty
()
.kind
,
item
.map
(|
i
|
&
i
.kind
))
{
if
let
Some
((
impl_item
,
trait_assoc_item
))
=
trait_assoc_items
.filter
(|
i
|
i
.def_id
==
*
item_def_id
)
.next
()
.and_then
(|
trait_assoc_item
|
impl_items
.iter
()
.filter
(|
i
|
i
.ident
==
trait_assoc_item
.ident
)
.next
()
.map
(|
impl_item
|
(
impl_item
,
trait_assoc_item
)))
.and_then
(|
trait_assoc_item
|
impl_items
.iter
()
.filter
(|
i
|
i
.ident
==
trait_assoc_item
.ident
)
.next
()
.map
(|
impl_item
|
(
impl_item
,
trait_assoc_item
)))
{
cause
.span
=
impl_item
.span
;
cause
.code
=
traits
::
AssocTypeBound
(
item_span
,
trait_assoc_item
.ident.span
,
);
}
cause
.span
=
impl_item
.span
;
cause
.code
=
traits
::
AssocTypeBound
(
item_span
,
trait_assoc_item
.ident.span
,
);
}
}
_
=>
{}
}
_
=>
{}
}
};
if
let
Elaborate
::
All
=
elaborate
{
let
trait_assoc_items
=
tcx
.associated_items
(
trait_ref
.def_id
);
let
predicates
=
obligations
.iter
()
.map
(|
obligation
|
obligation
.predicate
.clone
())
.collect
();
let
implied_obligations
=
traits
::
elaborate_predicates
(
tcx
,
predicates
);
let
implied_obligations
=
implied_obligations
.map
(|
pred
|
{
let
mut
cause
=
cause
.clone
();
extend_cause_with_original_assoc_item_obligation
(
&
mut
cause
,
&
pred
,
trait_assoc_items
.clone
(),
);
traits
::
Obligation
::
new
(
cause
,
param_env
,
pred
)
});
self
.out
.extend
(
implied_obligations
);
...
...
src/test/ui/associated-types/point-at-type-on-obligation-failure-2.stderr
浏览文件 @
669a4035
error[E0277]: the trait bound `bool: Bar` is not satisfied
--> $DIR/point-at-type-on-obligation-failure-2.rs:8:5
|
LL |
type Assoc: Bar;
|
----- associated type defined here
LL | type Assoc: Bar;
| ----- associated type defined here
...
LL | / impl Foo for () {
LL | | type Assoc = bool;
| | ^^^^^^^^^^^^^^^^^^ the trait `Bar` is not implemented for `bool`
LL | | }
| |_- in this `impl` item
LL | impl Foo for () {
| --------------- in this `impl` item
LL | type Assoc = bool;
| ^^^^^^^^^^^^^^^^^^ the trait `Bar` is not implemented for `bool`
error: aborting due to previous error
...
...
src/test/ui/associated-types/point-at-type-on-obligation-failure.stderr
浏览文件 @
669a4035
error[E0271]: type mismatch resolving `<Foo2 as Bar2>::Ok == ()`
--> $DIR/point-at-type-on-obligation-failure.rs:13:5
|
LL |
type Ok;
|
-- associated type defined here
LL | type Ok;
| -- associated type defined here
...
LL | / impl Bar for Foo {
LL | | type Ok = ();
| | ^^^^^^^^^^^^^ expected u32, found ()
LL | | type Sibling = Foo2;
LL | | }
| |_- in this `impl` item
LL | impl Bar for Foo {
| ---------------- in this `impl` item
LL | type Ok = ();
| ^^^^^^^^^^^^^ expected u32, found ()
|
= note: expected type `u32`
found type `()`
...
...
src/test/ui/issues/issue-43784-associated-type.stderr
浏览文件 @
669a4035
error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied
--> $DIR/issue-43784-associated-type.rs:14:5
|
LL |
type Assoc: Partial<Self>;
|
----- associated type defined here
LL | type Assoc: Partial<Self>;
| ----- associated type defined here
...
LL |
/
impl<T> Complete for T {
|
| - help: consider restricting this bound: `T: std::marker::Copy`
LL | | type Assoc = T;
|
| ^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `T
`
LL |
| }
|
|_- in this `impl` item
LL | impl<T> Complete for T {
|
---------------------- in this `impl` item
| |
|
help: consider restricting this bound: `T: std::marker::Copy
`
LL |
type Assoc = T;
|
^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `T`
|
= help: consider adding a `where T: std::marker::Copy` bound
...
...
src/test/ui/traits/cycle-cache-err-60010.stderr
浏览文件 @
669a4035
...
...
@@ -9,14 +9,13 @@ LL | _parse: <ParseQuery as Query<RootDatabase>>::Data,
error[E0275]: overflow evaluating the requirement `RootDatabase: SourceDatabase`
--> $DIR/cycle-cache-err-60010.rs:31:5
|
LL |
type Storage;
|
------- associated type defined here
LL | type Storage;
| ------- associated type defined here
...
LL | / impl Database for RootDatabase {
LL | | type Storage = SalsaStorage;
| | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
LL | | }
| |_- in this `impl` item
LL | impl Database for RootDatabase {
| ------------------------------ in this `impl` item
LL | type Storage = SalsaStorage;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: required because of the requirements on the impl of `Query<RootDatabase>` for `ParseQuery`
= note: required because it appears within the type `SalsaStorage`
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录