Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
da630de3
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,发现更多精彩内容 >>
未验证
提交
da630de3
编写于
7月 04, 2022
作者:
M
Matthias Krüger
提交者:
GitHub
7月 04, 2022
浏览文件
操作
浏览文件
下载
差异文件
Rollup merge of #98782 - compiler-errors:specialization-error-span, r=oli-obk
Improve spans for specialization error Fixes #98777
上级
82660a25
a368830d
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
31 addition
and
18 deletion
+31
-18
compiler/rustc_typeck/src/impl_wf_check/min_specialization.rs
...iler/rustc_typeck/src/impl_wf_check/min_specialization.rs
+20
-7
src/test/ui/specialization/min_specialization/repeated_projection_type.stderr
...zation/min_specialization/repeated_projection_type.stderr
+3
-3
src/test/ui/specialization/min_specialization/spec-marker-supertraits.stderr
...ization/min_specialization/spec-marker-supertraits.stderr
+2
-2
src/test/ui/specialization/min_specialization/specialization_super_trait.stderr
...tion/min_specialization/specialization_super_trait.stderr
+2
-2
src/test/ui/specialization/min_specialization/specialization_trait.stderr
...ialization/min_specialization/specialization_trait.stderr
+2
-2
src/test/ui/specialization/min_specialization/specialize_on_trait.stderr
...cialization/min_specialization/specialize_on_trait.stderr
+2
-2
未找到文件。
compiler/rustc_typeck/src/impl_wf_check/min_specialization.rs
浏览文件 @
da630de3
...
...
@@ -279,11 +279,16 @@ fn check_predicates<'tcx>(
span
:
Span
,
)
{
let
tcx
=
infcx
.tcx
;
let
impl1_predicates
:
Vec
<
_
>
=
traits
::
elaborate_predicates
(
let
instantiated
=
tcx
.predicates_of
(
impl1_def_id
)
.instantiate
(
tcx
,
impl1_substs
);
let
impl1_predicates
:
Vec
<
_
>
=
traits
::
elaborate_predicates_with_span
(
tcx
,
tcx
.predicates_of
(
impl1_def_id
)
.instantiate
(
tcx
,
impl1_substs
)
.predicates
.into_iter
(),
std
::
iter
::
zip
(
instantiated
.predicates
,
// Don't drop predicates (unsound!) because `spans` is too short
instantiated
.spans
.into_iter
()
.chain
(
std
::
iter
::
repeat
(
span
)),
),
)
.map
(|
obligation
|
obligation
.predicate
)
.map
(|
obligation
|
(
obligation
.predicate
,
obligation
.cause.span
)
)
.collect
();
let
mut
impl2_predicates
=
if
impl2_node
.is_from_trait
()
{
...
...
@@ -321,7 +326,7 @@ fn check_predicates<'tcx>(
// which is sound because we forbid impls like the following
//
// impl<D: Debug> AlwaysApplicable for D { }
let
always_applicable_traits
=
impl1_predicates
.iter
()
.copied
()
.filter
(|
&
predicate
|
{
let
always_applicable_traits
=
impl1_predicates
.iter
()
.copied
()
.filter
(|
&
(
predicate
,
_
)
|
{
matches!
(
trait_predicate_kind
(
tcx
,
predicate
),
Some
(
TraitSpecializationKind
::
AlwaysApplicable
)
...
...
@@ -345,11 +350,11 @@ fn check_predicates<'tcx>(
}
}
impl2_predicates
.extend
(
traits
::
elaborate_predicates
(
tcx
,
always_applicable_traits
)
traits
::
elaborate_predicates
_with_span
(
tcx
,
always_applicable_traits
)
.map
(|
obligation
|
obligation
.predicate
),
);
for
predicate
in
impl1_predicates
{
for
(
predicate
,
span
)
in
impl1_predicates
{
if
!
impl2_predicates
.contains
(
&
predicate
)
{
check_specialization_on
(
tcx
,
predicate
,
span
)
}
...
...
@@ -384,9 +389,17 @@ fn check_specialization_on<'tcx>(tcx: TyCtxt<'tcx>, predicate: ty::Predicate<'tc
.emit
();
}
}
ty
::
PredicateKind
::
Projection
(
ty
::
ProjectionPredicate
{
projection_ty
,
term
})
=>
{
tcx
.sess
.struct_span_err
(
span
,
&
format!
(
"cannot specialize on associated type `{projection_ty} == {term}`"
,),
)
.emit
();
}
_
=>
{
tcx
.sess
.struct_span_err
(
span
,
&
format!
(
"cannot specialize on
`{:?
}`"
,
predicate
))
.struct_span_err
(
span
,
&
format!
(
"cannot specialize on
predicate `{
}`"
,
predicate
))
.emit
();
}
}
...
...
src/test/ui/specialization/min_specialization/repeated_projection_type.stderr
浏览文件 @
da630de3
error: cannot specialize on
`Binder(ProjectionPredicate(ProjectionTy { substs: [V], item_def_id: DefId(0:6 ~ repeated_projection_type[54ea]::Id::This) }, Ty((I,))), []
)`
--> $DIR/repeated_projection_type.rs:19:1
error: cannot specialize on
associated type `<V as Id>::This == (I,
)`
--> $DIR/repeated_projection_type.rs:19:1
5
|
LL | impl<I, V: Id<This = (I,)>> X for V {
|
^^^^^^^^^^^^^^^^^^^^^^^^
^^^^^^^^^^^
|
^^^^^^^^^^^
error: aborting due to previous error
src/test/ui/specialization/min_specialization/spec-marker-supertraits.stderr
浏览文件 @
da630de3
error: cannot specialize on trait `HasMethod`
--> $DIR/spec-marker-supertraits.rs:22:
1
--> $DIR/spec-marker-supertraits.rs:22:
9
|
LL | impl<T: Marker> Spec for T {
|
^^^^^^^^^^^^^^^^^^^^
^^^^^^
|
^^^^^^
error: aborting due to previous error
src/test/ui/specialization/min_specialization/specialization_super_trait.stderr
浏览文件 @
da630de3
error: cannot specialize on trait `Default`
--> $DIR/specialization_super_trait.rs:13:
1
--> $DIR/specialization_super_trait.rs:13:
9
|
LL | impl<T: Default> SpecMarker for T {
|
^^^^^^^^^^^^^^^^^^^^^^^^^^
^^^^^^^
|
^^^^^^^
error: aborting due to previous error
src/test/ui/specialization/min_specialization/specialization_trait.stderr
浏览文件 @
da630de3
...
...
@@ -11,10 +11,10 @@ LL | impl<T> SpecMarker for (T, T) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: cannot specialize on trait `Clone`
--> $DIR/specialization_trait.rs:21:
1
--> $DIR/specialization_trait.rs:21:
9
|
LL | impl<T: Clone> SpecMarker for [T] {
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
^^^^^
|
^^^^^
error: aborting due to 3 previous errors
src/test/ui/specialization/min_specialization/specialize_on_trait.stderr
浏览文件 @
da630de3
error: cannot specialize on trait `SpecMarker`
--> $DIR/specialize_on_trait.rs:15:
1
--> $DIR/specialize_on_trait.rs:15:
9
|
LL | impl<T: SpecMarker> X for T {
|
^^^^^^^^^^^^^^^^^
^^^^^^^^^^
|
^^^^^^^^^^
error: aborting due to previous error
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录