Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
6ee31e2a
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,发现更多精彩内容 >>
提交
6ee31e2a
编写于
12月 06, 2017
作者:
N
Niko Matsakis
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
escape-upvar-ref: patch comment per arielb1
上级
8b657d37
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
21 addition
and
14 deletion
+21
-14
src/test/ui/nll/closure-requirements/escape-upvar-ref.rs
src/test/ui/nll/closure-requirements/escape-upvar-ref.rs
+9
-2
src/test/ui/nll/closure-requirements/escape-upvar-ref.stderr
src/test/ui/nll/closure-requirements/escape-upvar-ref.stderr
+12
-12
未找到文件。
src/test/ui/nll/closure-requirements/escape-upvar-ref.rs
浏览文件 @
6ee31e2a
...
...
@@ -9,8 +9,15 @@
// except according to those terms.
// Test closure that:
// - captures a variable `y`
// - stores reference to `y` into another, longer-lived spot
//
// - captures a variable `y` by reference
// - stores that reference to `y` into another, longer-lived place (`p`)
//
// Both of these are upvars of reference type (the capture of `y` is
// of type `&'a i32`, the capture of `p` is of type `&mut &'b
// i32`). The closure thus computes a relationship between `'a` and
// `'b`. This relationship is propagated to the closure creator,
// which reports an error.
// compile-flags:-Znll -Zborrowck=mir -Zverbose
...
...
src/test/ui/nll/closure-requirements/escape-upvar-ref.stderr
浏览文件 @
6ee31e2a
note: External requirements
--> $DIR/escape-upvar-ref.rs:
26
:27
--> $DIR/escape-upvar-ref.rs:
33
:27
|
26
| let mut closure = || p = &y;
33
| let mut closure = || p = &y;
| ^^^^^^^^^
|
= note: defining type: DefId(0/1:9 ~ escape_upvar_ref[317d]::test[0]::{{closure}}[0]) with closure substs [
...
...
@@ -14,26 +14,26 @@ note: External requirements
= note: where '_#3r: '_#2r
note: No external requirements
--> $DIR/escape-upvar-ref.rs:2
0
:1
--> $DIR/escape-upvar-ref.rs:2
7
:1
|
2
0
| / fn test() {
2
1
| | let x = 44;
2
2
| | let mut p = &x;
23
| |
2
7
| / fn test() {
2
8
| | let x = 44;
2
9
| | let mut p = &x;
30
| |
... |
3
0
| | deref(p);
3
1
| | }
3
7
| | deref(p);
3
8
| | }
| |_^
|
= note: defining type: DefId(0/0:3 ~ escape_upvar_ref[317d]::test[0]) with substs []
error[E0597]: borrowed value does not live long enough
--> $DIR/escape-upvar-ref.rs:
28
:6
--> $DIR/escape-upvar-ref.rs:
35
:6
|
25
| let y = 22;
32
| let y = 22;
| - temporary value created here
...
28
| } //~ ERROR borrowed value does not live long enough
35
| } //~ ERROR borrowed value does not live long enough
| ^ temporary value dropped here while still borrowed
|
= note: consider using a `let` binding to increase its lifetime
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录