Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
0d33ab7a
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,发现更多精彩内容 >>
提交
0d33ab7a
编写于
10月 30, 2020
作者:
B
bors
浏览文件
操作
浏览文件
下载
差异文件
Auto merge of #78432 - sexxi-goose:fix-77993-take3, r=nikomatsakis
Handle type errors in closure/generator upvar_tys Fixes #77993
上级
c792f033
5229571a
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
82 addition
and
6 deletion
+82
-6
compiler/rustc_middle/src/ty/sty.rs
compiler/rustc_middle/src/ty/sty.rs
+37
-6
src/test/ui/issues/issue-77993-1.rs
src/test/ui/issues/issue-77993-1.rs
+12
-0
src/test/ui/issues/issue-77993-1.stderr
src/test/ui/issues/issue-77993-1.stderr
+16
-0
src/test/ui/issues/issue-77993-2.rs
src/test/ui/issues/issue-77993-2.rs
+9
-0
src/test/ui/issues/issue-77993-2.stderr
src/test/ui/issues/issue-77993-2.stderr
+8
-0
未找到文件。
compiler/rustc_middle/src/ty/sty.rs
浏览文件 @
0d33ab7a
...
...
@@ -388,9 +388,19 @@ pub fn parent_substs(self) -> &'tcx [GenericArg<'tcx>] {
self
.split
()
.parent_substs
}
/// Returns an iterator over the list of types of captured paths by the closure.
/// In case there was a type error in figuring out the types of the captured path, an
/// empty iterator is returned.
#[inline]
pub
fn
upvar_tys
(
self
)
->
impl
Iterator
<
Item
=
Ty
<
'tcx
>>
+
'tcx
{
self
.tupled_upvars_ty
()
.tuple_fields
()
match
self
.tupled_upvars_ty
()
.kind
()
{
TyKind
::
Error
(
_
)
=>
None
,
TyKind
::
Tuple
(
..
)
=>
Some
(
self
.tupled_upvars_ty
()
.tuple_fields
()),
TyKind
::
Infer
(
_
)
=>
bug!
(
"upvar_tys called before capture types are inferred"
),
ty
=>
bug!
(
"Unexpected representation of upvar types tuple {:?}"
,
ty
),
}
.into_iter
()
.flatten
()
}
/// Returns the tuple type representing the upvars for this closure.
...
...
@@ -515,9 +525,19 @@ pub fn witness(self) -> Ty<'tcx> {
self
.split
()
.witness
.expect_ty
()
}
/// Returns an iterator over the list of types of captured paths by the generator.
/// In case there was a type error in figuring out the types of the captured path, an
/// empty iterator is returned.
#[inline]
pub
fn
upvar_tys
(
self
)
->
impl
Iterator
<
Item
=
Ty
<
'tcx
>>
+
'tcx
{
self
.tupled_upvars_ty
()
.tuple_fields
()
match
self
.tupled_upvars_ty
()
.kind
()
{
TyKind
::
Error
(
_
)
=>
None
,
TyKind
::
Tuple
(
..
)
=>
Some
(
self
.tupled_upvars_ty
()
.tuple_fields
()),
TyKind
::
Infer
(
_
)
=>
bug!
(
"upvar_tys called before capture types are inferred"
),
ty
=>
bug!
(
"Unexpected representation of upvar types tuple {:?}"
,
ty
),
}
.into_iter
()
.flatten
()
}
/// Returns the tuple type representing the upvars for this generator.
...
...
@@ -660,13 +680,24 @@ pub enum UpvarSubsts<'tcx> {
}
impl
<
'tcx
>
UpvarSubsts
<
'tcx
>
{
/// Returns an iterator over the list of types of captured paths by the closure/generator.
/// In case there was a type error in figuring out the types of the captured path, an
/// empty iterator is returned.
#[inline]
pub
fn
upvar_tys
(
self
)
->
impl
Iterator
<
Item
=
Ty
<
'tcx
>>
+
'tcx
{
let
tupled_
upvars_ty
=
match
self
{
UpvarSubsts
::
Closure
(
substs
)
=>
substs
.as_closure
()
.
split
()
.tupled_upvars_ty
,
UpvarSubsts
::
Generator
(
substs
)
=>
substs
.as_generator
()
.
split
()
.tupled_upvars_ty
,
let
tupled_
tys
=
match
self
{
UpvarSubsts
::
Closure
(
substs
)
=>
substs
.as_closure
()
.
tupled_upvars_ty
()
,
UpvarSubsts
::
Generator
(
substs
)
=>
substs
.as_generator
()
.
tupled_upvars_ty
()
,
};
tupled_upvars_ty
.expect_ty
()
.tuple_fields
()
match
tupled_tys
.kind
()
{
TyKind
::
Error
(
_
)
=>
None
,
TyKind
::
Tuple
(
..
)
=>
Some
(
self
.tupled_upvars_ty
()
.tuple_fields
()),
TyKind
::
Infer
(
_
)
=>
bug!
(
"upvar_tys called before capture types are inferred"
),
ty
=>
bug!
(
"Unexpected representation of upvar types tuple {:?}"
,
ty
),
}
.into_iter
()
.flatten
()
}
#[inline]
...
...
src/test/ui/issues/issue-77993-1.rs
0 → 100644
浏览文件 @
0d33ab7a
#[derive(Clone)]
struct
InGroup
<
F
>
{
it
:
It
,
//~^ ERROR cannot find type `It` in this scope
f
:
F
,
}
fn
dates_in_year
()
->
impl
Clone
{
InGroup
{
f
:
|
d
|
d
}
//~^ ERROR missing field `it` in initializer of `InGroup<_>`
}
fn
main
()
{}
src/test/ui/issues/issue-77993-1.stderr
0 → 100644
浏览文件 @
0d33ab7a
error[E0412]: cannot find type `It` in this scope
--> $DIR/issue-77993-1.rs:3:9
|
LL | it: It,
| ^^ not found in this scope
error[E0063]: missing field `it` in initializer of `InGroup<_>`
--> $DIR/issue-77993-1.rs:8:5
|
LL | InGroup { f: |d| d }
| ^^^^^^^ missing `it`
error: aborting due to 2 previous errors
Some errors have detailed explanations: E0063, E0412.
For more information about an error, try `rustc --explain E0063`.
src/test/ui/issues/issue-77993-2.rs
0 → 100644
浏览文件 @
0d33ab7a
// edition:2018
async
fn
test
()
->
Result
<
(),
Box
<
dyn
std
::
error
::
Error
>>
{
macro!
();
//~^ ERROR expected identifier, found `!`
Ok
(())
}
fn
main
()
{}
src/test/ui/issues/issue-77993-2.stderr
0 → 100644
浏览文件 @
0d33ab7a
error: expected identifier, found `!`
--> $DIR/issue-77993-2.rs:4:10
|
LL | macro!();
| ^ expected identifier
error: aborting due to previous error
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录