fork/rust

git clone https://git.julia.blue/fork/rust

borsAuto merge of #69854 - pietroalbini:stable-next, r=Centrilb8cedc00407

1.42.0
1.2 KiB29 linesraw
1error[E0495]: cannot infer an appropriate lifetime for borrow expression due to conflicting requirements
2  --> $DIR/regions-addr-of-self.rs:7:37
3   |
4LL |         let p: &'static mut usize = &mut self.cats_chased;
5   |                                     ^^^^^^^^^^^^^^^^^^^^^
6   |
7note: first, the lifetime cannot outlive the anonymous lifetime #1 defined on the method body at 6:5...
8  --> $DIR/regions-addr-of-self.rs:6:5
9   |
10LL | /     pub fn chase_cat(&mut self) {
11LL | |         let p: &'static mut usize = &mut self.cats_chased;
12LL | |         *p += 1;
13LL | |     }
14   | |_____^
15note: ...so that reference does not outlive borrowed content
16  --> $DIR/regions-addr-of-self.rs:7:37
17   |
18LL |         let p: &'static mut usize = &mut self.cats_chased;
19   |                                     ^^^^^^^^^^^^^^^^^^^^^
20   = note: but, the lifetime must be valid for the static lifetime...
21note: ...so that reference does not outlive borrowed content
22  --> $DIR/regions-addr-of-self.rs:7:37
23   |
24LL |         let p: &'static mut usize = &mut self.cats_chased;
25   |                                     ^^^^^^^^^^^^^^^^^^^^^
26
27error: aborting due to previous error
28
29For more information about this error, try `rustc --explain E0495`.