Added test for #46472

This commit is contained in:
David Wood 2017-12-10 17:00:20 +00:00
parent d78e8a730a
commit 15b8fbdfb3
No known key found for this signature in database
GPG key ID: 01760B4F9F53F154
4 changed files with 65 additions and 1 deletions

View file

@ -0,0 +1,19 @@
// 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: -Z emit-end-regions -Z borrowck=compare
fn bar<'a>() -> &'a mut u32 {
&mut 4
//~^ ERROR borrowed value does not live long enough (Ast) [E0597]
//~| ERROR borrowed value does not live long enough (Mir) [E0597]
}
fn main() { }

View file

@ -0,0 +1,40 @@
error[E0597]: borrowed value does not live long enough (Ast)
--> $DIR/issue-46472.rs:14:10
|
14 | &mut 4
| ^ does not live long enough
...
17 | }
| - temporary value only lives until here
|
note: borrowed value must be valid for the lifetime 'a as defined on the function body at 13:1...
--> $DIR/issue-46472.rs:13:1
|
13 | / fn bar<'a>() -> &'a mut u32 {
14 | | &mut 4
15 | | //~^ ERROR borrowed value does not live long enough (Ast) [E0597]
16 | | //~| ERROR borrowed value does not live long enough (Mir) [E0597]
17 | | }
| |_^
error[E0597]: borrowed value does not live long enough (Mir)
--> $DIR/issue-46472.rs:14:10
|
14 | &mut 4
| ^ does not live long enough
...
17 | }
| - temporary value only lives until here
|
note: borrowed value must be valid for the lifetime 'a as defined on the function body at 13:1...
--> $DIR/issue-46472.rs:13:1
|
13 | / fn bar<'a>() -> &'a mut u32 {
14 | | &mut 4
15 | | //~^ ERROR borrowed value does not live long enough (Ast) [E0597]
16 | | //~| ERROR borrowed value does not live long enough (Mir) [E0597]
17 | | }
| |_^
error: aborting due to 2 previous errors