connect NLL type checker to the impl trait code
We now add the suitable `impl Trait` constraints.
This commit is contained in:
parent
da63aaa7ab
commit
93afb1affc
14 changed files with 339 additions and 38 deletions
27
src/test/ui/nll/ty-outlives/impl-trait-captures.rs
Normal file
27
src/test/ui/nll/ty-outlives/impl-trait-captures.rs
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
// 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
|
||||
|
||||
#![allow(warnings)]
|
||||
#![feature(conservative_impl_trait)]
|
||||
|
||||
trait Foo<'a> {
|
||||
}
|
||||
|
||||
impl<'a, T> Foo<'a> for T { }
|
||||
|
||||
fn foo<'a, T>(x: &T) -> impl Foo<'a> {
|
||||
x
|
||||
//~^ WARNING not reporting region error due to -Znll
|
||||
//~| ERROR free region `'_#2r` does not outlive free region `ReEarlyBound(0, 'a)`
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
14
src/test/ui/nll/ty-outlives/impl-trait-captures.stderr
Normal file
14
src/test/ui/nll/ty-outlives/impl-trait-captures.stderr
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
warning: not reporting region error due to -Znll
|
||||
--> $DIR/impl-trait-captures.rs:22:5
|
||||
|
|
||||
22 | x
|
||||
| ^
|
||||
|
||||
error: free region `'_#2r` does not outlive free region `ReEarlyBound(0, 'a)`
|
||||
--> $DIR/impl-trait-captures.rs:22:5
|
||||
|
|
||||
22 | x
|
||||
| ^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
51
src/test/ui/nll/ty-outlives/impl-trait-outlives.rs
Normal file
51
src/test/ui/nll/ty-outlives/impl-trait-outlives.rs
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
// 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
|
||||
|
||||
#![allow(warnings)]
|
||||
#![feature(conservative_impl_trait)]
|
||||
|
||||
use std::fmt::Debug;
|
||||
|
||||
fn no_region<'a, T>(x: Box<T>) -> impl Debug + 'a
|
||||
//~^ WARNING not reporting region error due to -Znll
|
||||
where
|
||||
T: Debug,
|
||||
{
|
||||
x
|
||||
//~^ ERROR `T` does not outlive
|
||||
}
|
||||
|
||||
fn correct_region<'a, T>(x: Box<T>) -> impl Debug + 'a
|
||||
where
|
||||
T: 'a + Debug,
|
||||
{
|
||||
x
|
||||
}
|
||||
|
||||
fn wrong_region<'a, 'b, T>(x: Box<T>) -> impl Debug + 'a
|
||||
//~^ WARNING not reporting region error due to -Znll
|
||||
where
|
||||
T: 'b + Debug,
|
||||
{
|
||||
x
|
||||
//~^ ERROR `T` does not outlive
|
||||
}
|
||||
|
||||
fn outlives_region<'a, 'b, T>(x: Box<T>) -> impl Debug + 'a
|
||||
where
|
||||
T: 'b + Debug,
|
||||
'b: 'a,
|
||||
{
|
||||
x
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
26
src/test/ui/nll/ty-outlives/impl-trait-outlives.stderr
Normal file
26
src/test/ui/nll/ty-outlives/impl-trait-outlives.stderr
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
warning: not reporting region error due to -Znll
|
||||
--> $DIR/impl-trait-outlives.rs:18:35
|
||||
|
|
||||
18 | fn no_region<'a, T>(x: Box<T>) -> impl Debug + 'a
|
||||
| ^^^^^^^^^^^^^^^
|
||||
|
||||
warning: not reporting region error due to -Znll
|
||||
--> $DIR/impl-trait-outlives.rs:34:42
|
||||
|
|
||||
34 | fn wrong_region<'a, 'b, T>(x: Box<T>) -> impl Debug + 'a
|
||||
| ^^^^^^^^^^^^^^^
|
||||
|
||||
error: `T` does not outlive `'_#1r`
|
||||
--> $DIR/impl-trait-outlives.rs:23:5
|
||||
|
|
||||
23 | x
|
||||
| ^
|
||||
|
||||
error: `T` does not outlive `'_#1r`
|
||||
--> $DIR/impl-trait-outlives.rs:39:5
|
||||
|
|
||||
39 | x
|
||||
| ^
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue