move some parts of liveness to happen during type checking
This allows us to re-use the `normalize` method on `TypeCheck`, which is important since normalization may create fresh region variables. This is not an ideal solution, though, since the current representation of "liveness constraints" (a vector of (region, point) pairs) is rather inefficient. Could do somewhat better by converting to indices, but it'd still be less good than the older code. Unclear how important this is.
This commit is contained in:
parent
4a940b3215
commit
47c1921b9a
7 changed files with 351 additions and 199 deletions
53
src/test/ui/nll/ty-outlives/projection-fn.rs
Normal file
53
src/test/ui/nll/ty-outlives/projection-fn.rs
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
// 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
|
||||
|
||||
#![allow(warnings)]
|
||||
#![feature(dyn_trait)]
|
||||
|
||||
trait Anything { }
|
||||
|
||||
impl<T> Anything for T { }
|
||||
|
||||
fn no_region<'a, T>(mut x: T) -> Box<dyn Anything + 'a>
|
||||
where
|
||||
T: Iterator,
|
||||
{
|
||||
Box::new(x.next())
|
||||
//~^ WARNING not reporting region error due to -Znll
|
||||
//~| ERROR failed type test
|
||||
}
|
||||
|
||||
fn correct_region<'a, T>(mut x: T) -> Box<dyn Anything + 'a>
|
||||
where
|
||||
T: 'a + Iterator,
|
||||
{
|
||||
Box::new(x.next())
|
||||
}
|
||||
|
||||
fn wrong_region<'a, 'b, T>(mut x: T) -> Box<dyn Anything + 'a>
|
||||
where
|
||||
T: 'b + Iterator,
|
||||
{
|
||||
Box::new(x.next())
|
||||
//~^ WARNING not reporting region error due to -Znll
|
||||
//~| ERROR failed type test
|
||||
}
|
||||
|
||||
fn outlives_region<'a, 'b, T>(mut x: T) -> Box<dyn Anything + 'a>
|
||||
where
|
||||
T: 'b + Iterator,
|
||||
'b: 'a,
|
||||
{
|
||||
Box::new(x.next())
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
26
src/test/ui/nll/ty-outlives/projection-fn.stderr
Normal file
26
src/test/ui/nll/ty-outlives/projection-fn.stderr
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
warning: not reporting region error due to -Znll
|
||||
--> $DIR/projection-fn.rs:24:5
|
||||
|
|
||||
24 | Box::new(x.next())
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
||||
warning: not reporting region error due to -Znll
|
||||
--> $DIR/projection-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: '_#3r, point: bb5[0], span: $DIR/projection-fn.rs:24:5: 24:23, test: IsOutlivedByAnyRegionIn([]) }
|
||||
--> $DIR/projection-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: '_#4r, point: bb5[0], span: $DIR/projection-fn.rs:40:5: 40:23, test: IsOutlivedByAnyRegionIn(['_#2r]) }
|
||||
--> $DIR/projection-fn.rs:40:5
|
||||
|
|
||||
40 | Box::new(x.next())
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue