]> git.proxmox.com Git - rustc.git/blame - src/test/compile-fail/regions-reborrow-from-shorter-mut-ref.rs
New upstream version 1.23.0+dfsg1
[rustc.git] / src / test / compile-fail / regions-reborrow-from-shorter-mut-ref.rs
CommitLineData
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 15fn 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
19fn 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}