提交 dac59ac9 编写于 作者: N Niko Matsakis

escape-argument-callee: improve comment per arielb1's suggestions

上级 05977fe7
......@@ -10,12 +10,17 @@
// Test closure that:
//
// - takes an argument `y`
// - stores `y` into another, longer-lived spot
// - takes an argument `y` with lifetime `'a` (in the code, it's anonymous)
// - stores `y` into another, longer-lived spot with lifetime `'b`
//
// *but* the signature of the closure doesn't indicate that `y` lives
// long enough for that. The closure reports the error (and hence we
// see it before the closure's "external requirements" report).
// Because `'a` and `'b` are two different, unrelated higher-ranked
// regions with no relationship to one another, this is an error. This
// error is reported by the closure itself and is not propagated to
// its creator: this is because `'a` and `'b` are higher-ranked
// (late-bound) regions and the closure is not allowed to propagate
// additional where clauses between higher-ranked regions, only those
// that appear free in its type (hence, we see it before the closure's
// "external requirements" report).
// compile-flags:-Znll -Zborrowck=mir -Zverbose
......
warning: not reporting region error due to -Znll
--> $DIR/escape-argument-callee.rs:31:50
--> $DIR/escape-argument-callee.rs:36:50
|
31 | let mut closure = expect_sig(|p, y| *p = y);
36 | let mut closure = expect_sig(|p, y| *p = y);
| ^
error: free region `'_#4r` does not outlive free region `'_#3r`
--> $DIR/escape-argument-callee.rs:31:45
--> $DIR/escape-argument-callee.rs:36:45
|
31 | let mut closure = expect_sig(|p, y| *p = y);
36 | let mut closure = expect_sig(|p, y| *p = y);
| ^^^^^^
note: External requirements
--> $DIR/escape-argument-callee.rs:31:38
--> $DIR/escape-argument-callee.rs:36:38
|
31 | let mut closure = expect_sig(|p, y| *p = y);
36 | let mut closure = expect_sig(|p, y| *p = y);
| ^^^^^^^^^^^^^
|
= note: defining type: DefId(0/1:9 ~ escape_argument_callee[317d]::test[0]::{{closure}}[0]) with closure substs [
......@@ -23,15 +23,15 @@ note: External requirements
= note: number of external vids: 1
note: No external requirements
--> $DIR/escape-argument-callee.rs:25:1
--> $DIR/escape-argument-callee.rs:30:1
|
25 | / fn test() {
26 | | let x = 44;
27 | | let mut p = &x;
28 | |
30 | / fn test() {
31 | | let x = 44;
32 | | let mut p = &x;
33 | |
... |
37 | | deref(p);
38 | | }
42 | | deref(p);
43 | | }
| |_^
|
= note: defining type: DefId(0/0:3 ~ escape_argument_callee[317d]::test[0]) with substs []
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册