Skip to content

Commit 482c9d2

Browse files
nikomatsakiseddyb
authored andcommitted
---
yaml --- r: 149926 b: refs/heads/try2 c: a7db0d5 h: refs/heads/master v: v3
1 parent db699b1 commit 482c9d2

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 27c62449db9e752bcab39110aaaad63b2773e68b
8+
refs/heads/try2: a7db0d5d30adbaec2b4ec6e009a0bf9c7850f9be
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/test/compile-fail/borrowck-borrow-overloaded-auto-deref-mut.rs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,21 @@ fn deref_extend_mut_field2<'a>(x: &'a mut Own<Point>) -> &'a mut int {
7777
&mut x.y
7878
}
7979

80+
fn deref_extend_mut_field3<'a>(x: &'a mut Own<Point>) {
81+
// Hmm, this is unfortunate, because with ~ it would work,
82+
// but it's presently the expected outcome. See `deref_extend_mut_field4`
83+
// for the workaround.
84+
85+
let _x = &mut x.x;
86+
let _y = &mut x.y; //~ ERROR cannot borrow
87+
}
88+
89+
fn deref_extend_mut_field4<'a>(x: &'a mut Own<Point>) {
90+
let p = &mut **x;
91+
let _x = &mut p.x;
92+
let _y = &mut p.y;
93+
}
94+
8095
fn assign_field1<'a>(x: Own<Point>) {
8196
x.y = 3; //~ ERROR cannot borrow
8297
}
@@ -89,6 +104,11 @@ fn assign_field3<'a>(x: &'a mut Own<Point>) {
89104
x.y = 3;
90105
}
91106

107+
fn assign_field4<'a>(x: &'a mut Own<Point>) {
108+
let _p: &mut Point = &mut **x;
109+
x.y = 3; //~ ERROR cannot borrow
110+
}
111+
92112
// FIXME(eddyb) #12825 This shouldn't attempt to call deref_mut.
93113
/*
94114
fn deref_imm_method(x: Own<Point>) {
@@ -128,4 +148,4 @@ fn assign_method3<'a>(x: &'a mut Own<Point>) {
128148
*x.y_mut() = 3;
129149
}
130150

131-
pub fn main() {}
151+
pub fn main() {}

0 commit comments

Comments
 (0)