File tree Expand file tree Collapse file tree 2 files changed +44
-0
lines changed Expand file tree Collapse file tree 2 files changed +44
-0
lines changed Original file line number Diff line number Diff line change
1
+ // Copyright 2016 The Rust Project Developers. See the COPYRIGHT
2
+ // file at the top-level directory of this distribution and at
3
+ // http://rust-lang.org/COPYRIGHT.
4
+ //
5
+ // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6
+ // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7
+ // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8
+ // option. This file may not be copied, modified, or distributed
9
+ // except according to those terms.
10
+
11
+ // compile-flags: -Z emit-end-regions -Z borrowck=compare
12
+
13
+ fn foo ( ) -> & ' static u32 {
14
+ let x = 0 ;
15
+ & x
16
+ //~^ ERROR `x` does not live long enough (Ast) [E0597]
17
+ //~| ERROR `x` does not live long enough (Mir) [E0597]
18
+ }
19
+
20
+ fn main ( ) { }
Original file line number Diff line number Diff line change
1
+ error[E0597]: `x` does not live long enough (Ast)
2
+ --> $DIR/issue-46471.rs:15:6
3
+ |
4
+ 15 | &x
5
+ | ^ does not live long enough
6
+ ...
7
+ 18 | }
8
+ | - borrowed value only lives until here
9
+ |
10
+ = note: borrowed value must be valid for the static lifetime...
11
+
12
+ error[E0597]: `x` does not live long enough (Mir)
13
+ --> $DIR/issue-46471.rs:15:5
14
+ |
15
+ 15 | &x
16
+ | ^^ does not live long enough
17
+ ...
18
+ 18 | }
19
+ | - borrowed value only lives until here
20
+ |
21
+ = note: borrowed value must be valid for the static lifetime...
22
+
23
+ error: aborting due to 2 previous errors
24
+
You can’t perform that action at this time.
0 commit comments