about summary refs log tree commit diff
path: root/src/rustllvm/RustWrapper.cpp
diff options
context:
space:
mode:
authorPatrick Walton <pcwalton@mimiga.net>2014-07-28 11:33:06 -0700
committerPatrick Walton <pcwalton@mimiga.net>2014-08-01 08:45:22 -0700
commit5b85c8cbe70abb914f9ba66116192667b8235cfb (patch)
tree5c0cf5473084242abd986f078b6ed31e5485b527 /src/rustllvm/RustWrapper.cpp
parent51ff6c075a61cb8219a1d6ce935ccb4cefc7a9fd (diff)
downloadrust-5b85c8cbe70abb914f9ba66116192667b8235cfb.tar.gz
rust-5b85c8cbe70abb914f9ba66116192667b8235cfb.zip
librustc: Forbid pattern bindings after `@`s, for memory safety.
This is an alternative to upgrading the way rvalues are handled in the
borrow check. Making rvalues handled more like lvalues in the borrow
check caused numerous problems related to double mutable borrows and
rvalue scopes. Rather than come up with more borrow check rules to try
to solve these problems, I decided to just forbid pattern bindings after
`@`. This affected fewer than 10 lines of code in the compiler and
libraries.

This breaks code like:

    match x {
        y @ z => { ... }
    }

    match a {
        b @ Some(c) => { ... }
    }

Change this code to use nested `match` or `let` expressions. For
example:

    match x {
        y => {
            let z = y;
            ...
        }
    }

    match a {
        Some(c) => {
            let b = Some(c);
            ...
        }
    }

Closes #14587.

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