Skip to content

Commit 9e9aa86

Browse files
committed
---
yaml --- r: 92233 b: refs/heads/auto c: fc74d64 h: refs/heads/master i: 92231: 05e749a v: v3
1 parent 08f28ff commit 9e9aa86

File tree

4 files changed

+24
-4
lines changed

4 files changed

+24
-4
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
1313
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1414
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1515
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
16-
refs/heads/auto: 76d9a9671bf456407c1b8fd029a4a1149684fb5b
16+
refs/heads/auto: fc74d64f7d1b4daa95b21ff93cb78bbaf9798e81
1717
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1818
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1919
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336

branches/auto/src/librustc/middle/borrowck/doc.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -790,7 +790,15 @@ particular, if the referent is frozen, there is no harm in it:
790790
791791
In this case, creating the alias `t2` of `t0` is safe because the only
792792
thing `t2` can be used for is to further freeze `*t0`, which is
793-
already frozen.
793+
already frozen. In particular, we cannot assign to `*t0` through the
794+
new alias `t2`, as demonstrated in this test case:
795+
796+
// src/test/run-pass/borrowck-borrow-mut-base-ptr-in-aliasable-loc.rs
797+
fn foo(t0: & &mut int) {
798+
let t1 = t0;
799+
let p: &int = &**t0;
800+
**t1 = 22; //~ ERROR cannot assign
801+
}
794802
795803
This distinction is reflected in the rules. When doing an `&mut`
796804
borrow -- as in the first example -- the set `ACTIONS` will be
@@ -805,6 +813,8 @@ the referent implies that it cannot be claimed or mutated but permits
805813
others to freeze. Hence when these restrictions are propagated back to
806814
the base path, it will still be considered freezable.
807815
816+
817+
808818
**FIXME #10520: Restrictions against mutating the base pointer.** When
809819
an `&mut` pointer is frozen or claimed, we currently pass along the
810820
restriction against MUTATE to the base pointer. I do not believe this

branches/auto/src/test/compile-fail/borrowck-borrow-mut-base-ptr-in-aliasable-loc.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
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+
111
// Test that attempt to reborrow an `&mut` pointer in an aliasable
212
// location yields an error.
313
//
@@ -7,7 +17,7 @@ use std::util::swap;
717

818
fn foo(t0: & &mut int) {
919
let t1 = t0;
10-
let p: &int = &**t0; //~ ERROR cannot borrow an `&mut` in a `&` pointer
20+
let p: &int = &**t0;
1121
**t1 = 22; //~ ERROR cannot assign
1222
}
1323

branches/auto/src/test/compile-fail/borrowck-borrow-of-mut-base-ptr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ fn foo<'a>(mut t0: &'a mut int,
1919
mut t1: &'a mut int) {
2020
let p: &mut int = &mut *t0; // Claims `*t0`
2121
let mut t2 = &t0; //~ ERROR cannot borrow `t0`
22-
let q: &int = &*t2; // Freezes `*t0` but not through `*p`
22+
let q: &int = &**t2; // Freezes `*t0` but not through `*p`
2323
*p += 1; // violates type of `*q`
2424
}
2525

0 commit comments

Comments
 (0)