test approximations of the "shorter side" that resort to 'static
This includes the additional case suggested by arielb1.
This commit is contained in:
parent
3c42f18c37
commit
ca60826110
4 changed files with 113 additions and 18 deletions
|
@ -8,8 +8,13 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// Test a case where we are forced to approximate one end-point with
|
||||
// `'static`. Note that `'static` shows up in the stderr output as `'0`.
|
||||
// Test a case where we are trying to prove `'x: 'y` and are forced to
|
||||
// approximate the shorter end-point (`'y`) to with `'static`. This is
|
||||
// because `'y` is higher-ranked but we know of no relations to other
|
||||
// regions. Note that `'static` shows up in the stderr output as `'0`.
|
||||
//
|
||||
// FIXME(#45827) Because of shortcomings in the MIR type checker,
|
||||
// these errors are not (yet) reported.
|
||||
|
||||
// compile-flags:-Znll -Zborrowck=mir -Zverbose
|
||||
|
|
@ -1,20 +1,20 @@
|
|||
warning: not reporting region error due to -Znll
|
||||
--> $DIR/propagate-approximated-to-static.rs:42:9
|
||||
--> $DIR/propagate-approximated-shorter-to-static-no-bound.rs:47:9
|
||||
|
|
||||
42 | demand_y(x, y, x.get())
|
||||
47 | demand_y(x, y, x.get())
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
note: External requirements
|
||||
--> $DIR/propagate-approximated-to-static.rs:40:47
|
||||
--> $DIR/propagate-approximated-shorter-to-static-no-bound.rs:45:47
|
||||
|
|
||||
40 | establish_relationships(&cell_a, &cell_b, |_outlives, x, y| {
|
||||
45 | establish_relationships(&cell_a, &cell_b, |_outlives, x, y| {
|
||||
| _______________________________________________^
|
||||
41 | | // Only works if 'x: 'y:
|
||||
42 | | demand_y(x, y, x.get())
|
||||
43 | | });
|
||||
46 | | // Only works if 'x: 'y:
|
||||
47 | | demand_y(x, y, x.get())
|
||||
48 | | });
|
||||
| |_____^
|
||||
|
|
||||
= note: defining type: DefId(0/1:18 ~ propagate_approximated_to_static[317d]::supply[0]::{{closure}}[0]) with closure substs [
|
||||
= note: defining type: DefId(0/1:18 ~ propagate_approximated_shorter_to_static_no_bound[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<&'_#1r &ReLateBound(DebruijnIndex { depth: 1 }, BrNamed(crate0:DefIndex(0:0), 's)) u32>, &ReLateBound(DebruijnIndex { depth: 1 }, BrNamed(crate0:DefIndex(0:0), 't0)) std::cell::Cell<&ReLateBound(DebruijnIndex { depth: 1 }, BrNamed(crate0:DefIndex(0:0), 's)) u32>, &ReLateBound(DebruijnIndex { depth: 1 }, BrNamed(crate0:DefIndex(0:0), 't1)) std::cell::Cell<&ReLateBound(DebruijnIndex { depth: 1 }, BrNamed(crate0:DefIndex(0:0), 't2)) u32>))
|
||||
]
|
||||
|
@ -22,15 +22,15 @@ note: External requirements
|
|||
= note: where '_#1r: '_#0r
|
||||
|
||||
note: No external requirements
|
||||
--> $DIR/propagate-approximated-to-static.rs:39:1
|
||||
--> $DIR/propagate-approximated-shorter-to-static-no-bound.rs:44:1
|
||||
|
|
||||
39 | / fn supply<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) {
|
||||
40 | | establish_relationships(&cell_a, &cell_b, |_outlives, x, y| {
|
||||
41 | | // Only works if 'x: 'y:
|
||||
42 | | demand_y(x, y, x.get())
|
||||
43 | | });
|
||||
44 | | }
|
||||
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())
|
||||
48 | | });
|
||||
49 | | }
|
||||
| |_^
|
||||
|
|
||||
= note: defining type: DefId(0/0:6 ~ propagate_approximated_to_static[317d]::supply[0]) with substs []
|
||||
= note: defining type: DefId(0/0:6 ~ propagate_approximated_shorter_to_static_no_bound[317d]::supply[0]) with substs []
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
// 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.
|
||||
|
||||
// Test a case where we are trying to prove `'x: 'y` and are forced to
|
||||
// approximate the shorter end-point (`'y`) to with `'static`. This is
|
||||
// because `'y` is higher-ranked but we know of only irrelevant
|
||||
// relations to other regions. Note that `'static` shows up in the
|
||||
// stderr output as `'0`.
|
||||
//
|
||||
// FIXME(#45827) Because of shortcomings in the MIR type checker,
|
||||
// these errors are not (yet) reported.
|
||||
|
||||
// compile-flags:-Znll -Zborrowck=mir -Zverbose
|
||||
|
||||
#![feature(rustc_attrs)]
|
||||
|
||||
use std::cell::Cell;
|
||||
|
||||
// Callee knows that:
|
||||
//
|
||||
// 'x: 'a
|
||||
// 'y: 'b
|
||||
//
|
||||
// so the only way we can ensure that `'x: 'y` is to show that
|
||||
// `'a: 'static`.
|
||||
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<&'a &'x u32>, // shows that 'x: 'a
|
||||
&Cell<&'b &'y u32>, // shows that 'y: 'b
|
||||
&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())
|
||||
});
|
||||
}
|
||||
|
||||
fn main() {}
|
|
@ -0,0 +1,36 @@
|
|||
warning: not reporting region error due to -Znll
|
||||
--> $DIR/propagate-approximated-shorter-to-static-wrong-bound.rs:50:9
|
||||
|
|
||||
50 | demand_y(x, y, x.get())
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
note: External requirements
|
||||
--> $DIR/propagate-approximated-shorter-to-static-wrong-bound.rs:48:47
|
||||
|
|
||||
48 | establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y| {
|
||||
| _______________________________________________^
|
||||
49 | | // Only works if 'x: 'y:
|
||||
50 | | demand_y(x, y, x.get())
|
||||
51 | | });
|
||||
| |_____^
|
||||
|
|
||||
= note: defining type: DefId(0/1:18 ~ propagate_approximated_shorter_to_static_wrong_bound[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<&'_#1r &ReLateBound(DebruijnIndex { depth: 1 }, BrNamed(crate0:DefIndex(0:0), 's)) u32>, &ReLateBound(DebruijnIndex { depth: 1 }, BrNamed(crate0:DefIndex(0:0), 't0)) std::cell::Cell<&'_#2r &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>, &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: where '_#1r: '_#0r
|
||||
|
||||
note: No external requirements
|
||||
--> $DIR/propagate-approximated-shorter-to-static-wrong-bound.rs:47:1
|
||||
|
|
||||
47 | / fn supply<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) {
|
||||
48 | | establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y| {
|
||||
49 | | // Only works if 'x: 'y:
|
||||
50 | | demand_y(x, y, x.get())
|
||||
51 | | });
|
||||
52 | | }
|
||||
| |_^
|
||||
|
|
||||
= note: defining type: DefId(0/0:6 ~ propagate_approximated_shorter_to_static_wrong_bound[317d]::supply[0]) with substs []
|
||||
|
Loading…
Reference in a new issue