1 // Constants (static variables) can be used to match in patterns, but mutable
2 // statics cannot. This ensures that there's some form of error if this is
5 static mut a: isize = 3;
8 // If they can't be matched against, then it's possible to capture the same
9 // name as a variable, hence this should be an unreachable pattern situation
10 // instead of spitting out a custom error about some identifier collisions
11 // (we should allow shadowing)
13 a => {} //~ ERROR match bindings cannot shadow statics
25 const NEW_FALSE: NewBool = NewBool(false);
27 bar: Option<Direction>,
31 static mut STATIC_MUT_FOO: Foo = Foo { bar: Some(Direction::West), baz: NEW_FALSE };
33 fn mutable_statics() {
34 match (Foo { bar: Some(Direction::North), baz: NewBool(true) }) {
35 Foo { bar: None, baz: NewBool(true) } => (),
37 //~^ ERROR match bindings cannot shadow statics
38 Foo { bar: Some(Direction::South), .. } => (),
39 Foo { bar: Some(EAST), .. } => (),
40 Foo { bar: Some(Direction::North), baz: NewBool(true) } => (),
41 Foo { bar: Some(EAST), baz: NewBool(false) } => ()