]>
git.proxmox.com Git - rustc.git/blob - src/test/run-pass/static-mut-xc.rs
5911b6cfa8504e4f22fd6b87517f6b84c92a14dd
1 // Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 // Constants (static variables) can be used to match in patterns, but mutable
12 // statics cannot. This ensures that there's some form of error if this is
15 // aux-build:static_mut_xc.rs
18 extern crate static_mut_xc
;
20 unsafe fn static_bound(_
: &'
static isize) {}
22 fn static_bound_set(a
: &'
static mut isize) {
27 assert_eq
!(static_mut_xc
::a
, 3);
29 assert_eq
!(static_mut_xc
::a
, 4);
30 static_mut_xc
::a
+= 1;
31 assert_eq
!(static_mut_xc
::a
, 5);
32 static_mut_xc
::a
*= 3;
33 assert_eq
!(static_mut_xc
::a
, 15);
34 static_mut_xc
::a
= -3;
35 assert_eq
!(static_mut_xc
::a
, -3);
36 static_bound(&static_mut_xc
::a
);
37 static_bound_set(&mut static_mut_xc
::a
);
45 pub static mut a
: isize = 4;