From dac59ac93afa3ca13adc1bab5eaa9bd2445ee868 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Wed, 6 Dec 2017 16:18:28 -0500 Subject: [PATCH] escape-argument-callee: improve comment per arielb1's suggestions --- .../escape-argument-callee.rs | 15 +++++++---- .../escape-argument-callee.stderr | 26 +++++++++---------- 2 files changed, 23 insertions(+), 18 deletions(-) diff --git a/src/test/ui/nll/closure-requirements/escape-argument-callee.rs b/src/test/ui/nll/closure-requirements/escape-argument-callee.rs index dae8c842240..1e34aaf1ea0 100644 --- a/src/test/ui/nll/closure-requirements/escape-argument-callee.rs +++ b/src/test/ui/nll/closure-requirements/escape-argument-callee.rs @@ -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 diff --git a/src/test/ui/nll/closure-requirements/escape-argument-callee.stderr b/src/test/ui/nll/closure-requirements/escape-argument-callee.stderr index 2d36143d5b3..c842d51a2ad 100644 --- a/src/test/ui/nll/closure-requirements/escape-argument-callee.stderr +++ b/src/test/ui/nll/closure-requirements/escape-argument-callee.stderr @@ -1,19 +1,19 @@ 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 []