1 // Test how overloaded deref interacts with borrows when only
2 // Deref and not DerefMut is implemented.
13 fn get(&self) -> (isize, isize) {
17 fn set(&mut self, x: isize, y: isize) {
22 fn x_ref(&self) -> &isize {
26 fn y_mut(&mut self) -> &mut isize {
31 fn deref_imm_field(x: Rc<Point>) {
35 fn deref_mut_field1(x: Rc<Point>) {
36 let __isize = &mut x.y; //~ ERROR cannot borrow
39 fn deref_mut_field2(mut x: Rc<Point>) {
40 let __isize = &mut x.y; //~ ERROR cannot borrow
43 fn deref_extend_field(x: &Rc<Point>) -> &isize {
47 fn deref_extend_mut_field1(x: &Rc<Point>) -> &mut isize {
48 &mut x.y //~ ERROR cannot borrow
51 fn deref_extend_mut_field2(x: &mut Rc<Point>) -> &mut isize {
52 &mut x.y //~ ERROR cannot borrow
55 fn assign_field1<'a>(x: Rc<Point>) {
56 x.y = 3; //~ ERROR cannot assign
59 fn assign_field2<'a>(x: &'a Rc<Point>) {
60 x.y = 3; //~ ERROR cannot assign
63 fn assign_field3<'a>(x: &'a mut Rc<Point>) {
64 x.y = 3; //~ ERROR cannot assign
67 fn deref_imm_method(x: Rc<Point>) {
68 let __isize = x.get();
71 fn deref_mut_method1(x: Rc<Point>) {
72 x.set(0, 0); //~ ERROR cannot borrow
75 fn deref_mut_method2(mut x: Rc<Point>) {
76 x.set(0, 0); //~ ERROR cannot borrow
79 fn deref_extend_method(x: &Rc<Point>) -> &isize {
83 fn deref_extend_mut_method1(x: &Rc<Point>) -> &mut isize {
84 x.y_mut() //~ ERROR cannot borrow
87 fn deref_extend_mut_method2(x: &mut Rc<Point>) -> &mut isize {
88 x.y_mut() //~ ERROR cannot borrow
91 fn assign_method1<'a>(x: Rc<Point>) {
92 *x.y_mut() = 3; //~ ERROR cannot borrow
95 fn assign_method2<'a>(x: &'a Rc<Point>) {
96 *x.y_mut() = 3; //~ ERROR cannot borrow
99 fn assign_method3<'a>(x: &'a mut Rc<Point>) {
100 *x.y_mut() = 3; //~ ERROR cannot borrow