Skip to content

Commit c75542a

Browse files
committed
---
yaml --- r: 120638 b: refs/heads/dist-snap c: f7ccae5 h: refs/heads/master v: v3
1 parent b63b1d8 commit c75542a

File tree

26 files changed

+108
-183
lines changed

26 files changed

+108
-183
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ refs/heads/try: 1813e5aa1a03b0596b8de7abd1af31edf5d6098f
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
9-
refs/heads/dist-snap: 43f942f88656f6b6cb2ff143e496a8875ea157ac
9+
refs/heads/dist-snap: f7ccae5f158cbbb7b910e59befb293e262d3dc1b
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1212
refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0

branches/dist-snap/src/libcollections/lru_cache.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ impl<K: Hash + TotalEq, V> LruCache<K, V> {
9292
let cache = LruCache {
9393
map: HashMap::new(),
9494
max_size: capacity,
95-
head: unsafe{ mem::transmute(box mem::uninitialized::<LruEntry<K, V>>()) },
95+
head: unsafe{ mem::transmute(box mem::uninit::<LruEntry<K, V>>()) },
9696
};
9797
unsafe {
9898
(*cache.head).next = cache.head;

branches/dist-snap/src/libcore/mem.rs

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ pub fn size_of<T>() -> uint {
2626

2727
/// Returns the size of the type that `_val` points to in bytes.
2828
#[inline]
29-
#[stable]
29+
#[unstable = "the name of this function may change slightly before stabilizing"]
3030
pub fn size_of_val<T>(_val: &T) -> uint {
3131
size_of::<T>()
3232
}
@@ -64,7 +64,7 @@ pub fn min_align_of<T>() -> uint {
6464
/// Returns the ABI-required minimum alignment of the type of the value that
6565
/// `_val` points to
6666
#[inline]
67-
#[stable]
67+
#[unstable = "the name of this function may change slightly before stabilizing"]
6868
pub fn min_align_of_val<T>(_val: &T) -> uint {
6969
min_align_of::<T>()
7070
}
@@ -90,7 +90,7 @@ pub fn align_of<T>() -> uint {
9090
/// as trait objects (in the future), returning the alignment for an arbitrary
9191
/// value at runtime.
9292
#[inline]
93-
#[stable]
93+
#[unstable = "the name of this function may change slightly before stabilizing"]
9494
pub fn align_of_val<T>(_val: &T) -> uint {
9595
align_of::<T>()
9696
}
@@ -117,7 +117,7 @@ pub fn pref_align_of_val<T>(val: &T) -> uint { align_of_val(val) }
117117
///
118118
/// This is useful for FFI functions sometimes, but should generally be avoided.
119119
#[inline]
120-
#[stable]
120+
#[unstable = "the name of this function is subject to change"]
121121
pub unsafe fn zeroed<T>() -> T {
122122
intrinsics::init()
123123
}
@@ -136,14 +136,7 @@ pub unsafe fn init<T>() -> T { zeroed() }
136136
///
137137
/// This is useful for FFI functions sometimes, but should generally be avoided.
138138
#[inline]
139-
#[stable]
140-
pub unsafe fn uninitialized<T>() -> T {
141-
intrinsics::uninit()
142-
}
143-
144-
/// Deprecated, use `uninitialized` instead.
145-
#[inline]
146-
#[deprecated = "this function has been renamed to `uninitialized`"]
139+
#[unstable = "the name of this function is subject to change"]
147140
pub unsafe fn uninit<T>() -> T {
148141
intrinsics::uninit()
149142
}
@@ -155,7 +148,7 @@ pub unsafe fn uninit<T>() -> T {
155148
/// contained at the location `dst`. This could leak allocations or resources,
156149
/// so care must be taken to previously deallocate the value at `dst`.
157150
#[inline]
158-
#[stable]
151+
#[unstable = "the name of this function is subject to change"]
159152
pub unsafe fn overwrite<T>(dst: *mut T, src: T) {
160153
intrinsics::move_val_init(&mut *dst, src)
161154
}
@@ -322,7 +315,7 @@ pub fn from_be64(x: u64) -> u64 { x }
322315
pub fn swap<T>(x: &mut T, y: &mut T) {
323316
unsafe {
324317
// Give ourselves some scratch space to work with
325-
let mut t: T = uninitialized();
318+
let mut t: T = uninit();
326319

327320
// Perform the swap, `&mut` pointers never alias
328321
ptr::copy_nonoverlapping_memory(&mut t, &*x, 1);

branches/dist-snap/src/libcore/ptr.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ pub unsafe fn copy_memory<T>(dst: *mut T, src: *T, count: uint) {
196196
/// fn swap<T>(x: &mut T, y: &mut T) {
197197
/// unsafe {
198198
/// // Give ourselves some scratch space to work with
199-
/// let mut t: T = mem::uninitialized();
199+
/// let mut t: T = mem::uninit();
200200
///
201201
/// // Perform the swap, `&mut` pointers never alias
202202
/// ptr::copy_nonoverlapping_memory(&mut t, &*x, 1);
@@ -239,7 +239,7 @@ pub unsafe fn zero_memory<T>(dst: *mut T, count: uint) {
239239
#[inline]
240240
pub unsafe fn swap<T>(x: *mut T, y: *mut T) {
241241
// Give ourselves some scratch space to work with
242-
let mut tmp: T = mem::uninitialized();
242+
let mut tmp: T = mem::uninit();
243243
let t: *mut T = &mut tmp;
244244

245245
// Perform the swap
@@ -263,7 +263,7 @@ pub unsafe fn replace<T>(dest: *mut T, mut src: T) -> T {
263263
/// Reads the value from `*src` and returns it.
264264
#[inline(always)]
265265
pub unsafe fn read<T>(src: *T) -> T {
266-
let mut tmp: T = mem::uninitialized();
266+
let mut tmp: T = mem::uninit();
267267
copy_nonoverlapping_memory(&mut tmp, src, 1);
268268
tmp
269269
}

branches/dist-snap/src/libnative/io/file_unix.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ impl rtio::RtioFileStream for FileDesc {
164164
}
165165

166166
fn fstat(&mut self) -> IoResult<io::FileStat> {
167-
let mut stat: libc::stat = unsafe { mem::zeroed() };
167+
let mut stat: libc::stat = unsafe { mem::uninit() };
168168
match retry(|| unsafe { libc::fstat(self.fd(), &mut stat) }) {
169169
0 => Ok(mkstat(&stat)),
170170
_ => Err(super::last_error()),
@@ -509,15 +509,15 @@ fn mkstat(stat: &libc::stat) -> io::FileStat {
509509
}
510510

511511
pub fn stat(p: &CString) -> IoResult<io::FileStat> {
512-
let mut stat: libc::stat = unsafe { mem::zeroed() };
512+
let mut stat: libc::stat = unsafe { mem::uninit() };
513513
match retry(|| unsafe { libc::stat(p.with_ref(|p| p), &mut stat) }) {
514514
0 => Ok(mkstat(&stat)),
515515
_ => Err(super::last_error()),
516516
}
517517
}
518518

519519
pub fn lstat(p: &CString) -> IoResult<io::FileStat> {
520-
let mut stat: libc::stat = unsafe { mem::zeroed() };
520+
let mut stat: libc::stat = unsafe { mem::uninit() };
521521
match retry(|| unsafe { libc::lstat(p.with_ref(|p| p), &mut stat) }) {
522522
0 => Ok(mkstat(&stat)),
523523
_ => Err(super::last_error()),

branches/dist-snap/src/libnative/io/file_win32.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ impl rtio::RtioFileStream for FileDesc {
195195
}
196196

197197
fn fstat(&mut self) -> IoResult<io::FileStat> {
198-
let mut stat: libc::stat = unsafe { mem::zeroed() };
198+
let mut stat: libc::stat = unsafe { mem::uninit() };
199199
match unsafe { libc::fstat(self.fd(), &mut stat) } {
200200
0 => Ok(mkstat(&stat)),
201201
_ => Err(super::last_error()),
@@ -510,7 +510,7 @@ fn mkstat(stat: &libc::stat) -> io::FileStat {
510510
}
511511

512512
pub fn stat(p: &CString) -> IoResult<io::FileStat> {
513-
let mut stat: libc::stat = unsafe { mem::zeroed() };
513+
let mut stat: libc::stat = unsafe { mem::uninit() };
514514
as_utf16_p(p.as_str().unwrap(), |up| {
515515
match unsafe { libc::wstat(up, &mut stat) } {
516516
0 => Ok(mkstat(&stat)),

branches/dist-snap/src/libregex_macros/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,8 +254,8 @@ fn exec<'t>(which: ::regex::native::MatchKind, input: &'t str,
254254
// The idea here is to avoid initializing threads that never
255255
// need to be initialized, particularly for larger regexs with
256256
// a lot of instructions.
257-
queue: unsafe { ::std::mem::uninitialized() },
258-
sparse: unsafe { ::std::mem::uninitialized() },
257+
queue: unsafe { ::std::mem::uninit() },
258+
sparse: unsafe { ::std::mem::uninit() },
259259
size: 0,
260260
}
261261
}

branches/dist-snap/src/libserialize/serialize.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,10 @@ pub trait Decodable<D:Decoder<E>, E> {
171171
fn decode(d: &mut D) -> Result<Self, E>;
172172
}
173173

174+
macro_rules! try ( ($e:expr) => (
175+
match $e { Ok(v) => v, Err(e) => return Err(e) }
176+
))
177+
174178
impl<E, S:Encoder<E>> Encodable<S, E> for uint {
175179
fn encode(&self, s: &mut S) -> Result<(), E> {
176180
s.emit_uint(*self)

branches/dist-snap/src/libstd/ascii.rs

Lines changed: 48 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,29 @@ impl Ascii {
3939
self.chr as char
4040
}
4141

42-
/// Convert to lowercase.
4342
#[inline]
43+
#[allow(missing_doc)]
44+
#[deprecated="renamed to `to_lowercase`"]
4445
pub fn to_lower(self) -> Ascii {
46+
self.to_lowercase()
47+
}
48+
49+
/// Convert to lowercase.
50+
#[inline]
51+
pub fn to_lowercase(self) -> Ascii {
4552
Ascii{chr: ASCII_LOWER_MAP[self.chr as uint]}
4653
}
4754

48-
/// Convert to uppercase.
4955
#[inline]
56+
#[allow(missing_doc)]
57+
#[deprecated="renamed to `to_uppercase`"]
5058
pub fn to_upper(self) -> Ascii {
59+
self.to_uppercase()
60+
}
61+
62+
/// Convert to uppercase.
63+
#[inline]
64+
pub fn to_uppercase(self) -> Ascii {
5165
Ascii{chr: ASCII_UPPER_MAP[self.chr as uint]}
5266
}
5367

@@ -59,9 +73,16 @@ impl Ascii {
5973

6074
// the following methods are like ctype, and the implementation is inspired by musl
6175

62-
/// Check if the character is a letter (a-z, A-Z)
6376
#[inline]
77+
#[allow(missing_doc)]
78+
#[deprecated="renamed to `is_alphabetic`"]
6479
pub fn is_alpha(&self) -> bool {
80+
self.is_alphabetic()
81+
}
82+
83+
/// Check if the character is a letter (a-z, A-Z)
84+
#[inline]
85+
pub fn is_alphabetic(&self) -> bool {
6586
(self.chr >= 0x41 && self.chr <= 0x5A) || (self.chr >= 0x61 && self.chr <= 0x7A)
6687
}
6788

@@ -71,9 +92,16 @@ impl Ascii {
7192
self.chr >= 0x30 && self.chr <= 0x39
7293
}
7394

74-
/// Check if the character is a letter or number
7595
#[inline]
96+
#[allow(missing_doc)]
97+
#[deprecated="renamed to `is_alphanumeric`"]
7698
pub fn is_alnum(&self) -> bool {
99+
self.is_alphanumeric()
100+
}
101+
102+
/// Check if the character is a letter or number
103+
#[inline]
104+
pub fn is_alphanumeric(&self) -> bool {
77105
self.is_alpha() || self.is_digit()
78106
}
79107

@@ -101,15 +129,29 @@ impl Ascii {
101129
(self.chr - 0x20) < 0x5F
102130
}
103131

104-
/// Checks if the character is lowercase
105132
#[inline]
133+
#[allow(missing_doc)]
134+
#[deprecated="renamed to `is_lowercase`"]
106135
pub fn is_lower(&self) -> bool {
136+
self.is_lowercase()
137+
}
138+
139+
/// Checks if the character is lowercase
140+
#[inline]
141+
pub fn is_lowercase(&self) -> bool {
107142
(self.chr - 'a' as u8) < 26
108143
}
109144

110-
/// Checks if the character is uppercase
111145
#[inline]
146+
#[allow(missing_doc)]
147+
#[deprecated="renamed to `is_uppercase`"]
112148
pub fn is_upper(&self) -> bool {
149+
self.is_uppercase()
150+
}
151+
152+
/// Checks if the character is uppercase
153+
#[inline]
154+
pub fn is_uppercase(&self) -> bool {
113155
(self.chr - 'A' as u8) < 26
114156
}
115157

branches/dist-snap/src/libstd/c_str.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ impl<'a> ToCStr for &'a [u8] {
377377
// Unsafe function that handles possibly copying the &[u8] into a stack array.
378378
unsafe fn with_c_str<T>(v: &[u8], checked: bool, f: |*libc::c_char| -> T) -> T {
379379
if v.len() < BUF_LEN {
380-
let mut buf: [u8, .. BUF_LEN] = mem::uninitialized();
380+
let mut buf: [u8, .. BUF_LEN] = mem::uninit();
381381
slice::bytes::copy_memory(buf, v);
382382
buf[v.len()] = 0;
383383

branches/dist-snap/src/libstd/comm/mod.rs

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -600,22 +600,20 @@ impl<T: Send> Clone for Sender<T> {
600600
let (packet, sleeper) = match *unsafe { self.inner() } {
601601
Oneshot(ref p) => {
602602
let a = Arc::new(Unsafe::new(shared::Packet::new()));
603-
unsafe {
604-
(*a.get()).postinit_lock();
605-
match (*p.get()).upgrade(Receiver::new(Shared(a.clone()))) {
606-
oneshot::UpSuccess | oneshot::UpDisconnected => (a, None),
607-
oneshot::UpWoke(task) => (a, Some(task))
608-
}
603+
match unsafe {
604+
(*p.get()).upgrade(Receiver::new(Shared(a.clone())))
605+
} {
606+
oneshot::UpSuccess | oneshot::UpDisconnected => (a, None),
607+
oneshot::UpWoke(task) => (a, Some(task))
609608
}
610609
}
611610
Stream(ref p) => {
612611
let a = Arc::new(Unsafe::new(shared::Packet::new()));
613-
unsafe {
614-
(*a.get()).postinit_lock();
615-
match (*p.get()).upgrade(Receiver::new(Shared(a.clone()))) {
616-
stream::UpSuccess | stream::UpDisconnected => (a, None),
617-
stream::UpWoke(task) => (a, Some(task)),
618-
}
612+
match unsafe {
613+
(*p.get()).upgrade(Receiver::new(Shared(a.clone())))
614+
} {
615+
stream::UpSuccess | stream::UpDisconnected => (a, None),
616+
stream::UpWoke(task) => (a, Some(task)),
619617
}
620618
}
621619
Shared(ref p) => {

branches/dist-snap/src/libstd/comm/shared.rs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,7 @@ pub enum Failure {
6666
}
6767

6868
impl<T: Send> Packet<T> {
69-
// Creation of a packet *must* be followed by a call to postinit_lock
70-
// and later by inherit_blocker
69+
// Creation of a packet *must* be followed by a call to inherit_blocker
7170
pub fn new() -> Packet<T> {
7271
let p = Packet {
7372
queue: mpsc::Queue::new(),
@@ -79,18 +78,11 @@ impl<T: Send> Packet<T> {
7978
sender_drain: atomics::AtomicInt::new(0),
8079
select_lock: unsafe { NativeMutex::new() },
8180
};
81+
// see comments in inherit_blocker about why we grab this lock
82+
unsafe { p.select_lock.lock_noguard() }
8283
return p;
8384
}
8485

85-
// This function should be used after newly created Packet
86-
// was wrapped with an Arc
87-
// In other case mutex data will be duplicated while clonning
88-
// and that could cause problems on platforms where it is
89-
// represented by opaque data structure
90-
pub fn postinit_lock(&mut self) {
91-
unsafe { self.select_lock.lock_noguard() }
92-
}
93-
9486
// This function is used at the creation of a shared packet to inherit a
9587
// previously blocked task. This is done to prevent spurious wakeups of
9688
// tasks in select().

branches/dist-snap/src/libstd/os.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -969,7 +969,7 @@ pub fn page_size() -> uint {
969969
pub fn page_size() -> uint {
970970
use mem;
971971
unsafe {
972-
let mut info = mem::zeroed();
972+
let mut info = mem::uninit();
973973
libc::GetSystemInfo(&mut info);
974974

975975
return info.dwPageSize as uint;
@@ -1288,7 +1288,7 @@ impl MemoryMap {
12881288
pub fn granularity() -> uint {
12891289
use mem;
12901290
unsafe {
1291-
let mut info = mem::zeroed();
1291+
let mut info = mem::uninit();
12921292
libc::GetSystemInfo(&mut info);
12931293

12941294
return info.dwAllocationGranularity as uint;

branches/dist-snap/src/libstd/rt/thread.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,8 @@ mod imp {
227227
pub type rust_thread_return = *u8;
228228

229229
pub unsafe fn create(stack: uint, p: Box<proc():Send>) -> rust_thread {
230-
let mut native: libc::pthread_t = mem::zeroed();
231-
let mut attr: libc::pthread_attr_t = mem::zeroed();
230+
let mut native: libc::pthread_t = mem::uninit();
231+
let mut attr: libc::pthread_attr_t = mem::uninit();
232232
assert_eq!(pthread_attr_init(&mut attr), 0);
233233
assert_eq!(pthread_attr_setdetachstate(&mut attr,
234234
PTHREAD_CREATE_JOINABLE), 0);

0 commit comments

Comments
 (0)