about summary refs log tree commit diff
path: root/src/rustllvm/RustWrapper.cpp
diff options
context:
space:
mode:
authorPatrick Walton <pcwalton@mimiga.net>2014-08-12 14:25:41 -0700
committerPatrick Walton <pcwalton@mimiga.net>2014-08-12 14:30:05 -0700
commitf1799fdfcae806988bd7104870da56c7596af8ac (patch)
tree07030434f531353eee21c29df90609a97220f1e3 /src/rustllvm/RustWrapper.cpp
parente2273d945640442224a09e532865e4a58257a851 (diff)
downloadrust-f1799fdfcae806988bd7104870da56c7596af8ac.tar.gz
rust-f1799fdfcae806988bd7104870da56c7596af8ac.zip
librustc: Record unique immutable borrows in the restrictions table.
This fixes borrow checking for closures. Code like this will break:

    struct Foo {
        x: int,
    }

    pub fn main() {
        let mut this = &mut Foo {
            x: 1,
        };
        let r = || {
            let p = &this.x;
            &mut this.x;
        };
        r()
    }

Change this code to not take multiple mutable references to the same value. For
example:

    struct Foo {
        x: int,
    }

    pub fn main() {
        let mut this = &mut Foo {
            x: 1,
        };
        let r = || {
            &mut this.x;
        };
        r()
    }

Closes #16361.

[breaking-change]
Diffstat (limited to 'src/rustllvm/RustWrapper.cpp')
0 files changed, 0 insertions, 0 deletions