Skip to content

Commit 41892d5

Browse files
committed
---
yaml --- r: 166581 b: refs/heads/snap-stage3 c: 19f73b4 h: refs/heads/master i: 166579: 8ad5277 v: v3
1 parent 84b18cc commit 41892d5

File tree

209 files changed

+4052
-2582
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

209 files changed

+4052
-2582
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 18842f89f084c52588fe7cffe07f87bf6e90796a
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: c1f3acaa64a004577b79834996715595877efffc
4+
refs/heads/snap-stage3: 19f73b4ef6fb1d24f19738a8665889396fc1b0c8
55
refs/heads/try: f5d619caf9f32458680fae55526b99582ca682dd
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d

branches/snap-stage3/mk/rt.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ $$(JEMALLOC_LOCAL_$(1)): $$(JEMALLOC_DEPS) $$(MKFILE_DEPS)
180180
AR="$$(AR_$(1))" \
181181
RANLIB="$$(AR_$(1)) s" \
182182
CPPFLAGS="-I $(S)src/rt/" \
183-
EXTRA_CFLAGS="-g1"
183+
EXTRA_CFLAGS="-g1 -ffunction-sections -fdata-sections"
184184
$$(Q)$$(MAKE) -C "$$(JEMALLOC_BUILD_DIR_$(1))" build_lib_static
185185

186186
ifeq ($$(CFG_DISABLE_JEMALLOC),)

branches/snap-stage3/src/compiletest/errors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ fn parse_expected(last_nonfollow_error: Option<uint>,
6767
re: &Regex) -> Option<(WhichLine, ExpectedError)> {
6868
re.captures(line).and_then(|caps| {
6969
let adjusts = caps.name("adjusts").unwrap_or("").len();
70-
let kind = caps.name("kind").unwrap_or("").to_ascii_lower();
70+
let kind = caps.name("kind").unwrap_or("").to_ascii_lowercase();
7171
let msg = caps.name("msg").unwrap_or("").trim().to_string();
7272
let follow = caps.name("follow").unwrap_or("").len() > 0;
7373

branches/snap-stage3/src/compiletest/runtest.rs

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ use util::logv;
2121
#[cfg(target_os = "windows")]
2222
use util;
2323

24+
#[cfg(target_os = "windows")]
25+
use std::ascii::AsciiExt;
2426
use std::io::File;
2527
use std::io::fs::PathExtensions;
2628
use std::io::fs;
@@ -985,22 +987,9 @@ fn check_expected_errors(expected_errors: Vec<errors::ExpectedError> ,
985987
format!("{}:{}:", testfile.display(), ee.line)
986988
}).collect::<Vec<String> >();
987989

988-
#[cfg(target_os = "windows")]
989-
fn to_lower( s : &str ) -> String {
990-
let i = s.chars();
991-
let c : Vec<char> = i.map( |c| {
992-
if c.is_ascii() {
993-
c.to_ascii().to_lowercase().as_char()
994-
} else {
995-
c
996-
}
997-
} ).collect();
998-
String::from_chars(c.as_slice())
999-
}
1000-
1001990
#[cfg(windows)]
1002991
fn prefix_matches( line : &str, prefix : &str ) -> bool {
1003-
to_lower(line).as_slice().starts_with(to_lower(prefix).as_slice())
992+
line.to_ascii_lowercase().starts_with(prefix.to_ascii_lowercase().as_slice())
1004993
}
1005994

1006995
#[cfg(unix)]

branches/snap-stage3/src/etc/rustup.sh

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,18 @@ validate_opt() {
229229
done
230230
}
231231

232+
create_tmp_dir() {
233+
local TMP_DIR=./rustup-tmp-install
234+
235+
rm -Rf "${TMP_DIR}"
236+
need_ok "failed to remove temporary installation directory"
237+
238+
mkdir -p "${TMP_DIR}"
239+
need_ok "failed to create create temporary installation directory"
240+
241+
echo $TMP_DIR
242+
}
243+
232244
probe_need CFG_CURL curl
233245
probe_need CFG_TAR tar
234246
probe_need CFG_FILE file
@@ -401,7 +413,9 @@ then
401413
CFG_INSTALL_FLAGS="${CFG_INSTALL_FLAGS} --prefix=${CFG_PREFIX}"
402414
fi
403415

404-
CFG_TMP_DIR="./rustup-tmp-install"
416+
CFG_TMP_DIR=$(mktemp -d 2>/dev/null \
417+
|| mktemp -d -t 'rustup-tmp-install' 2>/dev/null \
418+
|| create_tmp_dir)
405419

406420
RUST_URL="https://static.rust-lang.org/dist"
407421
RUST_PACKAGE_NAME=rust-nightly
@@ -424,9 +438,6 @@ download_package() {
424438

425439
msg "Downloading ${remote_tarball} to ${local_tarball}"
426440

427-
mkdir -p "${CFG_TMP_DIR}"
428-
need_ok "failed to create create download directory"
429-
430441
"${CFG_CURL}" -f -o "${local_tarball}" "${remote_tarball}"
431442
if [ $? -ne 0 ]
432443
then

branches/snap-stage3/src/liballoc/arc.rs

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,11 @@ use core::default::Default;
7676
use core::kinds::{Sync, Send};
7777
use core::mem::{min_align_of, size_of, drop};
7878
use core::mem;
79+
use core::nonzero::NonZero;
7980
use core::ops::{Drop, Deref};
8081
use core::option::Option;
8182
use core::option::Option::{Some, None};
82-
use core::ptr::RawPtr;
83-
use core::ptr;
83+
use core::ptr::{mod, RawPtr};
8484
use heap::deallocate;
8585

8686
/// An atomically reference counted wrapper for shared state.
@@ -114,9 +114,13 @@ use heap::deallocate;
114114
pub struct Arc<T> {
115115
// FIXME #12808: strange name to try to avoid interfering with
116116
// field accesses of the contained type via Deref
117-
_ptr: *mut ArcInner<T>,
117+
_ptr: NonZero<*mut ArcInner<T>>,
118118
}
119119

120+
unsafe impl<T: Sync + Send> Send for Arc<T> { }
121+
unsafe impl<T: Sync + Send> Sync for Arc<T> { }
122+
123+
120124
/// A weak pointer to an `Arc`.
121125
///
122126
/// Weak pointers will not keep the data inside of the `Arc` alive, and can be used to break cycles
@@ -126,16 +130,22 @@ pub struct Arc<T> {
126130
pub struct Weak<T> {
127131
// FIXME #12808: strange name to try to avoid interfering with
128132
// field accesses of the contained type via Deref
129-
_ptr: *mut ArcInner<T>,
133+
_ptr: NonZero<*mut ArcInner<T>>,
130134
}
131135

136+
unsafe impl<T: Sync + Send> Send for Weak<T> { }
137+
unsafe impl<T: Sync + Send> Sync for Weak<T> { }
138+
132139
struct ArcInner<T> {
133140
strong: atomic::AtomicUint,
134141
weak: atomic::AtomicUint,
135142
data: T,
136143
}
137144

138-
impl<T: Sync + Send> Arc<T> {
145+
unsafe impl<T: Sync + Send> Send for ArcInner<T> {}
146+
unsafe impl<T: Sync + Send> Sync for ArcInner<T> {}
147+
148+
impl<T> Arc<T> {
139149
/// Constructs a new `Arc<T>`.
140150
///
141151
/// # Examples
@@ -155,7 +165,7 @@ impl<T: Sync + Send> Arc<T> {
155165
weak: atomic::AtomicUint::new(1),
156166
data: data,
157167
};
158-
Arc { _ptr: unsafe { mem::transmute(x) } }
168+
Arc { _ptr: unsafe { NonZero::new(mem::transmute(x)) } }
159169
}
160170

161171
/// Downgrades the `Arc<T>` to a `Weak<T>` reference.
@@ -184,7 +194,7 @@ impl<T> Arc<T> {
184194
// pointer is valid. Furthermore, we know that the `ArcInner` structure itself is `Sync`
185195
// because the inner data is `Sync` as well, so we're ok loaning out an immutable pointer
186196
// to these contents.
187-
unsafe { &*self._ptr }
197+
unsafe { &**self._ptr }
188198
}
189199
}
190200

@@ -271,7 +281,7 @@ impl<T: Send + Sync + Clone> Arc<T> {
271281
// pointer that will ever be returned to T. Our reference count is guaranteed to be 1 at
272282
// this point, and we required the Arc itself to be `mut`, so we're returning the only
273283
// possible reference to the inner data.
274-
let inner = unsafe { &mut *self._ptr };
284+
let inner = unsafe { &mut **self._ptr };
275285
&mut inner.data
276286
}
277287
}
@@ -306,7 +316,8 @@ impl<T: Sync + Send> Drop for Arc<T> {
306316
fn drop(&mut self) {
307317
// This structure has #[unsafe_no_drop_flag], so this drop glue may run more than once (but
308318
// it is guaranteed to be zeroed after the first if it's run more than once)
309-
if self._ptr.is_null() { return }
319+
let ptr = *self._ptr;
320+
if ptr.is_null() { return }
310321

311322
// Because `fetch_sub` is already atomic, we do not need to synchronize with other threads
312323
// unless we are going to delete the object. This same logic applies to the below
@@ -336,7 +347,7 @@ impl<T: Sync + Send> Drop for Arc<T> {
336347

337348
if self.inner().weak.fetch_sub(1, atomic::Release) == 1 {
338349
atomic::fence(atomic::Acquire);
339-
unsafe { deallocate(self._ptr as *mut u8, size_of::<ArcInner<T>>(),
350+
unsafe { deallocate(ptr as *mut u8, size_of::<ArcInner<T>>(),
340351
min_align_of::<ArcInner<T>>()) }
341352
}
342353
}
@@ -376,7 +387,7 @@ impl<T: Sync + Send> Weak<T> {
376387
#[inline]
377388
fn inner(&self) -> &ArcInner<T> {
378389
// See comments above for why this is "safe"
379-
unsafe { &*self._ptr }
390+
unsafe { &**self._ptr }
380391
}
381392
}
382393

@@ -432,14 +443,16 @@ impl<T: Sync + Send> Drop for Weak<T> {
432443
/// } // implicit drop
433444
/// ```
434445
fn drop(&mut self) {
446+
let ptr = *self._ptr;
447+
435448
// see comments above for why this check is here
436-
if self._ptr.is_null() { return }
449+
if ptr.is_null() { return }
437450

438451
// If we find out that we were the last weak pointer, then its time to deallocate the data
439452
// entirely. See the discussion in Arc::drop() about the memory orderings
440453
if self.inner().weak.fetch_sub(1, atomic::Release) == 1 {
441454
atomic::fence(atomic::Acquire);
442-
unsafe { deallocate(self._ptr as *mut u8, size_of::<ArcInner<T>>(),
455+
unsafe { deallocate(ptr as *mut u8, size_of::<ArcInner<T>>(),
443456
min_align_of::<ArcInner<T>>()) }
444457
}
445458
}
@@ -587,6 +600,7 @@ mod tests {
587600
use std::str::Str;
588601
use std::sync::atomic;
589602
use std::task;
603+
use std::kinds::Send;
590604
use std::vec::Vec;
591605
use super::{Arc, Weak, weak_count, strong_count};
592606
use std::sync::Mutex;

branches/snap-stage3/src/liballoc/boxed.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ use core::hash::{mod, Hash};
1919
use core::kinds::Sized;
2020
use core::mem;
2121
use core::option::Option;
22+
use core::ptr::Unique;
2223
use core::raw::TraitObject;
2324
use core::result::Result;
2425
use core::result::Result::{Ok, Err};
@@ -44,7 +45,7 @@ pub static HEAP: () = ();
4445
/// A type that represents a uniquely-owned value.
4546
#[lang = "owned_box"]
4647
#[unstable = "custom allocators will add an additional type parameter (with default)"]
47-
pub struct Box<T>(*mut T);
48+
pub struct Box<T>(Unique<T>);
4849

4950
#[stable]
5051
impl<T: Default> Default for Box<T> {

branches/snap-stage3/src/liballoc/rc.rs

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -150,11 +150,11 @@ use core::fmt;
150150
use core::hash::{mod, Hash};
151151
use core::kinds::marker;
152152
use core::mem::{transmute, min_align_of, size_of, forget};
153+
use core::nonzero::NonZero;
153154
use core::ops::{Deref, Drop};
154155
use core::option::Option;
155156
use core::option::Option::{Some, None};
156-
use core::ptr;
157-
use core::ptr::RawPtr;
157+
use core::ptr::{mod, RawPtr};
158158
use core::result::Result;
159159
use core::result::Result::{Ok, Err};
160160

@@ -174,7 +174,7 @@ struct RcBox<T> {
174174
pub struct Rc<T> {
175175
// FIXME #12808: strange names to try to avoid interfering with field accesses of the contained
176176
// type via Deref
177-
_ptr: *mut RcBox<T>,
177+
_ptr: NonZero<*mut RcBox<T>>,
178178
_nosend: marker::NoSend,
179179
_noshare: marker::NoSync
180180
}
@@ -196,11 +196,11 @@ impl<T> Rc<T> {
196196
// there is an implicit weak pointer owned by all the strong pointers, which
197197
// ensures that the weak destructor never frees the allocation while the strong
198198
// destructor is running, even if the weak pointer is stored inside the strong one.
199-
_ptr: transmute(box RcBox {
199+
_ptr: NonZero::new(transmute(box RcBox {
200200
value: value,
201201
strong: Cell::new(1),
202202
weak: Cell::new(1)
203-
}),
203+
})),
204204
_nosend: marker::NoSend,
205205
_noshare: marker::NoSync
206206
}
@@ -281,7 +281,7 @@ pub fn try_unwrap<T>(rc: Rc<T>) -> Result<T, Rc<T>> {
281281
let val = ptr::read(&*rc); // copy the contained object
282282
// destruct the box and skip our Drop
283283
// we can ignore the refcounts because we know we're unique
284-
deallocate(rc._ptr as *mut u8, size_of::<RcBox<T>>(),
284+
deallocate(*rc._ptr as *mut u8, size_of::<RcBox<T>>(),
285285
min_align_of::<RcBox<T>>());
286286
forget(rc);
287287
Ok(val)
@@ -311,7 +311,7 @@ pub fn try_unwrap<T>(rc: Rc<T>) -> Result<T, Rc<T>> {
311311
#[experimental]
312312
pub fn get_mut<'a, T>(rc: &'a mut Rc<T>) -> Option<&'a mut T> {
313313
if is_unique(rc) {
314-
let inner = unsafe { &mut *rc._ptr };
314+
let inner = unsafe { &mut **rc._ptr };
315315
Some(&mut inner.value)
316316
} else {
317317
None
@@ -343,7 +343,7 @@ impl<T: Clone> Rc<T> {
343343
// pointer that will ever be returned to T. Our reference count is guaranteed to be 1 at
344344
// this point, and we required the `Rc<T>` itself to be `mut`, so we're returning the only
345345
// possible reference to the inner value.
346-
let inner = unsafe { &mut *self._ptr };
346+
let inner = unsafe { &mut **self._ptr };
347347
&mut inner.value
348348
}
349349
}
@@ -391,7 +391,8 @@ impl<T> Drop for Rc<T> {
391391
/// ```
392392
fn drop(&mut self) {
393393
unsafe {
394-
if !self._ptr.is_null() {
394+
let ptr = *self._ptr;
395+
if !ptr.is_null() {
395396
self.dec_strong();
396397
if self.strong() == 0 {
397398
ptr::read(&**self); // destroy the contained object
@@ -401,7 +402,7 @@ impl<T> Drop for Rc<T> {
401402
self.dec_weak();
402403

403404
if self.weak() == 0 {
404-
deallocate(self._ptr as *mut u8, size_of::<RcBox<T>>(),
405+
deallocate(ptr as *mut u8, size_of::<RcBox<T>>(),
405406
min_align_of::<RcBox<T>>())
406407
}
407408
}
@@ -618,7 +619,7 @@ impl<T: fmt::Show> fmt::Show for Rc<T> {
618619
pub struct Weak<T> {
619620
// FIXME #12808: strange names to try to avoid interfering with
620621
// field accesses of the contained type via Deref
621-
_ptr: *mut RcBox<T>,
622+
_ptr: NonZero<*mut RcBox<T>>,
622623
_nosend: marker::NoSend,
623624
_noshare: marker::NoSync
624625
}
@@ -682,12 +683,13 @@ impl<T> Drop for Weak<T> {
682683
/// ```
683684
fn drop(&mut self) {
684685
unsafe {
685-
if !self._ptr.is_null() {
686+
let ptr = *self._ptr;
687+
if !ptr.is_null() {
686688
self.dec_weak();
687689
// the weak count starts at 1, and will only go to zero if all the strong pointers
688690
// have disappeared.
689691
if self.weak() == 0 {
690-
deallocate(self._ptr as *mut u8, size_of::<RcBox<T>>(),
692+
deallocate(ptr as *mut u8, size_of::<RcBox<T>>(),
691693
min_align_of::<RcBox<T>>())
692694
}
693695
}
@@ -742,12 +744,12 @@ trait RcBoxPtr<T> {
742744

743745
impl<T> RcBoxPtr<T> for Rc<T> {
744746
#[inline(always)]
745-
fn inner(&self) -> &RcBox<T> { unsafe { &(*self._ptr) } }
747+
fn inner(&self) -> &RcBox<T> { unsafe { &(**self._ptr) } }
746748
}
747749

748750
impl<T> RcBoxPtr<T> for Weak<T> {
749751
#[inline(always)]
750-
fn inner(&self) -> &RcBox<T> { unsafe { &(*self._ptr) } }
752+
fn inner(&self) -> &RcBox<T> { unsafe { &(**self._ptr) } }
751753
}
752754

753755
#[cfg(test)]

0 commit comments

Comments
 (0)