handle projections with regions

This commit is contained in:
Niko Matsakis 2017-12-05 13:15:23 -05:00
parent 3a5842afe1
commit 3fcb13ae45
14 changed files with 1757 additions and 101 deletions

View file

@ -0,0 +1,68 @@
// 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.
// compile-flags:-Znll -Zborrowck=mir -Zverbose
// Tests closures that propagate an outlives relationship to their
// creator where the subject is a projection with no regions (`<T as
// Iterator>::Item`, to be exact).
#![allow(warnings)]
#![feature(dyn_trait)]
#![feature(rustc_attrs)]
trait Anything { }
impl<T> Anything for T { }
fn with_signature<'a, T, F>(x: Box<T>, op: F) -> Box<dyn Anything + 'a>
where F: FnOnce(Box<T>) -> Box<dyn Anything + 'a>
{
op(x)
}
#[rustc_regions]
fn no_region<'a, T>(x: Box<T>) -> Box<dyn Anything + 'a>
where
T: Iterator,
{
with_signature(x, |mut y| Box::new(y.next()))
//~^ WARNING not reporting region error due to -Znll
//~| ERROR failed type test
}
#[rustc_regions]
fn correct_region<'a, T>(x: Box<T>) -> Box<dyn Anything + 'a>
where
T: 'a + Iterator,
{
with_signature(x, |mut y| Box::new(y.next()))
}
#[rustc_regions]
fn wrong_region<'a, 'b, T>(x: Box<T>) -> Box<dyn Anything + 'a>
where
T: 'b + Iterator,
{
with_signature(x, |mut y| Box::new(y.next()))
//~^ WARNING not reporting region error due to -Znll
//~| ERROR failed type test
}
#[rustc_regions]
fn outlives_region<'a, 'b, T>(x: Box<T>) -> Box<dyn Anything + 'a>
where
T: 'b + Iterator,
'b: 'a,
{
with_signature(x, |mut y| Box::new(y.next()))
}
fn main() {}

View file

@ -0,0 +1,157 @@
warning: not reporting region error due to -Znll
--> $DIR/projection-no-regions-closure.rs:36:31
|
36 | with_signature(x, |mut y| Box::new(y.next()))
| ^^^^^^^^^^^^^^^^^^
warning: not reporting region error due to -Znll
--> $DIR/projection-no-regions-closure.rs:54:31
|
54 | with_signature(x, |mut y| Box::new(y.next()))
| ^^^^^^^^^^^^^^^^^^
note: External requirements
--> $DIR/projection-no-regions-closure.rs:36:23
|
36 | with_signature(x, |mut y| Box::new(y.next()))
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: defining type: DefId(0/1:15 ~ projection_no_regions_closure[317d]::no_region[0]::{{closure}}[0]) with closure substs [
'_#1r,
T,
i32,
extern "rust-call" fn((std::boxed::Box<T>,)) -> std::boxed::Box<Anything + '_#2r>
]
= note: number of external vids: 3
= note: where <T as std::iter::Iterator>::Item: '_#2r
note: External requirements
--> $DIR/projection-no-regions-closure.rs:46:23
|
46 | with_signature(x, |mut y| Box::new(y.next()))
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: defining type: DefId(0/1:18 ~ projection_no_regions_closure[317d]::correct_region[0]::{{closure}}[0]) with closure substs [
'_#1r,
T,
i32,
extern "rust-call" fn((std::boxed::Box<T>,)) -> std::boxed::Box<Anything + '_#2r>
]
= note: number of external vids: 3
= note: where <T as std::iter::Iterator>::Item: '_#2r
note: External requirements
--> $DIR/projection-no-regions-closure.rs:54:23
|
54 | with_signature(x, |mut y| Box::new(y.next()))
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: defining type: DefId(0/1:22 ~ projection_no_regions_closure[317d]::wrong_region[0]::{{closure}}[0]) with closure substs [
'_#1r,
'_#2r,
T,
i32,
extern "rust-call" fn((std::boxed::Box<T>,)) -> std::boxed::Box<Anything + '_#3r>
]
= note: number of external vids: 4
= note: where <T as std::iter::Iterator>::Item: '_#3r
note: External requirements
--> $DIR/projection-no-regions-closure.rs:65:23
|
65 | with_signature(x, |mut y| Box::new(y.next()))
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: defining type: DefId(0/1:26 ~ projection_no_regions_closure[317d]::outlives_region[0]::{{closure}}[0]) with closure substs [
'_#1r,
'_#2r,
T,
i32,
extern "rust-call" fn((std::boxed::Box<T>,)) -> std::boxed::Box<Anything + '_#3r>
]
= note: number of external vids: 4
= note: where <T as std::iter::Iterator>::Item: '_#3r
error: failed type test: TypeTest { generic_kind: ProjectionTy { substs: Slice([T]), item_def_id: DefId(2/0:1697 ~ core[2633]::iter[0]::iterator[0]::Iterator[0]::Item[0]) }, lower_bound: '_#4r, point: bb0[5], span: $DIR/projection-no-regions-closure.rs:36:23: 36:49, test: IsOutlivedByAnyRegionIn(['_#2r]) }
--> $DIR/projection-no-regions-closure.rs:36:23
|
36 | with_signature(x, |mut y| Box::new(y.next()))
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
note: No external requirements
--> $DIR/projection-no-regions-closure.rs:32:1
|
32 | / fn no_region<'a, T>(x: Box<T>) -> Box<dyn Anything + 'a>
33 | | where
34 | | T: Iterator,
35 | | {
... |
38 | | //~| ERROR failed type test
39 | | }
| |_^
|
= note: defining type: DefId(0/0:6 ~ projection_no_regions_closure[317d]::no_region[0]) with substs [
'_#1r,
T
]
note: No external requirements
--> $DIR/projection-no-regions-closure.rs:42:1
|
42 | / fn correct_region<'a, T>(x: Box<T>) -> Box<dyn Anything + 'a>
43 | | where
44 | | T: 'a + Iterator,
45 | | {
46 | | with_signature(x, |mut y| Box::new(y.next()))
47 | | }
| |_^
|
= note: defining type: DefId(0/0:7 ~ projection_no_regions_closure[317d]::correct_region[0]) with substs [
'_#1r,
T
]
error: failed type test: TypeTest { generic_kind: ProjectionTy { substs: Slice([T]), item_def_id: DefId(2/0:1697 ~ core[2633]::iter[0]::iterator[0]::Iterator[0]::Item[0]) }, lower_bound: '_#6r, point: bb0[5], span: $DIR/projection-no-regions-closure.rs:54:23: 54:49, test: IsOutlivedByAnyRegionIn(['_#2r, '_#3r]) }
--> $DIR/projection-no-regions-closure.rs:54:23
|
54 | with_signature(x, |mut y| Box::new(y.next()))
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
note: No external requirements
--> $DIR/projection-no-regions-closure.rs:50:1
|
50 | / fn wrong_region<'a, 'b, T>(x: Box<T>) -> Box<dyn Anything + 'a>
51 | | where
52 | | T: 'b + Iterator,
53 | | {
... |
56 | | //~| ERROR failed type test
57 | | }
| |_^
|
= note: defining type: DefId(0/0:8 ~ projection_no_regions_closure[317d]::wrong_region[0]) with substs [
'_#1r,
'_#2r,
T
]
note: No external requirements
--> $DIR/projection-no-regions-closure.rs:60:1
|
60 | / fn outlives_region<'a, 'b, T>(x: Box<T>) -> Box<dyn Anything + 'a>
61 | | where
62 | | T: 'b + Iterator,
63 | | 'b: 'a,
64 | | {
65 | | with_signature(x, |mut y| Box::new(y.next()))
66 | | }
| |_^
|
= note: defining type: DefId(0/0:9 ~ projection_no_regions_closure[317d]::outlives_region[0]) with substs [
'_#1r,
'_#2r,
T
]
error: aborting due to 2 previous errors

View file

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// compile-flags:-Znll -Zborrowck=mir
// compile-flags:-Znll -Zborrowck=mir -Zverbose
#![allow(warnings)]
#![feature(dyn_trait)]

View file

@ -1,23 +1,23 @@
warning: not reporting region error due to -Znll
--> $DIR/projection-fn.rs:24:5
--> $DIR/projection-no-regions-fn.rs:24:5
|
24 | Box::new(x.next())
| ^^^^^^^^^^^^^^^^^^
warning: not reporting region error due to -Znll
--> $DIR/projection-fn.rs:40:5
--> $DIR/projection-no-regions-fn.rs:40:5
|
40 | Box::new(x.next())
| ^^^^^^^^^^^^^^^^^^
error: failed type test: TypeTest { generic_kind: ProjectionTy { substs: Slice([T]), item_def_id: DefId(2/0:1695 ~ core[2633]::iter[0]::iterator[0]::Iterator[0]::Item[0]) }, lower_bound: '_#4r, point: bb5[0], span: $DIR/projection-fn.rs:24:5: 24:23, test: IsOutlivedByAnyRegionIn(['_#2r]) }
--> $DIR/projection-fn.rs:24:5
error: failed type test: TypeTest { generic_kind: ProjectionTy { substs: Slice([T]), item_def_id: DefId(2/0:1697 ~ core[2633]::iter[0]::iterator[0]::Iterator[0]::Item[0]) }, lower_bound: '_#4r, point: bb5[0], span: $DIR/projection-no-regions-fn.rs:24:5: 24:23, test: IsOutlivedByAnyRegionIn(['_#2r]) }
--> $DIR/projection-no-regions-fn.rs:24:5
|
24 | Box::new(x.next())
| ^^^^^^^^^^^^^^^^^^
error: failed type test: TypeTest { generic_kind: ProjectionTy { substs: Slice([T]), item_def_id: DefId(2/0:1695 ~ core[2633]::iter[0]::iterator[0]::Iterator[0]::Item[0]) }, lower_bound: '_#5r, point: bb5[0], span: $DIR/projection-fn.rs:40:5: 40:23, test: IsOutlivedByAnyRegionIn(['_#2r, '_#3r]) }
--> $DIR/projection-fn.rs:40:5
error: failed type test: TypeTest { generic_kind: ProjectionTy { substs: Slice([T]), item_def_id: DefId(2/0:1697 ~ core[2633]::iter[0]::iterator[0]::Iterator[0]::Item[0]) }, lower_bound: '_#5r, point: bb5[0], span: $DIR/projection-no-regions-fn.rs:40:5: 40:23, test: IsOutlivedByAnyRegionIn(['_#2r, '_#3r]) }
--> $DIR/projection-no-regions-fn.rs:40:5
|
40 | Box::new(x.next())
| ^^^^^^^^^^^^^^^^^^

View file

@ -0,0 +1,106 @@
// 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 cases where we constrain `<T as Anything<'b>>::AssocType` to
// outlive `'a` and there are no bounds in the trait definition of
// `Anything`. This means that the constraint can only be satisfied in two
// ways:
//
// - by ensuring that `T: 'a` and `'b: 'a`, or
// - by something in the where clauses.
//
// As of this writing, the where clause option does not work because
// of limitations in our region inferencing system (this is true both
// with and without NLL). See `projection_outlives`.
//
// Ensuring that both `T: 'a` and `'b: 'a` holds does work (`elements_outlive`).
// compile-flags:-Znll -Zborrowck=mir -Zverbose
#![allow(warnings)]
#![feature(dyn_trait)]
#![feature(rustc_attrs)]
use std::cell::Cell;
trait Anything<'a> {
type AssocType;
}
fn with_signature<'a, T, F>(cell: Cell<&'a ()>, t: T, op: F)
where
F: FnOnce(Cell<&'a ()>, T),
{
op(cell, t)
}
fn require<'a, 'b, T>(_cell: Cell<&'a ()>, _t: T)
where
T: Anything<'b>,
T::AssocType: 'a,
{
}
#[rustc_regions]
fn no_relationships_late<'a, 'b, T>(cell: Cell<&'a ()>, t: T)
where
T: Anything<'b>,
{
with_signature(cell, t, |cell, t| require(cell, t));
//~^ WARNING not reporting region error due to -Znll
//~| ERROR failed type test
//~| ERROR free region `ReEarlyBound(0, 'b)` does not outlive free region `'_#2r`
}
#[rustc_regions]
fn no_relationships_early<'a, 'b, T>(cell: Cell<&'a ()>, t: T)
where
T: Anything<'b>,
'a: 'a,
{
with_signature(cell, t, |cell, t| require(cell, t));
//~^ WARNING not reporting region error due to -Znll
//~| ERROR failed type test
//~| ERROR free region `ReEarlyBound(1, 'b)` does not outlive free region `ReEarlyBound(0, 'a)`
}
#[rustc_regions]
fn projection_outlives<'a, 'b, T>(cell: Cell<&'a ()>, t: T)
where
T: Anything<'b>,
T::AssocType: 'a,
{
// This error is unfortunate. This code ought to type-check: we
// are projecting `<T as Anything<'b>>::AssocType`, and we know
// that this outlives `'a` because of the where-clause. However,
// the way the region checker works, we don't register this
// outlives obligation, and hence we get an error: this is because
// what we see is a projection like `<T as
// Anything<'?0>>::AssocType`, and we don't yet know if `?0` will
// equal `'b` or not, so we ignore the where-clause. Obviously we
// can do better here with a more involved verification step.
with_signature(cell, t, |cell, t| require(cell, t));
//~^ WARNING not reporting region error due to -Znll
//~| ERROR failed type test
//~| ERROR free region `ReEarlyBound(1, 'b)` does not outlive free region `ReEarlyBound(0, 'a)`
}
#[rustc_regions]
fn elements_outlive<'a, 'b, T>(cell: Cell<&'a ()>, t: T)
where
T: Anything<'b>,
T: 'a,
'b: 'a,
{
with_signature(cell, t, |cell, t| require(cell, t));
}
fn main() {}

View file

@ -0,0 +1,194 @@
warning: not reporting region error due to -Znll
--> $DIR/projection-one-region-closure.rs:56:39
|
56 | with_signature(cell, t, |cell, t| require(cell, t));
| ^^^^^^^
warning: not reporting region error due to -Znll
--> $DIR/projection-one-region-closure.rs:68:39
|
68 | with_signature(cell, t, |cell, t| require(cell, t));
| ^^^^^^^
warning: not reporting region error due to -Znll
--> $DIR/projection-one-region-closure.rs:90:39
|
90 | with_signature(cell, t, |cell, t| require(cell, t));
| ^^^^^^^
note: External requirements
--> $DIR/projection-one-region-closure.rs:56:29
|
56 | with_signature(cell, t, |cell, t| require(cell, t));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: defining type: DefId(0/1:19 ~ projection_one_region_closure[317d]::no_relationships_late[0]::{{closure}}[0]) with closure substs [
'_#1r,
T,
i32,
extern "rust-call" fn((std::cell::Cell<&'_#2r ()>, T))
]
= note: number of external vids: 3
= note: where T: '_#2r
= note: where '_#1r: '_#2r
note: External requirements
--> $DIR/projection-one-region-closure.rs:68:29
|
68 | with_signature(cell, t, |cell, t| require(cell, t));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: defining type: DefId(0/1:23 ~ projection_one_region_closure[317d]::no_relationships_early[0]::{{closure}}[0]) with closure substs [
'_#1r,
'_#2r,
T,
i32,
extern "rust-call" fn((std::cell::Cell<&'_#3r ()>, T))
]
= note: number of external vids: 4
= note: where T: '_#3r
= note: where '_#2r: '_#3r
note: External requirements
--> $DIR/projection-one-region-closure.rs:90:29
|
90 | with_signature(cell, t, |cell, t| require(cell, t));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: defining type: DefId(0/1:27 ~ projection_one_region_closure[317d]::projection_outlives[0]::{{closure}}[0]) with closure substs [
'_#1r,
'_#2r,
T,
i32,
extern "rust-call" fn((std::cell::Cell<&'_#3r ()>, T))
]
= note: number of external vids: 4
= note: where T: '_#3r
= note: where '_#2r: '_#3r
note: External requirements
--> $DIR/projection-one-region-closure.rs:103:29
|
103 | with_signature(cell, t, |cell, t| require(cell, t));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: defining type: DefId(0/1:31 ~ projection_one_region_closure[317d]::elements_outlive[0]::{{closure}}[0]) with closure substs [
'_#1r,
'_#2r,
T,
i32,
extern "rust-call" fn((std::cell::Cell<&'_#3r ()>, T))
]
= note: number of external vids: 4
= note: where T: '_#3r
= note: where '_#2r: '_#3r
error: failed type test: TypeTest { generic_kind: T/#1, lower_bound: '_#5r, point: bb0[5], span: $DIR/projection-one-region-closure.rs:56:29: 56:55, test: IsOutlivedByAnyRegionIn(['_#3r]) }
--> $DIR/projection-one-region-closure.rs:56:29
|
56 | with_signature(cell, t, |cell, t| require(cell, t));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
error: free region `ReEarlyBound(0, 'b)` does not outlive free region `'_#2r`
--> $DIR/projection-one-region-closure.rs:56:20
|
56 | with_signature(cell, t, |cell, t| require(cell, t));
| ^^^^
note: No external requirements
--> $DIR/projection-one-region-closure.rs:52:1
|
52 | / fn no_relationships_late<'a, 'b, T>(cell: Cell<&'a ()>, t: T)
53 | | where
54 | | T: Anything<'b>,
55 | | {
... |
59 | | //~| ERROR free region `ReEarlyBound(0, 'b)` does not outlive free region `'_#2r`
60 | | }
| |_^
|
= note: defining type: DefId(0/0:8 ~ projection_one_region_closure[317d]::no_relationships_late[0]) with substs [
'_#1r,
T
]
error: failed type test: TypeTest { generic_kind: T/#2, lower_bound: '_#6r, point: bb0[5], span: $DIR/projection-one-region-closure.rs:68:29: 68:55, test: IsOutlivedByAnyRegionIn(['_#3r]) }
--> $DIR/projection-one-region-closure.rs:68:29
|
68 | with_signature(cell, t, |cell, t| require(cell, t));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
error: free region `ReEarlyBound(1, 'b)` does not outlive free region `ReEarlyBound(0, 'a)`
--> $DIR/projection-one-region-closure.rs:68:20
|
68 | with_signature(cell, t, |cell, t| require(cell, t));
| ^^^^
note: No external requirements
--> $DIR/projection-one-region-closure.rs:63:1
|
63 | / fn no_relationships_early<'a, 'b, T>(cell: Cell<&'a ()>, t: T)
64 | | where
65 | | T: Anything<'b>,
66 | | 'a: 'a,
... |
71 | | //~| ERROR free region `ReEarlyBound(1, 'b)` does not outlive free region `ReEarlyBound(0, 'a)`
72 | | }
| |_^
|
= note: defining type: DefId(0/0:9 ~ projection_one_region_closure[317d]::no_relationships_early[0]) with substs [
'_#1r,
'_#2r,
T
]
error: failed type test: TypeTest { generic_kind: T/#2, lower_bound: '_#6r, point: bb0[5], span: $DIR/projection-one-region-closure.rs:90:29: 90:55, test: IsOutlivedByAnyRegionIn(['_#3r]) }
--> $DIR/projection-one-region-closure.rs:90:29
|
90 | with_signature(cell, t, |cell, t| require(cell, t));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
error: free region `ReEarlyBound(1, 'b)` does not outlive free region `ReEarlyBound(0, 'a)`
--> $DIR/projection-one-region-closure.rs:90:20
|
90 | with_signature(cell, t, |cell, t| require(cell, t));
| ^^^^
note: No external requirements
--> $DIR/projection-one-region-closure.rs:75:1
|
75 | / fn projection_outlives<'a, 'b, T>(cell: Cell<&'a ()>, t: T)
76 | | where
77 | | T: Anything<'b>,
78 | | T::AssocType: 'a,
... |
93 | | //~| ERROR free region `ReEarlyBound(1, 'b)` does not outlive free region `ReEarlyBound(0, 'a)`
94 | | }
| |_^
|
= note: defining type: DefId(0/0:10 ~ projection_one_region_closure[317d]::projection_outlives[0]) with substs [
'_#1r,
'_#2r,
T
]
note: No external requirements
--> $DIR/projection-one-region-closure.rs:97:1
|
97 | / fn elements_outlive<'a, 'b, T>(cell: Cell<&'a ()>, t: T)
98 | | where
99 | | T: Anything<'b>,
100 | | T: 'a,
... |
103 | | with_signature(cell, t, |cell, t| require(cell, t));
104 | | }
| |_^
|
= note: defining type: DefId(0/0:11 ~ projection_one_region_closure[317d]::elements_outlive[0]) with substs [
'_#1r,
'_#2r,
T
]
error: aborting due to 6 previous errors

View file

@ -0,0 +1,106 @@
// 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 cases where we constrain `<T as Anything<'b>>::AssocType` to
// outlive `'a` and there is a unique bound in the trait definition of
// `Anything` -- i.e., we know that `AssocType` outlives `'b`. In this
// case, the best way to satisfy the trait bound is to show that `'b:
// 'a`, which can be done in various ways.
// compile-flags:-Znll -Zborrowck=mir -Zverbose
#![allow(warnings)]
#![feature(dyn_trait)]
#![feature(rustc_attrs)]
use std::cell::Cell;
trait Anything<'a> {
type AssocType: 'a;
}
fn with_signature<'a, T, F>(cell: Cell<&'a ()>, t: T, op: F)
where
F: FnOnce(Cell<&'a ()>, T),
{
op(cell, t)
}
fn require<'a, 'b, T>(_cell: Cell<&'a ()>, _t: T)
where
T: Anything<'b>,
T::AssocType: 'a,
{
}
#[rustc_regions]
fn no_relationships_late<'a, 'b, T>(cell: Cell<&'a ()>, t: T)
where
T: Anything<'b>,
{
with_signature(cell, t, |cell, t| require(cell, t));
//~^ WARNING not reporting region error due to -Znll
//~| ERROR free region `ReEarlyBound(0, 'b)` does not outlive free region `'_#2r`
}
#[rustc_regions]
fn no_relationships_early<'a, 'b, T>(cell: Cell<&'a ()>, t: T)
where
T: Anything<'b>,
'a: 'a,
{
with_signature(cell, t, |cell, t| require(cell, t));
//~^ WARNING not reporting region error due to -Znll
//~| ERROR free region `ReEarlyBound(1, 'b)` does not outlive free region `ReEarlyBound(0, 'a)`
}
#[rustc_regions]
fn projection_outlives<'a, 'b, T>(cell: Cell<&'a ()>, t: T)
where
T: Anything<'b>,
T::AssocType: 'a,
{
// This error is unfortunate. This code ought to type-check: we
// are projecting `<T as Anything<'b>>::AssocType`, and we know
// that this outlives `'a` because of the where-clause. However,
// the way the region checker works, we don't register this
// outlives obligation, and hence we get an error: this is because
// what we see is a projection like `<T as
// Anything<'?0>>::AssocType`, and we don't yet know if `?0` will
// equal `'b` or not, so we ignore the where-clause. Obviously we
// can do better here with a more involved verification step.
with_signature(cell, t, |cell, t| require(cell, t));
//~^ WARNING not reporting region error due to -Znll
//~| ERROR free region `ReEarlyBound(1, 'b)` does not outlive free region `ReEarlyBound(0, 'a)`
}
#[rustc_regions]
fn elements_outlive<'a, 'b, T>(cell: Cell<&'a ()>, t: T)
where
T: Anything<'b>,
'b: 'a,
{
with_signature(cell, t, |cell, t| require(cell, t));
}
#[rustc_regions]
fn one_region<'a, T>(cell: Cell<&'a ()>, t: T)
where
T: Anything<'a>,
{
// Note that in this case the closure still propagates an external
// requirement between two variables in its signature, but the
// creator maps both those two region variables to `'a` on its
// side.
with_signature(cell, t, |cell, t| require(cell, t));
}
fn main() {}

View file

@ -0,0 +1,204 @@
warning: not reporting region error due to -Znll
--> $DIR/projection-one-region-trait-bound-closure.rs:48:39
|
48 | with_signature(cell, t, |cell, t| require(cell, t));
| ^^^^^^^
warning: not reporting region error due to -Znll
--> $DIR/projection-one-region-trait-bound-closure.rs:59:39
|
59 | with_signature(cell, t, |cell, t| require(cell, t));
| ^^^^^^^
warning: not reporting region error due to -Znll
--> $DIR/projection-one-region-trait-bound-closure.rs:80:39
|
80 | with_signature(cell, t, |cell, t| require(cell, t));
| ^^^^^^^
note: External requirements
--> $DIR/projection-one-region-trait-bound-closure.rs:48:29
|
48 | with_signature(cell, t, |cell, t| require(cell, t));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: defining type: DefId(0/1:19 ~ projection_one_region_trait_bound_closure[317d]::no_relationships_late[0]::{{closure}}[0]) with closure substs [
'_#1r,
T,
i32,
extern "rust-call" fn((std::cell::Cell<&'_#2r ()>, T))
]
= note: number of external vids: 3
= note: where '_#1r: '_#2r
note: External requirements
--> $DIR/projection-one-region-trait-bound-closure.rs:59:29
|
59 | with_signature(cell, t, |cell, t| require(cell, t));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: defining type: DefId(0/1:23 ~ projection_one_region_trait_bound_closure[317d]::no_relationships_early[0]::{{closure}}[0]) with closure substs [
'_#1r,
'_#2r,
T,
i32,
extern "rust-call" fn((std::cell::Cell<&'_#3r ()>, T))
]
= note: number of external vids: 4
= note: where '_#2r: '_#3r
note: External requirements
--> $DIR/projection-one-region-trait-bound-closure.rs:80:29
|
80 | with_signature(cell, t, |cell, t| require(cell, t));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: defining type: DefId(0/1:27 ~ projection_one_region_trait_bound_closure[317d]::projection_outlives[0]::{{closure}}[0]) with closure substs [
'_#1r,
'_#2r,
T,
i32,
extern "rust-call" fn((std::cell::Cell<&'_#3r ()>, T))
]
= note: number of external vids: 4
= note: where '_#2r: '_#3r
note: External requirements
--> $DIR/projection-one-region-trait-bound-closure.rs:91:29
|
91 | with_signature(cell, t, |cell, t| require(cell, t));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: defining type: DefId(0/1:31 ~ projection_one_region_trait_bound_closure[317d]::elements_outlive[0]::{{closure}}[0]) with closure substs [
'_#1r,
'_#2r,
T,
i32,
extern "rust-call" fn((std::cell::Cell<&'_#3r ()>, T))
]
= note: number of external vids: 4
= note: where '_#2r: '_#3r
note: External requirements
--> $DIR/projection-one-region-trait-bound-closure.rs:103:29
|
103 | with_signature(cell, t, |cell, t| require(cell, t));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: defining type: DefId(0/1:34 ~ projection_one_region_trait_bound_closure[317d]::one_region[0]::{{closure}}[0]) with closure substs [
'_#1r,
T,
i32,
extern "rust-call" fn((std::cell::Cell<&'_#2r ()>, T))
]
= note: number of external vids: 3
= note: where '_#1r: '_#2r
error: free region `ReEarlyBound(0, 'b)` does not outlive free region `'_#2r`
--> $DIR/projection-one-region-trait-bound-closure.rs:48:20
|
48 | with_signature(cell, t, |cell, t| require(cell, t));
| ^^^^
note: No external requirements
--> $DIR/projection-one-region-trait-bound-closure.rs:44:1
|
44 | / fn no_relationships_late<'a, 'b, T>(cell: Cell<&'a ()>, t: T)
45 | | where
46 | | T: Anything<'b>,
47 | | {
... |
50 | | //~| ERROR free region `ReEarlyBound(0, 'b)` does not outlive free region `'_#2r`
51 | | }
| |_^
|
= note: defining type: DefId(0/0:8 ~ projection_one_region_trait_bound_closure[317d]::no_relationships_late[0]) with substs [
'_#1r,
T
]
error: free region `ReEarlyBound(1, 'b)` does not outlive free region `ReEarlyBound(0, 'a)`
--> $DIR/projection-one-region-trait-bound-closure.rs:59:20
|
59 | with_signature(cell, t, |cell, t| require(cell, t));
| ^^^^
note: No external requirements
--> $DIR/projection-one-region-trait-bound-closure.rs:54:1
|
54 | / fn no_relationships_early<'a, 'b, T>(cell: Cell<&'a ()>, t: T)
55 | | where
56 | | T: Anything<'b>,
57 | | 'a: 'a,
... |
61 | | //~| ERROR free region `ReEarlyBound(1, 'b)` does not outlive free region `ReEarlyBound(0, 'a)`
62 | | }
| |_^
|
= note: defining type: DefId(0/0:9 ~ projection_one_region_trait_bound_closure[317d]::no_relationships_early[0]) with substs [
'_#1r,
'_#2r,
T
]
error: free region `ReEarlyBound(1, 'b)` does not outlive free region `ReEarlyBound(0, 'a)`
--> $DIR/projection-one-region-trait-bound-closure.rs:80:20
|
80 | with_signature(cell, t, |cell, t| require(cell, t));
| ^^^^
note: No external requirements
--> $DIR/projection-one-region-trait-bound-closure.rs:65:1
|
65 | / fn projection_outlives<'a, 'b, T>(cell: Cell<&'a ()>, t: T)
66 | | where
67 | | T: Anything<'b>,
68 | | T::AssocType: 'a,
... |
82 | | //~| ERROR free region `ReEarlyBound(1, 'b)` does not outlive free region `ReEarlyBound(0, 'a)`
83 | | }
| |_^
|
= note: defining type: DefId(0/0:10 ~ projection_one_region_trait_bound_closure[317d]::projection_outlives[0]) with substs [
'_#1r,
'_#2r,
T
]
note: No external requirements
--> $DIR/projection-one-region-trait-bound-closure.rs:86:1
|
86 | / fn elements_outlive<'a, 'b, T>(cell: Cell<&'a ()>, t: T)
87 | | where
88 | | T: Anything<'b>,
89 | | 'b: 'a,
90 | | {
91 | | with_signature(cell, t, |cell, t| require(cell, t));
92 | | }
| |_^
|
= note: defining type: DefId(0/0:11 ~ projection_one_region_trait_bound_closure[317d]::elements_outlive[0]) with substs [
'_#1r,
'_#2r,
T
]
note: No external requirements
--> $DIR/projection-one-region-trait-bound-closure.rs:95:1
|
95 | / fn one_region<'a, T>(cell: Cell<&'a ()>, t: T)
96 | | where
97 | | T: Anything<'a>,
98 | | {
... |
103 | | with_signature(cell, t, |cell, t| require(cell, t));
104 | | }
| |_^
|
= note: defining type: DefId(0/0:12 ~ projection_one_region_trait_bound_closure[317d]::one_region[0]) with substs [
'_#1r,
T
]
error: aborting due to 3 previous errors

View file

@ -0,0 +1,99 @@
// 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 cases where we constrain `<T as Anything<'b>>::AssocType` to
// outlive `'static`. In this case, we don't get any errors, and in fact
// we don't even propagate constraints from the closures to the callers.
// compile-flags:-Znll -Zborrowck=mir -Zverbose
// must-compile-successfully
#![allow(warnings)]
#![feature(dyn_trait)]
#![feature(rustc_attrs)]
use std::cell::Cell;
trait Anything<'a> {
type AssocType: 'static;
}
fn with_signature<'a, T, F>(cell: Cell<&'a ()>, t: T, op: F)
where
F: FnOnce(Cell<&'a ()>, T),
{
op(cell, t)
}
fn require<'a, 'b, T>(_cell: Cell<&'a ()>, _t: T)
where
T: Anything<'b>,
T::AssocType: 'a,
{
}
#[rustc_regions]
fn no_relationships_late<'a, 'b, T>(cell: Cell<&'a ()>, t: T)
where
T: Anything<'b>,
{
with_signature(cell, t, |cell, t| require(cell, t));
}
#[rustc_regions]
fn no_relationships_early<'a, 'b, T>(cell: Cell<&'a ()>, t: T)
where
T: Anything<'b>,
'a: 'a,
{
with_signature(cell, t, |cell, t| require(cell, t));
}
#[rustc_regions]
fn projection_outlives<'a, 'b, T>(cell: Cell<&'a ()>, t: T)
where
T: Anything<'b>,
T::AssocType: 'a,
{
// This error is unfortunate. This code ought to type-check: we
// are projecting `<T as Anything<'b>>::AssocType`, and we know
// that this outlives `'a` because of the where-clause. However,
// the way the region checker works, we don't register this
// outlives obligation, and hence we get an error: this is because
// what we see is a projection like `<T as
// Anything<'?0>>::AssocType`, and we don't yet know if `?0` will
// equal `'b` or not, so we ignore the where-clause. Obviously we
// can do better here with a more involved verification step.
with_signature(cell, t, |cell, t| require(cell, t));
}
#[rustc_regions]
fn elements_outlive<'a, 'b, T>(cell: Cell<&'a ()>, t: T)
where
T: Anything<'b>,
'b: 'a,
{
with_signature(cell, t, |cell, t| require(cell, t));
}
#[rustc_regions]
fn one_region<'a, T>(cell: Cell<&'a ()>, t: T)
where
T: Anything<'a>,
{
// Note that in this case the closure still propagates an external
// requirement between two variables in its signature, but the
// creator maps both those two region variables to `'a` on its
// side.
with_signature(cell, t, |cell, t| require(cell, t));
}
fn main() {}

View file

@ -0,0 +1,155 @@
note: No external requirements
--> $DIR/projection-one-region-trait-bound-static-closure.rs:47:29
|
47 | with_signature(cell, t, |cell, t| require(cell, t));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: defining type: DefId(0/1:19 ~ projection_one_region_trait_bound_static_closure[317d]::no_relationships_late[0]::{{closure}}[0]) with closure substs [
'_#1r,
T,
i32,
extern "rust-call" fn((std::cell::Cell<&'_#2r ()>, T))
]
note: No external requirements
--> $DIR/projection-one-region-trait-bound-static-closure.rs:56:29
|
56 | with_signature(cell, t, |cell, t| require(cell, t));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: defining type: DefId(0/1:23 ~ projection_one_region_trait_bound_static_closure[317d]::no_relationships_early[0]::{{closure}}[0]) with closure substs [
'_#1r,
'_#2r,
T,
i32,
extern "rust-call" fn((std::cell::Cell<&'_#3r ()>, T))
]
note: No external requirements
--> $DIR/projection-one-region-trait-bound-static-closure.rs:75:29
|
75 | with_signature(cell, t, |cell, t| require(cell, t));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: defining type: DefId(0/1:27 ~ projection_one_region_trait_bound_static_closure[317d]::projection_outlives[0]::{{closure}}[0]) with closure substs [
'_#1r,
'_#2r,
T,
i32,
extern "rust-call" fn((std::cell::Cell<&'_#3r ()>, T))
]
note: No external requirements
--> $DIR/projection-one-region-trait-bound-static-closure.rs:84:29
|
84 | with_signature(cell, t, |cell, t| require(cell, t));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: defining type: DefId(0/1:31 ~ projection_one_region_trait_bound_static_closure[317d]::elements_outlive[0]::{{closure}}[0]) with closure substs [
'_#1r,
'_#2r,
T,
i32,
extern "rust-call" fn((std::cell::Cell<&'_#3r ()>, T))
]
note: No external requirements
--> $DIR/projection-one-region-trait-bound-static-closure.rs:96:29
|
96 | with_signature(cell, t, |cell, t| require(cell, t));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: defining type: DefId(0/1:34 ~ projection_one_region_trait_bound_static_closure[317d]::one_region[0]::{{closure}}[0]) with closure substs [
'_#1r,
T,
i32,
extern "rust-call" fn((std::cell::Cell<&'_#2r ()>, T))
]
note: No external requirements
--> $DIR/projection-one-region-trait-bound-static-closure.rs:43:1
|
43 | / fn no_relationships_late<'a, 'b, T>(cell: Cell<&'a ()>, t: T)
44 | | where
45 | | T: Anything<'b>,
46 | | {
47 | | with_signature(cell, t, |cell, t| require(cell, t));
48 | | }
| |_^
|
= note: defining type: DefId(0/0:8 ~ projection_one_region_trait_bound_static_closure[317d]::no_relationships_late[0]) with substs [
'_#1r,
T
]
note: No external requirements
--> $DIR/projection-one-region-trait-bound-static-closure.rs:51:1
|
51 | / fn no_relationships_early<'a, 'b, T>(cell: Cell<&'a ()>, t: T)
52 | | where
53 | | T: Anything<'b>,
54 | | 'a: 'a,
55 | | {
56 | | with_signature(cell, t, |cell, t| require(cell, t));
57 | | }
| |_^
|
= note: defining type: DefId(0/0:9 ~ projection_one_region_trait_bound_static_closure[317d]::no_relationships_early[0]) with substs [
'_#1r,
'_#2r,
T
]
note: No external requirements
--> $DIR/projection-one-region-trait-bound-static-closure.rs:60:1
|
60 | / fn projection_outlives<'a, 'b, T>(cell: Cell<&'a ()>, t: T)
61 | | where
62 | | T: Anything<'b>,
63 | | T::AssocType: 'a,
... |
75 | | with_signature(cell, t, |cell, t| require(cell, t));
76 | | }
| |_^
|
= note: defining type: DefId(0/0:10 ~ projection_one_region_trait_bound_static_closure[317d]::projection_outlives[0]) with substs [
'_#1r,
'_#2r,
T
]
note: No external requirements
--> $DIR/projection-one-region-trait-bound-static-closure.rs:79:1
|
79 | / fn elements_outlive<'a, 'b, T>(cell: Cell<&'a ()>, t: T)
80 | | where
81 | | T: Anything<'b>,
82 | | 'b: 'a,
83 | | {
84 | | with_signature(cell, t, |cell, t| require(cell, t));
85 | | }
| |_^
|
= note: defining type: DefId(0/0:11 ~ projection_one_region_trait_bound_static_closure[317d]::elements_outlive[0]) with substs [
'_#1r,
'_#2r,
T
]
note: No external requirements
--> $DIR/projection-one-region-trait-bound-static-closure.rs:88:1
|
88 | / fn one_region<'a, T>(cell: Cell<&'a ()>, t: T)
89 | | where
90 | | T: Anything<'a>,
91 | | {
... |
96 | | with_signature(cell, t, |cell, t| require(cell, t));
97 | | }
| |_^
|
= note: defining type: DefId(0/0:12 ~ projection_one_region_trait_bound_static_closure[317d]::one_region[0]) with substs [
'_#1r,
T
]

View file

@ -0,0 +1,135 @@
// 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 cases where we constrain `<T as Anything<'a, 'b>>::AssocType`
// to outlive `'a` and there are two bounds in the trait definition of
// `Anything` -- i.e., we know that `AssocType` outlives `'a` and
// `'b`. In this case, it's not clear what is the best way to satisfy
// the trait bound, and hence we propagate it to the caller as a type
// test.
// compile-flags:-Znll -Zborrowck=mir -Zverbose
#![allow(warnings)]
#![feature(dyn_trait)]
#![feature(rustc_attrs)]
use std::cell::Cell;
trait Anything<'a, 'b> {
type AssocType: 'a + 'b;
}
fn with_signature<'a, T, F>(cell: Cell<&'a ()>, t: T, op: F)
where
F: FnOnce(Cell<&'a ()>, T),
{
op(cell, t)
}
fn require<'a, 'b, 'c, T>(_cell: Cell<&'a ()>, _t: T)
where
T: Anything<'b, 'c>,
T::AssocType: 'a,
{
}
#[rustc_regions]
fn no_relationships_late<'a, 'b, 'c, T>(cell: Cell<&'a ()>, t: T)
where
T: Anything<'b, 'c>,
{
with_signature(cell, t, |cell, t| require(cell, t));
//~^ WARNING not reporting region error due to -Znll
//~| ERROR failed type test
}
#[rustc_regions]
fn no_relationships_early<'a, 'b, 'c, T>(cell: Cell<&'a ()>, t: T)
where
T: Anything<'b, 'c>,
'a: 'a,
{
with_signature(cell, t, |cell, t| require(cell, t));
//~^ WARNING not reporting region error due to -Znll
//~| ERROR failed type test
}
#[rustc_regions]
fn projection_outlives<'a, 'b, 'c, T>(cell: Cell<&'a ()>, t: T)
where
T: Anything<'b, 'c>,
T::AssocType: 'a,
{
// This error is unfortunate. This code ought to type-check: we
// are projecting `<T as Anything<'b>>::AssocType`, and we know
// that this outlives `'a` because of the where-clause. However,
// the way the region checker works, we don't register this
// outlives obligation, and hence we get an error: this is because
// what we see is a projection like `<T as
// Anything<'?0>>::AssocType`, and we don't yet know if `?0` will
// equal `'b` or not, so we ignore the where-clause. Obviously we
// can do better here with a more involved verification step.
with_signature(cell, t, |cell, t| require(cell, t));
//~^ WARNING not reporting region error due to -Znll
//~| ERROR failed type test
}
#[rustc_regions]
fn elements_outlive1<'a, 'b, 'c, T>(cell: Cell<&'a ()>, t: T)
where
T: Anything<'b, 'c>,
'b: 'a,
{
with_signature(cell, t, |cell, t| require(cell, t));
}
#[rustc_regions]
fn elements_outlive2<'a, 'b, 'c, T>(cell: Cell<&'a ()>, t: T)
where
T: Anything<'b, 'c>,
'c: 'a,
{
with_signature(cell, t, |cell, t| require(cell, t));
}
#[rustc_regions]
fn two_regions<'a, 'b, T>(cell: Cell<&'a ()>, t: T)
where
T: Anything<'b, 'b>,
{
with_signature(cell, t, |cell, t| require(cell, t));
//~^ WARNING not reporting region error due to -Znll
//~| ERROR free region `ReEarlyBound(0, 'b)` does not outlive free region `'_#2r`
}
#[rustc_regions]
fn two_regions_outlive<'a, 'b, T>(cell: Cell<&'a ()>, t: T)
where
T: Anything<'b, 'b>,
'b: 'a,
{
with_signature(cell, t, |cell, t| require(cell, t));
}
#[rustc_regions]
fn one_region<'a, T>(cell: Cell<&'a ()>, t: T)
where
T: Anything<'a, 'a>,
{
// Note that in this case the closure still propagates an external
// requirement between two variables in its signature, but the
// creator maps both those two region variables to `'a` on its
// side.
with_signature(cell, t, |cell, t| require(cell, t));
}
fn main() {}

View file

@ -0,0 +1,326 @@
warning: not reporting region error due to -Znll
--> $DIR/projection-two-region-trait-bound-closure.rs:49:39
|
49 | with_signature(cell, t, |cell, t| require(cell, t));
| ^^^^^^^
warning: not reporting region error due to -Znll
--> $DIR/projection-two-region-trait-bound-closure.rs:60:39
|
60 | with_signature(cell, t, |cell, t| require(cell, t));
| ^^^^^^^
warning: not reporting region error due to -Znll
--> $DIR/projection-two-region-trait-bound-closure.rs:81:39
|
81 | with_signature(cell, t, |cell, t| require(cell, t));
| ^^^^^^^
warning: not reporting region error due to -Znll
--> $DIR/projection-two-region-trait-bound-closure.rs:109:39
|
109 | with_signature(cell, t, |cell, t| require(cell, t));
| ^^^^^^^
note: External requirements
--> $DIR/projection-two-region-trait-bound-closure.rs:49:29
|
49 | with_signature(cell, t, |cell, t| require(cell, t));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: defining type: DefId(0/1:22 ~ projection_two_region_trait_bound_closure[317d]::no_relationships_late[0]::{{closure}}[0]) with closure substs [
'_#1r,
'_#2r,
T,
i32,
extern "rust-call" fn((std::cell::Cell<&'_#3r ()>, T))
]
= note: number of external vids: 4
= note: where <T as Anything<ReClosureBound('_#1r), ReClosureBound('_#2r)>>::AssocType: '_#3r
note: External requirements
--> $DIR/projection-two-region-trait-bound-closure.rs:60:29
|
60 | with_signature(cell, t, |cell, t| require(cell, t));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: defining type: DefId(0/1:27 ~ projection_two_region_trait_bound_closure[317d]::no_relationships_early[0]::{{closure}}[0]) with closure substs [
'_#1r,
'_#2r,
'_#3r,
T,
i32,
extern "rust-call" fn((std::cell::Cell<&'_#4r ()>, T))
]
= note: number of external vids: 5
= note: where <T as Anything<ReClosureBound('_#2r), ReClosureBound('_#3r)>>::AssocType: '_#4r
note: External requirements
--> $DIR/projection-two-region-trait-bound-closure.rs:81:29
|
81 | with_signature(cell, t, |cell, t| require(cell, t));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: defining type: DefId(0/1:32 ~ projection_two_region_trait_bound_closure[317d]::projection_outlives[0]::{{closure}}[0]) with closure substs [
'_#1r,
'_#2r,
'_#3r,
T,
i32,
extern "rust-call" fn((std::cell::Cell<&'_#4r ()>, T))
]
= note: number of external vids: 5
= note: where <T as Anything<ReClosureBound('_#2r), ReClosureBound('_#3r)>>::AssocType: '_#4r
note: External requirements
--> $DIR/projection-two-region-trait-bound-closure.rs:92:29
|
92 | with_signature(cell, t, |cell, t| require(cell, t));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: defining type: DefId(0/1:37 ~ projection_two_region_trait_bound_closure[317d]::elements_outlive1[0]::{{closure}}[0]) with closure substs [
'_#1r,
'_#2r,
'_#3r,
T,
i32,
extern "rust-call" fn((std::cell::Cell<&'_#4r ()>, T))
]
= note: number of external vids: 5
= note: where <T as Anything<ReClosureBound('_#2r), ReClosureBound('_#3r)>>::AssocType: '_#4r
note: External requirements
--> $DIR/projection-two-region-trait-bound-closure.rs:101:29
|
101 | with_signature(cell, t, |cell, t| require(cell, t));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: defining type: DefId(0/1:42 ~ projection_two_region_trait_bound_closure[317d]::elements_outlive2[0]::{{closure}}[0]) with closure substs [
'_#1r,
'_#2r,
'_#3r,
T,
i32,
extern "rust-call" fn((std::cell::Cell<&'_#4r ()>, T))
]
= note: number of external vids: 5
= note: where <T as Anything<ReClosureBound('_#2r), ReClosureBound('_#3r)>>::AssocType: '_#4r
note: External requirements
--> $DIR/projection-two-region-trait-bound-closure.rs:109:29
|
109 | with_signature(cell, t, |cell, t| require(cell, t));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: defining type: DefId(0/1:46 ~ projection_two_region_trait_bound_closure[317d]::two_regions[0]::{{closure}}[0]) with closure substs [
'_#1r,
T,
i32,
extern "rust-call" fn((std::cell::Cell<&'_#2r ()>, T))
]
= note: number of external vids: 3
= note: where <T as Anything<ReClosureBound('_#1r), ReClosureBound('_#1r)>>::AssocType: '_#2r
note: External requirements
--> $DIR/projection-two-region-trait-bound-closure.rs:120:29
|
120 | with_signature(cell, t, |cell, t| require(cell, t));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: defining type: DefId(0/1:50 ~ projection_two_region_trait_bound_closure[317d]::two_regions_outlive[0]::{{closure}}[0]) with closure substs [
'_#1r,
'_#2r,
T,
i32,
extern "rust-call" fn((std::cell::Cell<&'_#3r ()>, T))
]
= note: number of external vids: 4
= note: where <T as Anything<ReClosureBound('_#2r), ReClosureBound('_#2r)>>::AssocType: '_#3r
note: External requirements
--> $DIR/projection-two-region-trait-bound-closure.rs:132:29
|
132 | with_signature(cell, t, |cell, t| require(cell, t));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: defining type: DefId(0/1:53 ~ projection_two_region_trait_bound_closure[317d]::one_region[0]::{{closure}}[0]) with closure substs [
'_#1r,
T,
i32,
extern "rust-call" fn((std::cell::Cell<&'_#2r ()>, T))
]
= note: number of external vids: 3
= note: where <T as Anything<ReClosureBound('_#1r), ReClosureBound('_#1r)>>::AssocType: '_#2r
error: failed type test: TypeTest { generic_kind: ProjectionTy { substs: Slice([T, '_#5r, '_#6r]), item_def_id: DefId(0/0:5 ~ projection_two_region_trait_bound_closure[317d]::Anything[0]::AssocType[0]) }, lower_bound: '_#7r, point: bb0[5], span: $DIR/projection-two-region-trait-bound-closure.rs:49:29: 49:55, test: Any([IsOutlivedByAnyRegionIn(['_#6r, '_#5r]), All([IsOutlivedByAnyRegionIn(['_#4r]), IsOutlivedByAllRegionsIn(['_#5r, '_#6r])])]) }
--> $DIR/projection-two-region-trait-bound-closure.rs:49:29
|
49 | with_signature(cell, t, |cell, t| require(cell, t));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
note: No external requirements
--> $DIR/projection-two-region-trait-bound-closure.rs:45:1
|
45 | / fn no_relationships_late<'a, 'b, 'c, T>(cell: Cell<&'a ()>, t: T)
46 | | where
47 | | T: Anything<'b, 'c>,
48 | | {
... |
51 | | //~| ERROR failed type test
52 | | }
| |_^
|
= note: defining type: DefId(0/0:8 ~ projection_two_region_trait_bound_closure[317d]::no_relationships_late[0]) with substs [
'_#1r,
'_#2r,
T
]
error: failed type test: TypeTest { generic_kind: ProjectionTy { substs: Slice([T, '_#6r, '_#7r]), item_def_id: DefId(0/0:5 ~ projection_two_region_trait_bound_closure[317d]::Anything[0]::AssocType[0]) }, lower_bound: '_#8r, point: bb0[5], span: $DIR/projection-two-region-trait-bound-closure.rs:60:29: 60:55, test: Any([IsOutlivedByAnyRegionIn(['_#7r, '_#6r]), All([IsOutlivedByAnyRegionIn(['_#4r]), IsOutlivedByAllRegionsIn(['_#6r, '_#7r])])]) }
--> $DIR/projection-two-region-trait-bound-closure.rs:60:29
|
60 | with_signature(cell, t, |cell, t| require(cell, t));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
note: No external requirements
--> $DIR/projection-two-region-trait-bound-closure.rs:55:1
|
55 | / fn no_relationships_early<'a, 'b, 'c, T>(cell: Cell<&'a ()>, t: T)
56 | | where
57 | | T: Anything<'b, 'c>,
58 | | 'a: 'a,
... |
62 | | //~| ERROR failed type test
63 | | }
| |_^
|
= note: defining type: DefId(0/0:9 ~ projection_two_region_trait_bound_closure[317d]::no_relationships_early[0]) with substs [
'_#1r,
'_#2r,
'_#3r,
T
]
error: failed type test: TypeTest { generic_kind: ProjectionTy { substs: Slice([T, '_#6r, '_#7r]), item_def_id: DefId(0/0:5 ~ projection_two_region_trait_bound_closure[317d]::Anything[0]::AssocType[0]) }, lower_bound: '_#8r, point: bb0[5], span: $DIR/projection-two-region-trait-bound-closure.rs:81:29: 81:55, test: Any([IsOutlivedByAnyRegionIn(['_#7r, '_#6r]), All([IsOutlivedByAnyRegionIn(['_#4r]), IsOutlivedByAllRegionsIn(['_#6r, '_#7r])])]) }
--> $DIR/projection-two-region-trait-bound-closure.rs:81:29
|
81 | with_signature(cell, t, |cell, t| require(cell, t));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
note: No external requirements
--> $DIR/projection-two-region-trait-bound-closure.rs:66:1
|
66 | / fn projection_outlives<'a, 'b, 'c, T>(cell: Cell<&'a ()>, t: T)
67 | | where
68 | | T: Anything<'b, 'c>,
69 | | T::AssocType: 'a,
... |
83 | | //~| ERROR failed type test
84 | | }
| |_^
|
= note: defining type: DefId(0/0:10 ~ projection_two_region_trait_bound_closure[317d]::projection_outlives[0]) with substs [
'_#1r,
'_#2r,
'_#3r,
T
]
note: No external requirements
--> $DIR/projection-two-region-trait-bound-closure.rs:87:1
|
87 | / fn elements_outlive1<'a, 'b, 'c, T>(cell: Cell<&'a ()>, t: T)
88 | | where
89 | | T: Anything<'b, 'c>,
90 | | 'b: 'a,
91 | | {
92 | | with_signature(cell, t, |cell, t| require(cell, t));
93 | | }
| |_^
|
= note: defining type: DefId(0/0:11 ~ projection_two_region_trait_bound_closure[317d]::elements_outlive1[0]) with substs [
'_#1r,
'_#2r,
'_#3r,
T
]
note: No external requirements
--> $DIR/projection-two-region-trait-bound-closure.rs:96:1
|
96 | / fn elements_outlive2<'a, 'b, 'c, T>(cell: Cell<&'a ()>, t: T)
97 | | where
98 | | T: Anything<'b, 'c>,
99 | | 'c: 'a,
100 | | {
101 | | with_signature(cell, t, |cell, t| require(cell, t));
102 | | }
| |_^
|
= note: defining type: DefId(0/0:12 ~ projection_two_region_trait_bound_closure[317d]::elements_outlive2[0]) with substs [
'_#1r,
'_#2r,
'_#3r,
T
]
error: free region `ReEarlyBound(0, 'b)` does not outlive free region `'_#2r`
--> $DIR/projection-two-region-trait-bound-closure.rs:109:20
|
109 | with_signature(cell, t, |cell, t| require(cell, t));
| ^^^^
note: No external requirements
--> $DIR/projection-two-region-trait-bound-closure.rs:105:1
|
105 | / fn two_regions<'a, 'b, T>(cell: Cell<&'a ()>, t: T)
106 | | where
107 | | T: Anything<'b, 'b>,
108 | | {
... |
111 | | //~| ERROR free region `ReEarlyBound(0, 'b)` does not outlive free region `'_#2r`
112 | | }
| |_^
|
= note: defining type: DefId(0/0:13 ~ projection_two_region_trait_bound_closure[317d]::two_regions[0]) with substs [
'_#1r,
T
]
note: No external requirements
--> $DIR/projection-two-region-trait-bound-closure.rs:115:1
|
115 | / fn two_regions_outlive<'a, 'b, T>(cell: Cell<&'a ()>, t: T)
116 | | where
117 | | T: Anything<'b, 'b>,
118 | | 'b: 'a,
119 | | {
120 | | with_signature(cell, t, |cell, t| require(cell, t));
121 | | }
| |_^
|
= note: defining type: DefId(0/0:14 ~ projection_two_region_trait_bound_closure[317d]::two_regions_outlive[0]) with substs [
'_#1r,
'_#2r,
T
]
note: No external requirements
--> $DIR/projection-two-region-trait-bound-closure.rs:124:1
|
124 | / fn one_region<'a, T>(cell: Cell<&'a ()>, t: T)
125 | | where
126 | | T: Anything<'a, 'a>,
127 | | {
... |
132 | | with_signature(cell, t, |cell, t| require(cell, t));
133 | | }
| |_^
|
= note: defining type: DefId(0/0:15 ~ projection_two_region_trait_bound_closure[317d]::one_region[0]) with substs [
'_#1r,
T
]
error: aborting due to 4 previous errors