diff options
| author | Baoshan <pangbw@gmail.com> | 2019-09-01 17:52:09 -0700 | 
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-09-01 17:52:09 -0700 | 
| commit | d5ef9df032ec32c48d6c59050735352c48ff16f8 (patch) | |
| tree | 31a87971a84ffc967645099773910d6498d0cb0b /src/test/ui/parser/mut-patterns.rs | |
| parent | 7726b54c059db0759e9725a58e222118eacec6d9 (diff) | |
| parent | dfd43f0fdd4e6969c7d82c0670d70bf305fbccf8 (diff) | |
| download | rust-d5ef9df032ec32c48d6c59050735352c48ff16f8.tar.gz rust-d5ef9df032ec32c48d6c59050735352c48ff16f8.zip | |
Merge pull request #13 from rust-lang/master
sync with rust-lang/rust
Diffstat (limited to 'src/test/ui/parser/mut-patterns.rs')
| -rw-r--r-- | src/test/ui/parser/mut-patterns.rs | 42 | 
1 files changed, 41 insertions, 1 deletions
| diff --git a/src/test/ui/parser/mut-patterns.rs b/src/test/ui/parser/mut-patterns.rs index a5eb4825239..d46186a0fea 100644 --- a/src/test/ui/parser/mut-patterns.rs +++ b/src/test/ui/parser/mut-patterns.rs @@ -1,6 +1,46 @@ // Can't put mut in non-ident pattern +// edition:2018 + +#![feature(box_patterns)] +#![allow(warnings)] + pub fn main() { + let mut _ = 0; //~ ERROR `mut` must be followed by a named binding + let mut (_, _) = (0, 0); //~ ERROR `mut` must be followed by a named binding + + let mut mut x = 0; + //~^ ERROR `mut` on a binding may not be repeated + //~| remove the additional `mut`s + struct Foo { x: isize } - let mut Foo { x: x } = Foo { x: 3 }; //~ ERROR: expected one of `:`, `;`, `=`, or `@`, found `{` + let mut Foo { x: x } = Foo { x: 3 }; + //~^ ERROR `mut` must be attached to each individual binding + //~| add `mut` to each binding + + let mut Foo { x } = Foo { x: 3 }; + //~^ ERROR `mut` must be attached to each individual binding + //~| add `mut` to each binding + + struct r#yield(u8, u8); + let mut mut yield(become, await) = r#yield(0, 0); + //~^ ERROR `mut` on a binding may not be repeated + //~| ERROR `mut` must be attached to each individual binding + //~| ERROR expected identifier, found reserved keyword `yield` + //~| ERROR expected identifier, found reserved keyword `become` + //~| ERROR expected identifier, found reserved keyword `await` + + struct W<T, U>(T, U); + struct B { f: Box<u8> } + let mut W(mut a, W(b, W(ref c, W(d, B { box f })))) + //~^ ERROR `mut` must be attached to each individual binding + = W(0, W(1, W(2, W(3, B { f: Box::new(4u8) })))); + + // Make sure we don't accidentally allow `mut $p` where `$p:pat`. + macro_rules! foo { + ($p:pat) => { + let mut $p = 0; //~ ERROR expected identifier, found `x` + } + } + foo!(x); } | 
