diff options
Diffstat (limited to 'src/test/compile-fail/borrowck-assign-comp.rs')
| -rw-r--r-- | src/test/compile-fail/borrowck-assign-comp.rs | 17 |
1 files changed, 4 insertions, 13 deletions
diff --git a/src/test/compile-fail/borrowck-assign-comp.rs b/src/test/compile-fail/borrowck-assign-comp.rs index f5597859433..283f04a283f 100644 --- a/src/test/compile-fail/borrowck-assign-comp.rs +++ b/src/test/compile-fail/borrowck-assign-comp.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -struct point {x: int, mut y: int } +struct point { x: int, y: int } fn a() { let mut p = point {x: 3, y: 4}; @@ -20,22 +20,13 @@ fn a() { p.x = 5; //~ ERROR assigning to mutable field prohibited due to outstanding loan } -fn b() { - let mut p = point {x: 3, mut y: 4}; - // This assignment is legal because `y` is inherently mutable (and - // hence &_q.y is &mut int). - let _q = &p; - - p.y = 5; -} - fn c() { // this is sort of the opposite. We take a loan to the interior of `p` // and then try to overwrite `p` as a whole. - let mut p = point {x: 3, mut y: 4}; + let mut p = point {x: 3, y: 4}; let _q = &p.y; //~ NOTE loan of mutable local variable granted here - p = point {x: 5, mut y: 7};//~ ERROR assigning to mutable local variable prohibited due to outstanding loan + p = point {x: 5, y: 7};//~ ERROR assigning to mutable local variable prohibited due to outstanding loan copy p; } @@ -43,7 +34,7 @@ fn d() { // just for completeness's sake, the easy case, where we take the // address of a subcomponent and then modify that subcomponent: - let mut p = point {x: 3, mut y: 4}; + let mut p = point {x: 3, y: 4}; let _q = &p.y; //~ NOTE loan of mutable field granted here p.y = 5; //~ ERROR assigning to mutable field prohibited due to outstanding loan copy p; |
