-
Notifications
You must be signed in to change notification settings - Fork 12.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test more failure cases for approximating the "longer" side
as suggested by arielb1
- Loading branch information
1 parent
ca60826
commit 2a17b93
Showing
5 changed files
with
157 additions
and
48 deletions.
There are no files selected for viewing
46 changes: 0 additions & 46 deletions
46
src/test/ui/nll/closure-requirements/propagate-approximated-to-empty.stderr
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
src/test/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-no-bounds.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
warning: not reporting region error due to -Znll | ||
--> $DIR/propagate-fail-to-approximate-longer-no-bounds.rs:47:9 | ||
| | ||
47 | demand_y(x, y, x.get()) | ||
| ^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: free region `'_#6r` does not outlive free region `'_#4r` | ||
--> $DIR/propagate-fail-to-approximate-longer-no-bounds.rs:47:21 | ||
| | ||
47 | demand_y(x, y, x.get()) | ||
| ^ | ||
|
||
note: External requirements | ||
--> $DIR/propagate-fail-to-approximate-longer-no-bounds.rs:45:47 | ||
| | ||
45 | establish_relationships(&cell_a, &cell_b, |_outlives, x, y| { | ||
| _______________________________________________^ | ||
46 | | // Only works if 'x: 'y: | ||
47 | | demand_y(x, y, x.get()) | ||
48 | | //~^ WARN not reporting region error due to -Znll | ||
49 | | //~| ERROR free region `'_#6r` does not outlive free region `'_#4r` | ||
50 | | }); | ||
| |_____^ | ||
| | ||
= note: defining type: DefId(0/1:18 ~ propagate_fail_to_approximate_longer_no_bounds[317d]::supply[0]::{{closure}}[0]) with closure substs [ | ||
i16, | ||
for<'r, 's, 't0, 't1, 't2> extern "rust-call" fn((&ReLateBound(DebruijnIndex { depth: 1 }, BrNamed(crate0:DefIndex(0:0), 'r)) std::cell::Cell<&ReLateBound(DebruijnIndex { depth: 1 }, BrNamed(crate0:DefIndex(0:0), 's)) &'_#1r u32>, &ReLateBound(DebruijnIndex { depth: 1 }, BrNamed(crate0:DefIndex(0:0), 't0)) std::cell::Cell<&ReLateBound(DebruijnIndex { depth: 1 }, BrNamed(crate0:DefIndex(0:0), 't1)) u32>, &ReLateBound(DebruijnIndex { depth: 1 }, BrNamed(crate0:DefIndex(0:0), 't2)) std::cell::Cell<&ReLateBound(DebruijnIndex { depth: 1 }, BrNamed(crate0:DefIndex(0:0), 's)) u32>)) | ||
] | ||
= note: number of external vids: 2 | ||
|
||
note: No external requirements | ||
--> $DIR/propagate-fail-to-approximate-longer-no-bounds.rs:44:1 | ||
| | ||
44 | / fn supply<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) { | ||
45 | | establish_relationships(&cell_a, &cell_b, |_outlives, x, y| { | ||
46 | | // Only works if 'x: 'y: | ||
47 | | demand_y(x, y, x.get()) | ||
... | | ||
50 | | }); | ||
51 | | } | ||
| |_^ | ||
| | ||
= note: defining type: DefId(0/0:6 ~ propagate_fail_to_approximate_longer_no_bounds[317d]::supply[0]) with substs [] | ||
|
||
error: aborting due to previous error | ||
|
57 changes: 57 additions & 0 deletions
57
src/test/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-wrong-bounds.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT | ||
// file at the top-level directory of this distribution and at | ||
// http://rust-lang.org/COPYRIGHT. | ||
// | ||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
// Similarly to escape-argument-callee, a test case where the closure | ||
// requires a relationship between 2 unrelated higher-ranked regions, | ||
// with no helpful relations between the HRRs and free regions. | ||
// | ||
// In this case, the error is reported by the closure itself. This is | ||
// because it is unable to approximate the higher-ranked region `'x`, | ||
// as it only knows of regions that `'x` is outlived by, and none that | ||
// `'x` outlives. | ||
|
||
// compile-flags:-Znll -Zborrowck=mir -Zverbose | ||
|
||
#![feature(rustc_attrs)] | ||
|
||
use std::cell::Cell; | ||
|
||
// Callee knows that: | ||
// | ||
// 'a: 'x | ||
// 'b: 'y | ||
// | ||
// but this doesn't really help us in proving that `'x: 'y`, so | ||
// closure gets an error. In particular, we would need to know that | ||
// `'x: 'a`, so that we could approximate `'x` "downwards" to `'a`. | ||
fn establish_relationships<'a, 'b, F>(_cell_a: &Cell<&'a u32>, _cell_b: &Cell<&'b u32>, _closure: F) | ||
where | ||
F: for<'x, 'y> FnMut( | ||
&Cell<&'x &'a u32>, // shows that 'a: 'x | ||
&Cell<&'y &'b u32>, // shows that 'b: 'y | ||
&Cell<&'x u32>, | ||
&Cell<&'y u32>, | ||
), | ||
{ | ||
} | ||
|
||
fn demand_y<'x, 'y>(_cell_x: &Cell<&'x u32>, _cell_y: &Cell<&'y u32>, _y: &'y u32) {} | ||
|
||
#[rustc_regions] | ||
fn supply<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) { | ||
establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y| { | ||
// Only works if 'x: 'y: | ||
demand_y(x, y, x.get()) | ||
//~^ WARN not reporting region error due to -Znll | ||
//~| ERROR free region `'_#5r` does not outlive free region `'_#7r` | ||
}); | ||
} | ||
|
||
fn main() {} |
46 changes: 46 additions & 0 deletions
46
...test/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-wrong-bounds.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
warning: not reporting region error due to -Znll | ||
--> $DIR/propagate-fail-to-approximate-longer-wrong-bounds.rs:51:9 | ||
| | ||
51 | demand_y(x, y, x.get()) | ||
| ^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: free region `'_#5r` does not outlive free region `'_#7r` | ||
--> $DIR/propagate-fail-to-approximate-longer-wrong-bounds.rs:51:21 | ||
| | ||
51 | demand_y(x, y, x.get()) | ||
| ^ | ||
|
||
note: External requirements | ||
--> $DIR/propagate-fail-to-approximate-longer-wrong-bounds.rs:49:47 | ||
| | ||
49 | establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y| { | ||
| _______________________________________________^ | ||
50 | | // Only works if 'x: 'y: | ||
51 | | demand_y(x, y, x.get()) | ||
52 | | //~^ WARN not reporting region error due to -Znll | ||
53 | | //~| ERROR free region `'_#5r` does not outlive free region `'_#7r` | ||
54 | | }); | ||
| |_____^ | ||
| | ||
= note: defining type: DefId(0/1:18 ~ propagate_fail_to_approximate_longer_wrong_bounds[317d]::supply[0]::{{closure}}[0]) with closure substs [ | ||
i16, | ||
for<'r, 's, 't0, 't1, 't2, 't3> extern "rust-call" fn((&ReLateBound(DebruijnIndex { depth: 1 }, BrNamed(crate0:DefIndex(0:0), 'r)) std::cell::Cell<&ReLateBound(DebruijnIndex { depth: 1 }, BrNamed(crate0:DefIndex(0:0), 's)) &'_#1r u32>, &ReLateBound(DebruijnIndex { depth: 1 }, BrNamed(crate0:DefIndex(0:0), 't0)) std::cell::Cell<&ReLateBound(DebruijnIndex { depth: 1 }, BrNamed(crate0:DefIndex(0:0), 't1)) &'_#2r u32>, &ReLateBound(DebruijnIndex { depth: 1 }, BrNamed(crate0:DefIndex(0:0), 't2)) std::cell::Cell<&ReLateBound(DebruijnIndex { depth: 1 }, BrNamed(crate0:DefIndex(0:0), 's)) u32>, &ReLateBound(DebruijnIndex { depth: 1 }, BrNamed(crate0:DefIndex(0:0), 't3)) std::cell::Cell<&ReLateBound(DebruijnIndex { depth: 1 }, BrNamed(crate0:DefIndex(0:0), 't1)) u32>)) | ||
] | ||
= note: number of external vids: 3 | ||
|
||
note: No external requirements | ||
--> $DIR/propagate-fail-to-approximate-longer-wrong-bounds.rs:48:1 | ||
| | ||
48 | / fn supply<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) { | ||
49 | | establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y| { | ||
50 | | // Only works if 'x: 'y: | ||
51 | | demand_y(x, y, x.get()) | ||
... | | ||
54 | | }); | ||
55 | | } | ||
| |_^ | ||
| | ||
= note: defining type: DefId(0/0:6 ~ propagate_fail_to_approximate_longer_wrong_bounds[317d]::supply[0]) with substs [] | ||
|
||
error: aborting due to previous error | ||
|