Allow mutable slices in statics.

Fixes #11411
This commit is contained in:
xales 2014-01-25 12:48:57 -05:00 committed by Flavio Percoco
parent 1eb3f63d9d
commit 8b8d41d28a
5 changed files with 54 additions and 8 deletions

View file

@ -0,0 +1,13 @@
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
static TEST: &'static mut [int] = &mut []; //~ ERROR mutable slice is not allowed
fn main() { }

View file

@ -0,0 +1,18 @@
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
static mut TEST: &'static mut [int] = &mut [1];
pub fn main() {
unsafe {
TEST[0] += 1;
}
}