2013-10-23 03:51:45 +00:00
|
|
|
// Can't put mut in non-ident pattern
|
|
|
|
|
2019-08-27 11:04:48 +00:00
|
|
|
// edition:2018
|
|
|
|
|
|
|
|
#![feature(box_patterns)]
|
|
|
|
#![allow(warnings)]
|
|
|
|
|
2013-10-23 03:51:45 +00:00
|
|
|
pub fn main() {
|
2019-08-27 21:44:44 +00:00
|
|
|
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
|
|
|
|
|
2020-02-17 15:03:07 +00:00
|
|
|
let mut (x @ y) = 0; //~ ERROR `mut` must be attached to each individual binding
|
|
|
|
|
2019-08-27 11:04:48 +00:00
|
|
|
let mut mut x = 0;
|
|
|
|
//~^ ERROR `mut` on a binding may not be repeated
|
|
|
|
//~| remove the additional `mut`s
|
|
|
|
|
2015-01-08 10:54:35 +00:00
|
|
|
struct Foo { x: isize }
|
2019-08-18 20:54:07 +00:00
|
|
|
let mut Foo { x: x } = Foo { x: 3 };
|
2019-08-27 11:04:48 +00:00
|
|
|
//~^ 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
|
2023-11-06 21:06:20 +00:00
|
|
|
//~| ERROR `mut` must be followed by a named binding
|
2019-08-27 11:04:48 +00:00
|
|
|
//~| ERROR expected identifier, found reserved keyword `yield`
|
|
|
|
//~| ERROR expected identifier, found reserved keyword `become`
|
2019-09-28 16:15:06 +00:00
|
|
|
//~| ERROR expected identifier, found keyword `await`
|
2019-08-27 11:04:48 +00:00
|
|
|
|
|
|
|
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) }))));
|
2019-08-27 17:51:21 +00:00
|
|
|
|
|
|
|
// 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);
|
2013-10-23 03:51:45 +00:00
|
|
|
}
|