]> git.lizzy.rs Git - rust.git/blob - src/test/ui/regions/regions-addr-of-self.rs
Use the same message as type & const generics.
[rust.git] / src / test / ui / regions / regions-addr-of-self.rs
1 // revisions: base nll
2 // ignore-compare-mode-nll
3 //[nll] compile-flags: -Z borrowck=mir
4
5 struct Dog {
6     cats_chased: usize,
7 }
8
9 impl Dog {
10     pub fn chase_cat(&mut self) {
11         let p: &'static mut usize = &mut self.cats_chased;
12         //[base]~^ ERROR E0759
13         //[nll]~^^ ERROR lifetime may not live long enough
14         *p += 1;
15     }
16
17     pub fn chase_cat_2(&mut self) {
18         let p: &mut usize = &mut self.cats_chased;
19         *p += 1;
20     }
21 }
22
23 fn dog() -> Dog {
24     Dog {
25         cats_chased: 0
26     }
27 }
28
29 fn main() {
30     let mut d = dog();
31     d.chase_cat();
32     println!("cats_chased: {}", d.cats_chased);
33 }