]>
git.proxmox.com Git - rustc.git/blob - src/test/run-pass/statics/static-mut-xc.rs
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.
12 #![allow(non_upper_case_globals)]
14 // Constants (static variables) can be used to match in patterns, but mutable
15 // statics cannot. This ensures that there's some form of error if this is
18 // aux-build:static_mut_xc.rs
21 extern crate static_mut_xc
;
23 unsafe fn static_bound(_
: &'
static isize) {}
25 fn static_bound_set(a
: &'
static mut isize) {
30 assert_eq
!(static_mut_xc
::a
, 3);
32 assert_eq
!(static_mut_xc
::a
, 4);
33 static_mut_xc
::a
+= 1;
34 assert_eq
!(static_mut_xc
::a
, 5);
35 static_mut_xc
::a
*= 3;
36 assert_eq
!(static_mut_xc
::a
, 15);
37 static_mut_xc
::a
= -3;
38 assert_eq
!(static_mut_xc
::a
, -3);
39 static_bound(&static_mut_xc
::a
);
40 static_bound_set(&mut static_mut_xc
::a
);
48 pub static mut a
: isize = 4;