Skip to content

Commit 5e0f38a

Browse files
committed
Auto merge of #22909 - Manishearth:rollup, r=Manishearth
r? @Manishearth
2 parents 8902936 + 679e9b2 commit 5e0f38a

28 files changed

+764
-134
lines changed

configure

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -875,7 +875,7 @@ then
875875
| cut -d ' ' -f 2)
876876

877877
case $CFG_CLANG_VERSION in
878-
(3.0svn | 3.0 | 3.1* | 3.2* | 3.3* | 3.4* | 3.5* | 3.6*)
878+
(3.2* | 3.3* | 3.4* | 3.5* | 3.6*)
879879
step_msg "found ok version of CLANG: $CFG_CLANG_VERSION"
880880
if [ -z "$CC" ]
881881
then

src/liballoc/arc.rs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -201,10 +201,11 @@ impl<T> Arc<T> {
201201
impl<T> Arc<T> {
202202
#[inline]
203203
fn inner(&self) -> &ArcInner<T> {
204-
// This unsafety is ok because while this arc is alive we're guaranteed that the inner
205-
// pointer is valid. Furthermore, we know that the `ArcInner` structure itself is `Sync`
206-
// because the inner data is `Sync` as well, so we're ok loaning out an immutable pointer
207-
// to these contents.
204+
// This unsafety is ok because while this arc is alive we're guaranteed
205+
// that the inner pointer is valid. Furthermore, we know that the
206+
// `ArcInner` structure itself is `Sync` because the inner data is
207+
// `Sync` as well, so we're ok loaning out an immutable pointer to these
208+
// contents.
208209
unsafe { &**self._ptr }
209210
}
210211
}
@@ -236,13 +237,15 @@ impl<T> Clone for Arc<T> {
236237
/// ```
237238
#[inline]
238239
fn clone(&self) -> Arc<T> {
239-
// Using a relaxed ordering is alright here, as knowledge of the original reference
240-
// prevents other threads from erroneously deleting the object.
240+
// Using a relaxed ordering is alright here, as knowledge of the
241+
// original reference prevents other threads from erroneously deleting
242+
// the object.
241243
//
242-
// As explained in the [Boost documentation][1], Increasing the reference counter can
243-
// always be done with memory_order_relaxed: New references to an object can only be formed
244-
// from an existing reference, and passing an existing reference from one thread to another
245-
// must already provide any required synchronization.
244+
// As explained in the [Boost documentation][1], Increasing the
245+
// reference counter can always be done with memory_order_relaxed: New
246+
// references to an object can only be formed from an existing
247+
// reference, and passing an existing reference from one thread to
248+
// another must already provide any required synchronization.
246249
//
247250
// [1]: (www.boost.org/doc/libs/1_55_0/doc/html/atomic/usage_examples.html)
248251
self.inner().strong.fetch_add(1, Relaxed);

src/libcore/fmt/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -700,7 +700,7 @@ impl Display for char {
700700
impl<T> Pointer for *const T {
701701
fn fmt(&self, f: &mut Formatter) -> Result {
702702
f.flags |= 1 << (FlagV1::Alternate as u32);
703-
let ret = LowerHex::fmt(&(*self as u32), f);
703+
let ret = LowerHex::fmt(&(*self as usize), f);
704704
f.flags &= !(1 << (FlagV1::Alternate as u32));
705705
ret
706706
}

src/libcore/iter.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ use num::{ToPrimitive, Int};
6868
use ops::{Add, Deref, FnMut};
6969
use option::Option;
7070
use option::Option::{Some, None};
71-
use marker::{Send, Sized, Sync};
71+
use marker::Sized;
7272
use usize;
7373

7474
/// An interface for dealing with "external iterators". These types of iterators
@@ -1783,10 +1783,6 @@ pub struct Peekable<I: Iterator> {
17831783
peeked: Option<I::Item>,
17841784
}
17851785

1786-
// FIXME: after #22828 being fixed, the following unsafe impl should be removed
1787-
unsafe impl<I: Iterator> Sync for Peekable<I> where I: Sync, I::Item: Sync {}
1788-
unsafe impl<I: Iterator> Send for Peekable<I> where I: Send, I::Item: Send {}
1789-
17901786
impl<I: Iterator + Clone> Clone for Peekable<I> where I::Item: Clone {
17911787
fn clone(&self) -> Peekable<I> {
17921788
Peekable {

src/librustc_trans/trans/base.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -433,13 +433,13 @@ pub fn set_inline_hint(f: ValueRef) {
433433
}
434434

435435
pub fn set_llvm_fn_attrs(ccx: &CrateContext, attrs: &[ast::Attribute], llfn: ValueRef) {
436-
use syntax::attr::*;
436+
use syntax::attr::{find_inline_attr, InlineAttr};
437437
// Set the inline hint if there is one
438438
match find_inline_attr(Some(ccx.sess().diagnostic()), attrs) {
439-
InlineHint => set_inline_hint(llfn),
440-
InlineAlways => set_always_inline(llfn),
441-
InlineNever => set_no_inline(llfn),
442-
InlineNone => { /* fallthrough */ }
439+
InlineAttr::Hint => set_inline_hint(llfn),
440+
InlineAttr::Always => set_always_inline(llfn),
441+
InlineAttr::Never => set_no_inline(llfn),
442+
InlineAttr::None => { /* fallthrough */ }
443443
}
444444

445445
for attr in attrs {
@@ -2332,6 +2332,11 @@ pub fn trans_item(ccx: &CrateContext, item: &ast::Item) {
23322332
// Do static_assert checking. It can't really be done much earlier
23332333
// because we need to get the value of the bool out of LLVM
23342334
if attr::contains_name(&item.attrs, "static_assert") {
2335+
if !ty::type_is_bool(ty::expr_ty(ccx.tcx(), expr)) {
2336+
ccx.sess().span_fatal(expr.span,
2337+
"can only have static_assert on a static \
2338+
with type `bool`");
2339+
}
23352340
if m == ast::MutMutable {
23362341
ccx.sess().span_fatal(expr.span,
23372342
"cannot have static_assert on a mutable \

src/libstd/io/lazy.rs

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
// Copyright 2015 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.
4+
//
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.
10+
11+
use prelude::v1::*;
12+
13+
use boxed;
14+
use cell::UnsafeCell;
15+
use rt;
16+
use sync::{StaticMutex, Arc};
17+
18+
pub struct Lazy<T> {
19+
pub lock: StaticMutex,
20+
pub ptr: UnsafeCell<*mut Arc<T>>,
21+
pub init: fn() -> Arc<T>,
22+
}
23+
24+
unsafe impl<T> Sync for Lazy<T> {}
25+
26+
macro_rules! lazy_init {
27+
($init:expr) => (::io::lazy::Lazy {
28+
lock: ::sync::MUTEX_INIT,
29+
ptr: ::cell::UnsafeCell { value: 0 as *mut _ },
30+
init: $init,
31+
})
32+
}
33+
34+
impl<T: Send + Sync + 'static> Lazy<T> {
35+
pub fn get(&'static self) -> Option<Arc<T>> {
36+
let _g = self.lock.lock();
37+
unsafe {
38+
let mut ptr = *self.ptr.get();
39+
if ptr.is_null() {
40+
ptr = boxed::into_raw(self.init());
41+
*self.ptr.get() = ptr;
42+
} else if ptr as usize == 1 {
43+
return None
44+
}
45+
Some((*ptr).clone())
46+
}
47+
}
48+
49+
fn init(&'static self) -> Box<Arc<T>> {
50+
rt::at_exit(move || unsafe {
51+
let g = self.lock.lock();
52+
let ptr = *self.ptr.get();
53+
*self.ptr.get() = 1 as *mut _;
54+
drop(g);
55+
drop(Box::from_raw(ptr))
56+
});
57+
Box::new((self.init)())
58+
}
59+
}

src/libstd/io/mod.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,18 @@ pub use self::buffered::IntoInnerError;
3939
pub use self::cursor::Cursor;
4040
pub use self::error::{Result, Error, ErrorKind};
4141
pub use self::util::{copy, sink, Sink, empty, Empty, repeat, Repeat};
42+
pub use self::stdio::{stdin, stdout, stderr, Stdin, Stdout, Stderr};
43+
pub use self::stdio::{StdoutLock, StderrLock, StdinLock};
44+
45+
#[macro_use] mod lazy;
4246

4347
pub mod prelude;
4448
mod buffered;
4549
mod cursor;
4650
mod error;
4751
mod impls;
4852
mod util;
53+
mod stdio;
4954

5055
const DEFAULT_BUF_SIZE: usize = 64 * 1024;
5156

0 commit comments

Comments
 (0)