]>
git.proxmox.com Git - rustc.git/blob - tests/ui/borrowck/borrowck-borrow-overloaded-deref.rs
1 // Test how overloaded deref interacts with borrows when only
2 // Deref and not DerefMut is implemented.
7 fn deref_imm(x
: Rc
<isize>) {
11 fn deref_mut1(x
: Rc
<isize>) {
12 let __isize
= &mut *x
; //~ ERROR cannot borrow
15 fn deref_mut2(mut x
: Rc
<isize>) {
16 let __isize
= &mut *x
; //~ ERROR cannot borrow
19 fn deref_extend
<'a
>(x
: &'a Rc
<isize>) -> &'a
isize {
23 fn deref_extend_mut1
<'a
>(x
: &'a Rc
<isize>) -> &'a
mut isize {
24 &mut **x
//~ ERROR cannot borrow
27 fn deref_extend_mut2
<'a
>(x
: &'a
mut Rc
<isize>) -> &'a
mut isize {
28 &mut **x
//~ ERROR cannot borrow
31 fn assign1
<'a
>(x
: Rc
<isize>) {
32 *x
= 3; //~ ERROR cannot assign
35 fn assign2
<'a
>(x
: &'a Rc
<isize>) {
36 **x
= 3; //~ ERROR cannot assign
39 fn assign3
<'a
>(x
: &'a
mut Rc
<isize>) {
40 **x
= 3; //~ ERROR cannot assign