Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
ef1a40d5
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,发现更多精彩内容 >>
提交
ef1a40d5
编写于
10月 12, 2018
作者:
M
Matthew Jasper
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Propagate bounds from generators
上级
121320d5
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
57 addition
and
19 deletion
+57
-19
src/librustc_mir/borrow_check/nll/region_infer/mod.rs
src/librustc_mir/borrow_check/nll/region_infer/mod.rs
+4
-8
src/librustc_mir/borrow_check/nll/type_check/mod.rs
src/librustc_mir/borrow_check/nll/type_check/mod.rs
+6
-9
src/librustc_mir/borrow_check/nll/universal_regions.rs
src/librustc_mir/borrow_check/nll/universal_regions.rs
+2
-2
src/test/ui/generator/generator-region-requirements.ast.stderr
...est/ui/generator/generator-region-requirements.ast.stderr
+12
-0
src/test/ui/generator/generator-region-requirements.nll.stderr
...est/ui/generator/generator-region-requirements.nll.stderr
+12
-0
src/test/ui/generator/generator-region-requirements.rs
src/test/ui/generator/generator-region-requirements.rs
+21
-0
未找到文件。
src/librustc_mir/borrow_check/nll/region_infer/mod.rs
浏览文件 @
ef1a40d5
...
...
@@ -1268,7 +1268,7 @@ fn apply_requirements(
tcx
:
TyCtxt
<
'_
,
'gcx
,
'tcx
>
,
location
:
Location
,
closure_def_id
:
DefId
,
closure_substs
:
ty
::
Closure
Substs
<
'tcx
>
,
closure_substs
:
&
'tcx
ty
::
subst
::
Substs
<
'tcx
>
,
)
->
Vec
<
QueryRegionConstraint
<
'tcx
>>
;
fn
subst_closure_mapping
<
T
>
(
...
...
@@ -1299,23 +1299,19 @@ fn apply_requirements(
tcx
:
TyCtxt
<
'_
,
'gcx
,
'tcx
>
,
location
:
Location
,
closure_def_id
:
DefId
,
closure_substs
:
ty
::
Closure
Substs
<
'tcx
>
,
closure_substs
:
&
'tcx
ty
::
subst
::
Substs
<
'tcx
>
,
)
->
Vec
<
QueryRegionConstraint
<
'tcx
>>
{
debug!
(
"apply_requirements(location={:?}, closure_def_id={:?}, closure_substs={:?})"
,
location
,
closure_def_id
,
closure_substs
);
// Get Tu.
let
user_closure_ty
=
tcx
.mk_closure
(
closure_def_id
,
closure_substs
);
debug!
(
"apply_requirements: user_closure_ty={:?}"
,
user_closure_ty
);
// Extract the values of the free regions in `user_closure_ty`
// Extract the values of the free regions in `closure_substs`
// into a vector. These are the regions that we will be
// relating to one another.
let
closure_mapping
=
&
UniversalRegions
::
closure_mapping
(
tcx
,
user_closure_ty
,
closure_substs
,
self
.num_external_vids
,
tcx
.closure_base_def_id
(
closure_def_id
),
);
...
...
src/librustc_mir/borrow_check/nll/type_check/mod.rs
浏览文件 @
ef1a40d5
...
...
@@ -42,7 +42,7 @@
use
rustc
::
traits
::
query
::{
Fallible
,
NoSolution
};
use
rustc
::
traits
::{
ObligationCause
,
PredicateObligations
};
use
rustc
::
ty
::
fold
::
TypeFoldable
;
use
rustc
::
ty
::
subst
::{
Subst
,
UnpackedKind
};
use
rustc
::
ty
::
subst
::{
Subst
,
Substs
,
UnpackedKind
};
use
rustc
::
ty
::{
self
,
RegionVid
,
ToPolyTraitRef
,
Ty
,
TyCtxt
,
TyKind
};
use
std
::
rc
::
Rc
;
use
std
::{
fmt
,
iter
};
...
...
@@ -2075,12 +2075,9 @@ fn prove_aggregate_predicates(
// desugaring. A closure gets desugared to a struct, and
// these extra requirements are basically like where
// clauses on the struct.
AggregateKind
::
Closure
(
def_id
,
substs
)
=>
{
self
.prove_closure_bounds
(
tcx
,
*
def_id
,
*
substs
,
location
)
}
AggregateKind
::
Generator
(
def_id
,
substs
,
_
)
=>
{
tcx
.predicates_of
(
*
def_id
)
.instantiate
(
tcx
,
substs
.substs
)
AggregateKind
::
Closure
(
def_id
,
ty
::
ClosureSubsts
{
substs
})
|
AggregateKind
::
Generator
(
def_id
,
ty
::
GeneratorSubsts
{
substs
},
_
)
=>
{
self
.prove_closure_bounds
(
tcx
,
*
def_id
,
substs
,
location
)
}
AggregateKind
::
Array
(
_
)
|
AggregateKind
::
Tuple
=>
ty
::
InstantiatedPredicates
::
empty
(),
...
...
@@ -2096,7 +2093,7 @@ fn prove_closure_bounds(
&
mut
self
,
tcx
:
TyCtxt
<
'a
,
'gcx
,
'tcx
>
,
def_id
:
DefId
,
substs
:
ty
::
Closure
Substs
<
'tcx
>
,
substs
:
&
'tcx
Substs
<
'tcx
>
,
location
:
Location
,
)
->
ty
::
InstantiatedPredicates
<
'tcx
>
{
if
let
Some
(
closure_region_requirements
)
=
...
...
@@ -2155,7 +2152,7 @@ fn prove_closure_bounds(
);
}
tcx
.predicates_of
(
def_id
)
.instantiate
(
tcx
,
substs
.substs
)
tcx
.predicates_of
(
def_id
)
.instantiate
(
tcx
,
substs
)
}
fn
prove_trait_ref
(
...
...
src/librustc_mir/borrow_check/nll/universal_regions.rs
浏览文件 @
ef1a40d5
...
...
@@ -232,13 +232,13 @@ pub fn new(
/// `V[1]: V[2]`.
pub
fn
closure_mapping
(
tcx
:
TyCtxt
<
'_
,
'_
,
'tcx
>
,
closure_
ty
:
Ty
<
'tcx
>
,
closure_
substs
:
&
'tcx
Substs
<
'tcx
>
,
expected_num_vars
:
usize
,
closure_base_def_id
:
DefId
,
)
->
IndexVec
<
RegionVid
,
ty
::
Region
<
'tcx
>>
{
let
mut
region_mapping
=
IndexVec
::
with_capacity
(
expected_num_vars
);
region_mapping
.push
(
tcx
.types.re_static
);
tcx
.for_each_free_region
(
&
closure_
ty
,
|
fr
|
{
tcx
.for_each_free_region
(
&
closure_
substs
,
|
fr
|
{
region_mapping
.push
(
fr
);
});
...
...
src/test/ui/generator/generator-region-requirements.ast.stderr
0 → 100644
浏览文件 @
ef1a40d5
error[E0621]: explicit lifetime required in the type of `x`
--> $DIR/generator-region-requirements.rs:15:51
|
LL | fn dangle(x: &mut i32) -> &'static mut i32 {
| -------- help: add explicit lifetime `'static` to the type of `x`: `&'static mut i32`
...
LL | GeneratorState::Complete(c) => return c,
| ^ lifetime `'static` required
error: aborting due to previous error
For more information about this error, try `rustc --explain E0621`.
src/test/ui/generator/generator-region-requirements.nll.stderr
0 → 100644
浏览文件 @
ef1a40d5
error[E0621]: explicit lifetime required in the type of `x`
--> $DIR/generator-region-requirements.rs:11:9
|
LL | fn dangle(x: &mut i32) -> &'static mut i32 {
| -------- help: add explicit lifetime `'static` to the type of `x`: `&'static mut i32`
...
LL | x
| ^ lifetime `'static` required
error: aborting due to previous error
For more information about this error, try `rustc --explain E0621`.
src/test/ui/generator/generator-region-requirements.rs
0 → 100644
浏览文件 @
ef1a40d5
// revisions: ast nll
// ignore-compare-mode-nll
#![feature(generators,
generator_trait)]
#![cfg_attr(nll,
feature(nll))]
use
std
::
ops
::{
Generator
,
GeneratorState
};
fn
dangle
(
x
:
&
mut
i32
)
->
&
'static
mut
i32
{
let
mut
g
=
||
{
yield
;
x
};
loop
{
match
unsafe
{
g
.resume
()
}
{
GeneratorState
::
Complete
(
c
)
=>
return
c
,
GeneratorState
::
Yielded
(
_
)
=>
(),
}
}
}
fn
main
()
{}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录