region-ebr-does-not-outlive-static: reuse old test instead
This commit is contained in:
parent
b8e9eaf3ae
commit
75cf482651
3 changed files with 13 additions and 43 deletions
|
@ -8,17 +8,27 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// revisions: ll nll
|
||||
//[nll] compile-flags: -Znll -Zborrowck=mir
|
||||
|
||||
fn static_id<'a,'b>(t: &'a ()) -> &'static ()
|
||||
where 'a: 'static { t }
|
||||
fn static_id_indirect<'a,'b>(t: &'a ()) -> &'static ()
|
||||
where 'a: 'b, 'b: 'static { t }
|
||||
fn static_id_wrong_way<'a>(t: &'a ()) -> &'static () where 'static: 'a {
|
||||
t //~ ERROR E0312
|
||||
t //[ll]~ ERROR E0312
|
||||
//[nll]~^ WARNING not reporting region error due to -Znll
|
||||
//[nll]~| ERROR free region `'a` does not outlive free region `'static`
|
||||
}
|
||||
|
||||
fn error(u: &(), v: &()) {
|
||||
static_id(&u); //~ ERROR cannot infer an appropriate lifetime
|
||||
static_id_indirect(&v); //~ ERROR cannot infer an appropriate lifetime
|
||||
static_id(&u); //[ll]~ ERROR cannot infer an appropriate lifetime
|
||||
//[nll]~^ WARNING not reporting region error due to -Znll
|
||||
static_id_indirect(&v); //[ll]~ ERROR cannot infer an appropriate lifetime
|
||||
//[nll]~^ WARNING not reporting region error due to -Znll
|
||||
|
||||
// FIXME(#45827) -- MIR type checker shortcomings mean we don't
|
||||
// see these errors (yet) in nll mode.
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
@ -1,26 +0,0 @@
|
|||
// 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.
|
||||
|
||||
// Basic test for free regions in the NLL code. This test ought to
|
||||
// report an error due to a reborrowing constraint. Right now, we get
|
||||
// a variety of errors from the older, AST-based machinery (notably
|
||||
// borrowck), and then we get the NLL error at the end.
|
||||
|
||||
// compile-flags:-Znll -Zborrowck=mir
|
||||
|
||||
fn foo<'a>(x: &'a u32) -> &'static u32
|
||||
where 'static: 'a
|
||||
{
|
||||
&*x
|
||||
//~^ WARN not reporting region error due to -Znll
|
||||
//~| ERROR free region `'a` does not outlive free region `'static`
|
||||
}
|
||||
|
||||
fn main() { }
|
|
@ -1,14 +0,0 @@
|
|||
warning: not reporting region error due to -Znll
|
||||
--> $DIR/region-ebr-does-not-outlive-static.rs:21:5
|
||||
|
|
||||
21 | &*x
|
||||
| ^^^
|
||||
|
||||
error: free region `'a` does not outlive free region `'static`
|
||||
--> $DIR/region-ebr-does-not-outlive-static.rs:21:5
|
||||
|
|
||||
21 | &*x
|
||||
| ^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
Loading…
Reference in a new issue