]>
Commit | Line | Data |
---|---|---|
223e47cc LB |
1 | // Copyright 2012 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 | ||
1a4d82fc JJ |
11 | // Issue #8624. Tests that reborrowing the contents of an `&'b mut` |
12 | // pointer which is backed by another `&'a mut` can only be done | |
13 | // for `'a` (which must be a sublifetime of `'b`). | |
223e47cc | 14 | |
1a4d82fc | 15 | fn copy_borrowed_ptr<'a, 'b>(p: &'a mut &'b mut isize) -> &'b mut isize { |
abe05a73 | 16 | &mut **p //~ ERROR 16:5: 16:13: lifetime mismatch [E0623] |
223e47cc LB |
17 | } |
18 | ||
19 | fn main() { | |
1a4d82fc JJ |
20 | let mut x = 1; |
21 | let mut y = &mut x; | |
22 | let z = copy_borrowed_ptr(&mut y); | |
23 | *y += 1; | |
24 | *z += 1; | |
223e47cc | 25 | } |