about summary refs log tree commit diff
path: root/src/libsyntax/ext
diff options
context:
space:
mode:
authorHuon Wilson <dbau.pp+github@gmail.com>2014-12-05 15:56:25 -0800
committerHuon Wilson <dbau.pp+github@gmail.com>2015-01-05 16:14:17 +1100
commitbf6c007760169e9c382d3700fd1cdd20037e4343 (patch)
tree248a48e3811afdf8908c5ebf260d67eade27aa92 /src/libsyntax/ext
parent5773bdefff2e47cc007f5cc2af3f80b30303d45a (diff)
downloadrust-bf6c007760169e9c382d3700fd1cdd20037e4343.tar.gz
rust-bf6c007760169e9c382d3700fd1cdd20037e4343.zip
Change `&` pat to only work with &T, and `&mut` with &mut T.
This implements RFC 179 by making the pattern `&<pat>` require matching
against a variable of type `&T`, and introducing the pattern `&mut
<pat>` which only works with variables of type `&mut T`.

The pattern `&mut x` currently parses as `&(mut x)` i.e. a pattern match
through a `&T` or a `&mut T` that binds the variable `x` to have type
`T` and to be mutable. This should be rewritten as follows, for example,

    for &mut x in slice.iter() {

becomes

    for &x in slice.iter() {
        let mut x = x;

Due to this, this is a

[breaking-change]

Closes #20496.
Diffstat (limited to 'src/libsyntax/ext')
-rw-r--r--src/libsyntax/ext/deriving/generic/mod.rs2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/libsyntax/ext/deriving/generic/mod.rs b/src/libsyntax/ext/deriving/generic/mod.rs
index 8863de8757b..d522c346fa0 100644
--- a/src/libsyntax/ext/deriving/generic/mod.rs
+++ b/src/libsyntax/ext/deriving/generic/mod.rs
@@ -940,7 +940,7 @@ impl<'a> MethodDef<'a> {
                                                                          &**variant,
                                                                          self_arg_name,
                                                                          ast::MutImmutable);
-                    (cx.pat(sp, ast::PatRegion(p)), idents)
+                    (cx.pat(sp, ast::PatRegion(p, ast::MutImmutable)), idents)
                 };
 
                 // A single arm has form (&VariantK, &VariantK, ...) => BodyK