Added test for #46472
This commit is contained in:
parent
d78e8a730a
commit
15b8fbdfb3
4 changed files with 65 additions and 1 deletions
19
src/test/ui/issue-46472.rs
Normal file
19
src/test/ui/issue-46472.rs
Normal 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() { }
|
||||
40
src/test/ui/issue-46472.stderr
Normal file
40
src/test/ui/issue-46472.stderr
Normal 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
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue