Skip to content

Commit 9b98332

Browse files
committed
auto merge of #17939 : alexcrichton/rust/snapshots, r=sfackler
Also convert a number of `static mut` to just a plain old `static` and remove some unsafe blocks.
2 parents ba24610 + dae48a0 commit 9b98332

36 files changed

+107
-307
lines changed

src/libcollections/string.rs

-23
Original file line numberDiff line numberDiff line change
@@ -928,29 +928,6 @@ impl<S: Str> Add<S, String> for String {
928928
}
929929
}
930930

931-
#[cfg(stage0)]
932-
impl ops::Slice<uint, str> for String {
933-
#[inline]
934-
fn as_slice_<'a>(&'a self) -> &'a str {
935-
self.as_slice()
936-
}
937-
938-
#[inline]
939-
fn slice_from_<'a>(&'a self, from: &uint) -> &'a str {
940-
self[][*from..]
941-
}
942-
943-
#[inline]
944-
fn slice_to_<'a>(&'a self, to: &uint) -> &'a str {
945-
self[][..*to]
946-
}
947-
948-
#[inline]
949-
fn slice_<'a>(&'a self, from: &uint, to: &uint) -> &'a str {
950-
self[][*from..*to]
951-
}
952-
}
953-
#[cfg(not(stage0))]
954931
impl ops::Slice<uint, str> for String {
955932
#[inline]
956933
fn as_slice_<'a>(&'a self) -> &'a str {

src/libcollections/trie.rs

-18
Original file line numberDiff line numberDiff line change
@@ -389,15 +389,6 @@ macro_rules! bound {
389389

390390
impl<T> TrieMap<T> {
391391
// If `upper` is true then returns upper_bound else returns lower_bound.
392-
#[cfg(stage0)]
393-
#[inline]
394-
fn bound<'a>(&'a self, key: uint, upper: bool) -> Entries<'a, T> {
395-
bound!(Entries, self = self,
396-
key = key, is_upper = upper,
397-
slice_from = slice_from_, iter = iter,
398-
mutability = )
399-
}
400-
#[cfg(not(stage0))]
401392
#[inline]
402393
fn bound<'a>(&'a self, key: uint, upper: bool) -> Entries<'a, T> {
403394
bound!(Entries, self = self,
@@ -440,15 +431,6 @@ impl<T> TrieMap<T> {
440431
self.bound(key, true)
441432
}
442433
// If `upper` is true then returns upper_bound else returns lower_bound.
443-
#[cfg(stage0)]
444-
#[inline]
445-
fn bound_mut<'a>(&'a mut self, key: uint, upper: bool) -> MutEntries<'a, T> {
446-
bound!(MutEntries, self = self,
447-
key = key, is_upper = upper,
448-
slice_from = slice_from_mut_, iter = iter_mut,
449-
mutability = mut)
450-
}
451-
#[cfg(not(stage0))]
452434
#[inline]
453435
fn bound_mut<'a>(&'a mut self, key: uint, upper: bool) -> MutEntries<'a, T> {
454436
bound!(MutEntries, self = self,

src/libcollections/vec.rs

-44
Original file line numberDiff line numberDiff line change
@@ -461,28 +461,6 @@ impl<T> Index<uint,T> for Vec<T> {
461461
}
462462
}*/
463463

464-
#[cfg(stage0)]
465-
impl<T> ops::Slice<uint, [T]> for Vec<T> {
466-
#[inline]
467-
fn as_slice_<'a>(&'a self) -> &'a [T] {
468-
self.as_slice()
469-
}
470-
471-
#[inline]
472-
fn slice_from_<'a>(&'a self, start: &uint) -> &'a [T] {
473-
self.as_slice().slice_from_(start)
474-
}
475-
476-
#[inline]
477-
fn slice_to_<'a>(&'a self, end: &uint) -> &'a [T] {
478-
self.as_slice().slice_to_(end)
479-
}
480-
#[inline]
481-
fn slice_<'a>(&'a self, start: &uint, end: &uint) -> &'a [T] {
482-
self.as_slice().slice_(start, end)
483-
}
484-
}
485-
#[cfg(not(stage0))]
486464
impl<T> ops::Slice<uint, [T]> for Vec<T> {
487465
#[inline]
488466
fn as_slice_<'a>(&'a self) -> &'a [T] {
@@ -504,28 +482,6 @@ impl<T> ops::Slice<uint, [T]> for Vec<T> {
504482
}
505483
}
506484

507-
#[cfg(stage0)]
508-
impl<T> ops::SliceMut<uint, [T]> for Vec<T> {
509-
#[inline]
510-
fn as_mut_slice_<'a>(&'a mut self) -> &'a mut [T] {
511-
self.as_mut_slice()
512-
}
513-
514-
#[inline]
515-
fn slice_from_mut_<'a>(&'a mut self, start: &uint) -> &'a mut [T] {
516-
self.as_mut_slice().slice_from_mut_(start)
517-
}
518-
519-
#[inline]
520-
fn slice_to_mut_<'a>(&'a mut self, end: &uint) -> &'a mut [T] {
521-
self.as_mut_slice().slice_to_mut_(end)
522-
}
523-
#[inline]
524-
fn slice_mut_<'a>(&'a mut self, start: &uint, end: &uint) -> &'a mut [T] {
525-
self.as_mut_slice().slice_mut_(start, end)
526-
}
527-
}
528-
#[cfg(not(stage0))]
529485
impl<T> ops::SliceMut<uint, [T]> for Vec<T> {
530486
#[inline]
531487
fn as_mut_slice_<'a>(&'a mut self) -> &'a mut [T] {

src/libcore/intrinsics.rs

-1
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,6 @@ extern "rust-intrinsic" {
254254
/// enabling further optimizations.
255255
///
256256
/// NB: This is very different from the `unreachable!()` macro!
257-
#[cfg(not(stage0))]
258257
pub fn unreachable() -> !;
259258

260259
/// Execute a breakpoint trap, for inspection by a debugger.

src/libcore/ops.rs

+1-32
Original file line numberDiff line numberDiff line change
@@ -711,7 +711,6 @@ pub trait IndexMut<Index, Result> {
711711
* }
712712
* ```
713713
*/
714-
#[cfg(not(stage0))]
715714
#[lang="slice"]
716715
pub trait Slice<Idx, Sized? Result> for Sized? {
717716
/// The method for the slicing operation foo[]
@@ -723,21 +722,6 @@ pub trait Slice<Idx, Sized? Result> for Sized? {
723722
/// The method for the slicing operation foo[from..to]
724723
fn slice_or_fail<'a>(&'a self, from: &Idx, to: &Idx) -> &'a Result;
725724
}
726-
#[cfg(stage0)]
727-
/**
728-
*
729-
*/
730-
#[lang="slice"]
731-
pub trait Slice<Idx, Sized? Result> for Sized? {
732-
/// The method for the slicing operation foo[]
733-
fn as_slice_<'a>(&'a self) -> &'a Result;
734-
/// The method for the slicing operation foo[from..]
735-
fn slice_from_<'a>(&'a self, from: &Idx) -> &'a Result;
736-
/// The method for the slicing operation foo[..to]
737-
fn slice_to_<'a>(&'a self, to: &Idx) -> &'a Result;
738-
/// The method for the slicing operation foo[from..to]
739-
fn slice_<'a>(&'a self, from: &Idx, to: &Idx) -> &'a Result;
740-
}
741725

742726
/**
743727
*
@@ -776,7 +760,6 @@ pub trait Slice<Idx, Sized? Result> for Sized? {
776760
* }
777761
* ```
778762
*/
779-
#[cfg(not(stage0))]
780763
#[lang="slice_mut"]
781764
pub trait SliceMut<Idx, Sized? Result> for Sized? {
782765
/// The method for the slicing operation foo[]
@@ -788,21 +771,7 @@ pub trait SliceMut<Idx, Sized? Result> for Sized? {
788771
/// The method for the slicing operation foo[from..to]
789772
fn slice_or_fail_mut<'a>(&'a mut self, from: &Idx, to: &Idx) -> &'a mut Result;
790773
}
791-
#[cfg(stage0)]
792-
/**
793-
*
794-
*/
795-
#[lang="slice_mut"]
796-
pub trait SliceMut<Idx, Sized? Result> for Sized? {
797-
/// The method for the slicing operation foo[mut]
798-
fn as_mut_slice_<'a>(&'a mut self) -> &'a mut Result;
799-
/// The method for the slicing operation foo[mut from..]
800-
fn slice_from_mut_<'a>(&'a mut self, from: &Idx) -> &'a mut Result;
801-
/// The method for the slicing operation foo[mut ..to]
802-
fn slice_to_mut_<'a>(&'a mut self, to: &Idx) -> &'a mut Result;
803-
/// The method for the slicing operation foo[mut from..to]
804-
fn slice_mut_<'a>(&'a mut self, from: &Idx, to: &Idx) -> &'a mut Result;
805-
}
774+
806775
/**
807776
*
808777
* The `Deref` trait is used to specify the functionality of dereferencing

src/libcore/slice.rs

-59
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,6 @@ impl<'a,T> ImmutableSlice<'a, T> for &'a [T] {
488488

489489

490490

491-
#[cfg(not(stage0))]
492491
impl<T> ops::Slice<uint, [T]> for [T] {
493492
#[inline]
494493
fn as_slice_<'a>(&'a self) -> &'a [T] {
@@ -516,36 +515,7 @@ impl<T> ops::Slice<uint, [T]> for [T] {
516515
}
517516
}
518517
}
519-
#[cfg(stage0)]
520-
impl<T> ops::Slice<uint, [T]> for [T] {
521-
#[inline]
522-
fn as_slice_<'a>(&'a self) -> &'a [T] {
523-
self
524-
}
525-
526-
#[inline]
527-
fn slice_from_<'a>(&'a self, start: &uint) -> &'a [T] {
528-
self.slice_(start, &self.len())
529-
}
530518

531-
#[inline]
532-
fn slice_to_<'a>(&'a self, end: &uint) -> &'a [T] {
533-
self.slice_(&0, end)
534-
}
535-
#[inline]
536-
fn slice_<'a>(&'a self, start: &uint, end: &uint) -> &'a [T] {
537-
assert!(*start <= *end);
538-
assert!(*end <= self.len());
539-
unsafe {
540-
transmute(RawSlice {
541-
data: self.as_ptr().offset(*start as int),
542-
len: (*end - *start)
543-
})
544-
}
545-
}
546-
}
547-
548-
#[cfg(not(stage0))]
549519
impl<T> ops::SliceMut<uint, [T]> for [T] {
550520
#[inline]
551521
fn as_mut_slice_<'a>(&'a mut self) -> &'a mut [T] {
@@ -574,35 +544,6 @@ impl<T> ops::SliceMut<uint, [T]> for [T] {
574544
}
575545
}
576546
}
577-
#[cfg(stage0)]
578-
impl<T> ops::SliceMut<uint, [T]> for [T] {
579-
#[inline]
580-
fn as_mut_slice_<'a>(&'a mut self) -> &'a mut [T] {
581-
self
582-
}
583-
584-
#[inline]
585-
fn slice_from_mut_<'a>(&'a mut self, start: &uint) -> &'a mut [T] {
586-
let len = &self.len();
587-
self.slice_mut_(start, len)
588-
}
589-
590-
#[inline]
591-
fn slice_to_mut_<'a>(&'a mut self, end: &uint) -> &'a mut [T] {
592-
self.slice_mut_(&0, end)
593-
}
594-
#[inline]
595-
fn slice_mut_<'a>(&'a mut self, start: &uint, end: &uint) -> &'a mut [T] {
596-
assert!(*start <= *end);
597-
assert!(*end <= self.len());
598-
unsafe {
599-
transmute(RawSlice {
600-
data: self.as_ptr().offset(*start as int),
601-
len: (*end - *start)
602-
})
603-
}
604-
}
605-
}
606547

607548
/// Extension methods for slices such that their elements are
608549
/// mutable.

src/libcore/str.rs

-23
Original file line numberDiff line numberDiff line change
@@ -1164,29 +1164,6 @@ pub mod traits {
11641164
fn equiv(&self, other: &S) -> bool { eq_slice(*self, other.as_slice()) }
11651165
}
11661166

1167-
#[cfg(stage0)]
1168-
impl ops::Slice<uint, str> for str {
1169-
#[inline]
1170-
fn as_slice_<'a>(&'a self) -> &'a str {
1171-
self
1172-
}
1173-
1174-
#[inline]
1175-
fn slice_from_<'a>(&'a self, from: &uint) -> &'a str {
1176-
self.slice_from(*from)
1177-
}
1178-
1179-
#[inline]
1180-
fn slice_to_<'a>(&'a self, to: &uint) -> &'a str {
1181-
self.slice_to(*to)
1182-
}
1183-
1184-
#[inline]
1185-
fn slice_<'a>(&'a self, from: &uint, to: &uint) -> &'a str {
1186-
self.slice(*from, *to)
1187-
}
1188-
}
1189-
#[cfg(not(stage0))]
11901167
impl ops::Slice<uint, str> for str {
11911168
#[inline]
11921169
fn as_slice_<'a>(&'a self) -> &'a str {

src/libcoretest/atomic.rs

+6-8
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,13 @@ fn int_xor() {
6969
assert_eq!(x.load(SeqCst), 0xf731 ^ 0x137f);
7070
}
7171

72-
static mut S_BOOL : AtomicBool = INIT_ATOMIC_BOOL;
73-
static mut S_INT : AtomicInt = INIT_ATOMIC_INT;
74-
static mut S_UINT : AtomicUint = INIT_ATOMIC_UINT;
72+
static S_BOOL : AtomicBool = INIT_ATOMIC_BOOL;
73+
static S_INT : AtomicInt = INIT_ATOMIC_INT;
74+
static S_UINT : AtomicUint = INIT_ATOMIC_UINT;
7575

7676
#[test]
7777
fn static_init() {
78-
unsafe {
79-
assert!(!S_BOOL.load(SeqCst));
80-
assert!(S_INT.load(SeqCst) == 0);
81-
assert!(S_UINT.load(SeqCst) == 0);
82-
}
78+
assert!(!S_BOOL.load(SeqCst));
79+
assert!(S_INT.load(SeqCst) == 0);
80+
assert!(S_UINT.load(SeqCst) == 0);
8381
}

src/libgreen/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ impl SchedPool {
335335
/// This will configure the pool according to the `config` parameter, and
336336
/// initially run `main` inside the pool of schedulers.
337337
pub fn new(config: PoolConfig) -> SchedPool {
338-
static mut POOL_ID: AtomicUint = INIT_ATOMIC_UINT;
338+
static POOL_ID: AtomicUint = INIT_ATOMIC_UINT;
339339

340340
let PoolConfig {
341341
threads: nscheds,
@@ -349,7 +349,7 @@ impl SchedPool {
349349
threads: vec![],
350350
handles: vec![],
351351
stealers: vec![],
352-
id: unsafe { POOL_ID.fetch_add(1, SeqCst) },
352+
id: POOL_ID.fetch_add(1, SeqCst),
353353
sleepers: SleeperList::new(),
354354
stack_pool: StackPool::new(),
355355
deque_pool: deque::BufferPool::new(),

src/libgreen/sched.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1458,7 +1458,7 @@ mod test {
14581458
#[test]
14591459
fn test_spawn_sched_blocking() {
14601460
use std::rt::mutex::{StaticNativeMutex, NATIVE_MUTEX_INIT};
1461-
static mut LOCK: StaticNativeMutex = NATIVE_MUTEX_INIT;
1461+
static LOCK: StaticNativeMutex = NATIVE_MUTEX_INIT;
14621462

14631463
// Testing that a task in one scheduler can block in foreign code
14641464
// without affecting other schedulers

src/libgreen/stack.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,8 @@ impl StackPool {
158158
}
159159

160160
fn max_cached_stacks() -> uint {
161-
static mut AMT: atomic::AtomicUint = atomic::INIT_ATOMIC_UINT;
162-
match unsafe { AMT.load(atomic::SeqCst) } {
161+
static AMT: atomic::AtomicUint = atomic::INIT_ATOMIC_UINT;
162+
match AMT.load(atomic::SeqCst) {
163163
0 => {}
164164
n => return n - 1,
165165
}
@@ -169,7 +169,7 @@ fn max_cached_stacks() -> uint {
169169
let amt = amt.unwrap_or(10);
170170
// 0 is our sentinel value, so ensure that we'll never see 0 after
171171
// initialization has run
172-
unsafe { AMT.store(amt + 1, atomic::SeqCst); }
172+
AMT.store(amt + 1, atomic::SeqCst);
173173
return amt;
174174
}
175175

src/liblog/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -348,8 +348,8 @@ pub struct LogLocation {
348348
/// module's log statement should be emitted or not.
349349
#[doc(hidden)]
350350
pub fn mod_enabled(level: u32, module: &str) -> bool {
351-
static mut INIT: Once = ONCE_INIT;
352-
unsafe { INIT.doit(init); }
351+
static INIT: Once = ONCE_INIT;
352+
INIT.doit(init);
353353

354354
// It's possible for many threads are in this function, only one of them
355355
// will perform the global initialization, but all of them will need to check

src/libnative/io/helper_thread.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ pub struct Helper<M> {
5555
pub initialized: UnsafeCell<bool>,
5656
}
5757

58-
macro_rules! helper_init( (static mut $name:ident: Helper<$m:ty>) => (
59-
static mut $name: Helper<$m> = Helper {
58+
macro_rules! helper_init( (static $name:ident: Helper<$m:ty>) => (
59+
static $name: Helper<$m> = Helper {
6060
lock: ::std::rt::mutex::NATIVE_MUTEX_INIT,
6161
chan: ::std::cell::UnsafeCell { value: 0 as *mut Sender<$m> },
6262
signal: ::std::cell::UnsafeCell { value: 0 },

src/libnative/io/net.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1063,7 +1063,7 @@ mod os {
10631063
unsafe {
10641064
use std::rt::mutex::{StaticNativeMutex, NATIVE_MUTEX_INIT};
10651065
static mut INITIALIZED: bool = false;
1066-
static mut LOCK: StaticNativeMutex = NATIVE_MUTEX_INIT;
1066+
static LOCK: StaticNativeMutex = NATIVE_MUTEX_INIT;
10671067

10681068
let _guard = LOCK.lock();
10691069
if !INITIALIZED {

0 commit comments

Comments
 (0)