Skip to content

Commit

Permalink
Auto merge of #35666 - eddyb:rollup, r=eddyb
Browse files Browse the repository at this point in the history
  • Loading branch information
bors authored Aug 14, 2016
2 parents 1d5b758 + bcee2ed commit 13ff307
Show file tree
Hide file tree
Showing 127 changed files with 532 additions and 217 deletions.
2 changes: 1 addition & 1 deletion configure
Original file line number Diff line number Diff line change
Expand Up @@ -1013,7 +1013,7 @@ then
LLVM_VERSION=$($LLVM_CONFIG --version)

case $LLVM_VERSION in
(3.[7-8]*)
(3.[7-9]*)
msg "found ok version of LLVM: $LLVM_VERSION"
;;
(*)
Expand Down
4 changes: 2 additions & 2 deletions mk/cfg/i586-unknown-linux-gnu.mk
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ CFG_LIB_NAME_i586-unknown-linux-gnu=lib$(1).so
CFG_STATIC_LIB_NAME_i586-unknown-linux-gnu=lib$(1).a
CFG_LIB_GLOB_i586-unknown-linux-gnu=lib$(1)-*.so
CFG_LIB_DSYM_GLOB_i586-unknown-linux-gnu=lib$(1)-*.dylib.dSYM
CFG_JEMALLOC_CFLAGS_i586-unknown-linux-gnu := -m32 $(CFLAGS) -march=pentium
CFG_GCCISH_CFLAGS_i586-unknown-linux-gnu := -g -fPIC -m32 $(CFLAGS) -march=pentium
CFG_JEMALLOC_CFLAGS_i586-unknown-linux-gnu := -m32 $(CFLAGS) -march=pentium -Wa,-mrelax-relocations=no
CFG_GCCISH_CFLAGS_i586-unknown-linux-gnu := -g -fPIC -m32 $(CFLAGS) -march=pentium -Wa,-mrelax-relocations=no
CFG_GCCISH_CXXFLAGS_i586-unknown-linux-gnu := -fno-rtti $(CXXFLAGS) -march=pentium
CFG_GCCISH_LINK_FLAGS_i586-unknown-linux-gnu := -shared -fPIC -ldl -pthread -lrt -g -m32
CFG_GCCISH_DEF_FLAG_i586-unknown-linux-gnu := -Wl,--export-dynamic,--dynamic-list=
Expand Down
4 changes: 2 additions & 2 deletions mk/cfg/i686-unknown-linux-musl.mk
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ CFG_INSTALL_ONLY_RLIB_i686-unknown-linux-musl = 1
CFG_LIB_NAME_i686-unknown-linux-musl=lib$(1).so
CFG_STATIC_LIB_NAME_i686-unknown-linux-musl=lib$(1).a
CFG_LIB_GLOB_i686-unknown-linux-musl=lib$(1)-*.so
CFG_JEMALLOC_CFLAGS_i686-unknown-linux-musl := -m32 -Wl,-melf_i386
CFG_GCCISH_CFLAGS_i686-unknown-linux-musl := -g -fPIC -m32 -Wl,-melf_i386
CFG_JEMALLOC_CFLAGS_i686-unknown-linux-musl := -m32 -Wl,-melf_i386 -Wa,-mrelax-relocations=no
CFG_GCCISH_CFLAGS_i686-unknown-linux-musl := -g -fPIC -m32 -Wl,-melf_i386 -Wa,-mrelax-relocations=no
CFG_GCCISH_CXXFLAGS_i686-unknown-linux-musl :=
CFG_GCCISH_LINK_FLAGS_i686-unknown-linux-musl :=
CFG_GCCISH_DEF_FLAG_i686-unknown-linux-musl :=
Expand Down
9 changes: 7 additions & 2 deletions src/bootstrap/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -870,8 +870,13 @@ impl Build {
// This is a hack, because newer binutils broke things on some vms/distros
// (i.e., linking against unknown relocs disabled by the following flag)
// See: https://github.com/rust-lang/rust/issues/34978
if target == "x86_64-unknown-linux-musl" {
base.push("-Wa,-mrelax-relocations=no".into());
match target {
"i586-unknown-linux-gnu" |
"i686-unknown-linux-musl" |
"x86_64-unknown-linux-musl" => {
base.push("-Wa,-mrelax-relocations=no".into());
},
_ => {},
}
return base
}
Expand Down
3 changes: 2 additions & 1 deletion src/bootstrap/sanity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ pub fn check(build: &mut Build) {
if target.contains("rumprun") ||
target.contains("bitrig") ||
target.contains("openbsd") ||
target.contains("msvc") {
target.contains("msvc") ||
target.contains("emscripten") {
build.config.use_jemalloc = false;
}

Expand Down
6 changes: 3 additions & 3 deletions src/doc/book/error-handling.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ story. The other half is *using* the `find` function we've written. Let's try
to use it to find the extension in a file name.

```rust
# fn find(_: &str, _: char) -> Option<usize> { None }
# fn find(haystack: &str, needle: char) -> Option<usize> { haystack.find(needle) }
fn main() {
let file_name = "foobar.rs";
match find(file_name, '.') {
Expand Down Expand Up @@ -223,7 +223,7 @@ Getting the extension of a file name is a pretty common operation, so it makes
sense to put it into a function:

```rust
# fn find(_: &str, _: char) -> Option<usize> { None }
# fn find(haystack: &str, needle: char) -> Option<usize> { haystack.find(needle) }
// Returns the extension of the given file name, where the extension is defined
// as all characters following the first `.`.
// If `file_name` has no `.`, then `None` is returned.
Expand Down Expand Up @@ -272,7 +272,7 @@ Armed with our new combinator, we can rewrite our `extension_explicit` method
to get rid of the case analysis:

```rust
# fn find(_: &str, _: char) -> Option<usize> { None }
# fn find(haystack: &str, needle: char) -> Option<usize> { haystack.find(needle) }
// Returns the extension of the given file name, where the extension is defined
// as all characters following the first `.`.
// If `file_name` has no `.`, then `None` is returned.
Expand Down
2 changes: 1 addition & 1 deletion src/doc/book/variable-bindings.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ warning, but it will still print "Hello, world!":

```text
Compiling hello_world v0.0.1 (file:///home/you/projects/hello_world)
src/main.rs:2:9: 2:10 warning: unused variable: `x`, #[warn(unused_variable)]
src/main.rs:2:9: 2:10 warning: unused variable: `x`, #[warn(unused_variables)]
on by default
src/main.rs:2 let x: i32;
^
Expand Down
6 changes: 3 additions & 3 deletions src/liballoc/raw_vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use super::boxed::Box;
use core::ops::Drop;
use core::cmp;

/// A low-level utility for more ergonomically allocating, reallocating, and deallocating a
/// A low-level utility for more ergonomically allocating, reallocating, and deallocating
/// a buffer of memory on the heap without having to worry about all the corner cases
/// involved. This type is excellent for building your own data structures like Vec and VecDeque.
/// In particular:
Expand Down Expand Up @@ -534,8 +534,8 @@ impl<T> RawVec<T> {
/// Converts the entire buffer into `Box<[T]>`.
///
/// While it is not *strictly* Undefined Behavior to call
/// this procedure while some of the RawVec is unintialized,
/// it cetainly makes it trivial to trigger it.
/// this procedure while some of the RawVec is uninitialized,
/// it certainly makes it trivial to trigger it.
///
/// Note that this will correctly reconstitute any `cap` changes
/// that may have been performed. (see description of type for details)
Expand Down
5 changes: 2 additions & 3 deletions src/libcollections/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1152,7 +1152,7 @@ impl String {
self.vec.set_len(len + amt);
}

/// Inserts a string into this `String` at a byte position.
/// Inserts a string slice into this `String` at a byte position.
///
/// This is an `O(n)` operation as it requires copying every element in the
/// buffer.
Expand Down Expand Up @@ -1182,8 +1182,7 @@ impl String {
reason = "recent addition",
issue = "35553")]
pub fn insert_str(&mut self, idx: usize, string: &str) {
let len = self.len();
assert!(idx <= len);
assert!(idx <= self.len());
assert!(self.is_char_boundary(idx));

unsafe {
Expand Down
63 changes: 51 additions & 12 deletions src/libcollections/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1446,13 +1446,12 @@ impl<T> IntoIterator for Vec<T> {
#[inline]
fn into_iter(mut self) -> IntoIter<T> {
unsafe {
let ptr = self.as_mut_ptr();
assume(!ptr.is_null());
let begin = ptr as *const T;
let begin = self.as_mut_ptr();
assume(!begin.is_null());
let end = if mem::size_of::<T>() == 0 {
arith_offset(ptr as *const i8, self.len() as isize) as *const T
arith_offset(begin as *const i8, self.len() as isize) as *const T
} else {
ptr.offset(self.len() as isize) as *const T
begin.offset(self.len() as isize) as *const T
};
let buf = ptr::read(&self.buf);
mem::forget(self);
Expand Down Expand Up @@ -1710,10 +1709,52 @@ impl<'a, T> FromIterator<T> for Cow<'a, [T]> where T: Clone {
#[stable(feature = "rust1", since = "1.0.0")]
pub struct IntoIter<T> {
_buf: RawVec<T>,
ptr: *const T,
ptr: *mut T,
end: *const T,
}

impl<T> IntoIter<T> {
/// Returns the remaining items of this iterator as a slice.
///
/// # Examples
///
/// ```rust
/// # #![feature(vec_into_iter_as_slice)]
/// let vec = vec!['a', 'b', 'c'];
/// let mut into_iter = vec.into_iter();
/// assert_eq!(into_iter.as_slice(), &['a', 'b', 'c']);
/// let _ = into_iter.next().unwrap();
/// assert_eq!(into_iter.as_slice(), &['b', 'c']);
/// ```
#[unstable(feature = "vec_into_iter_as_slice", issue = "35601")]
pub fn as_slice(&self) -> &[T] {
unsafe {
slice::from_raw_parts(self.ptr, self.len())
}
}

/// Returns the remaining items of this iterator as a mutable slice.
///
/// # Examples
///
/// ```rust
/// # #![feature(vec_into_iter_as_slice)]
/// let vec = vec!['a', 'b', 'c'];
/// let mut into_iter = vec.into_iter();
/// assert_eq!(into_iter.as_slice(), &['a', 'b', 'c']);
/// into_iter.as_mut_slice()[2] = 'z';
/// assert_eq!(into_iter.next().unwrap(), 'a');
/// assert_eq!(into_iter.next().unwrap(), 'b');
/// assert_eq!(into_iter.next().unwrap(), 'z');
/// ```
#[unstable(feature = "vec_into_iter_as_slice", issue = "35601")]
pub fn as_mut_slice(&self) -> &mut [T] {
unsafe {
slice::from_raw_parts_mut(self.ptr, self.len())
}
}
}

#[stable(feature = "rust1", since = "1.0.0")]
unsafe impl<T: Send> Send for IntoIter<T> {}
#[stable(feature = "rust1", since = "1.0.0")]
Expand All @@ -1726,14 +1767,14 @@ impl<T> Iterator for IntoIter<T> {
#[inline]
fn next(&mut self) -> Option<T> {
unsafe {
if self.ptr == self.end {
if self.ptr as *const _ == self.end {
None
} else {
if mem::size_of::<T>() == 0 {
// purposefully don't use 'ptr.offset' because for
// vectors with 0-size elements this would return the
// same pointer.
self.ptr = arith_offset(self.ptr as *const i8, 1) as *const T;
self.ptr = arith_offset(self.ptr as *const i8, 1) as *mut T;

// Use a non-null pointer value
Some(ptr::read(EMPTY as *mut T))
Expand Down Expand Up @@ -1776,7 +1817,7 @@ impl<T> DoubleEndedIterator for IntoIter<T> {
} else {
if mem::size_of::<T>() == 0 {
// See above for why 'ptr.offset' isn't used
self.end = arith_offset(self.end as *const i8, -1) as *const T;
self.end = arith_offset(self.end as *const i8, -1) as *mut T;

// Use a non-null pointer value
Some(ptr::read(EMPTY as *mut T))
Expand All @@ -1796,9 +1837,7 @@ impl<T> ExactSizeIterator for IntoIter<T> {}
#[stable(feature = "vec_into_iter_clone", since = "1.8.0")]
impl<T: Clone> Clone for IntoIter<T> {
fn clone(&self) -> IntoIter<T> {
unsafe {
slice::from_raw_parts(self.ptr, self.len()).to_owned().into_iter()
}
self.as_slice().to_owned().into_iter()
}
}

Expand Down
1 change: 1 addition & 0 deletions src/libcollectionstest/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#![feature(unboxed_closures)]
#![feature(unicode)]
#![feature(vec_deque_contains)]
#![feature(vec_into_iter_as_slice)]

extern crate collections;
extern crate test;
Expand Down
23 changes: 23 additions & 0 deletions src/libcollectionstest/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,29 @@ fn test_split_off() {
assert_eq!(vec2, [5, 6]);
}

#[test]
fn test_into_iter_as_slice() {
let vec = vec!['a', 'b', 'c'];
let mut into_iter = vec.into_iter();
assert_eq!(into_iter.as_slice(), &['a', 'b', 'c']);
let _ = into_iter.next().unwrap();
assert_eq!(into_iter.as_slice(), &['b', 'c']);
let _ = into_iter.next().unwrap();
let _ = into_iter.next().unwrap();
assert_eq!(into_iter.as_slice(), &[]);
}

#[test]
fn test_into_iter_as_mut_slice() {
let vec = vec!['a', 'b', 'c'];
let mut into_iter = vec.into_iter();
assert_eq!(into_iter.as_slice(), &['a', 'b', 'c']);
into_iter.as_mut_slice()[0] = 'x';
into_iter.as_mut_slice()[1] = 'y';
assert_eq!(into_iter.next().unwrap(), 'x');
assert_eq!(into_iter.as_slice(), &['y', 'c']);
}

#[test]
fn test_into_iter_count() {
assert_eq!(vec![1, 2, 3].into_iter().count(), 3);
Expand Down
22 changes: 22 additions & 0 deletions src/libcore/cell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@

use clone::Clone;
use cmp::{PartialEq, Eq, PartialOrd, Ord, Ordering};
use convert::From;
use default::Default;
use fmt::{self, Debug, Display};
use marker::{Copy, PhantomData, Send, Sync, Sized, Unsize};
Expand Down Expand Up @@ -329,6 +330,13 @@ impl<T:Ord + Copy> Ord for Cell<T> {
}
}

#[stable(feature = "cell_from", since = "1.12.0")]
impl<T: Copy> From<T> for Cell<T> {
fn from(t: T) -> Cell<T> {
Cell::new(t)
}
}

/// A mutable memory location with dynamically checked borrow rules
///
/// See the [module-level documentation](index.html) for more.
Expand Down Expand Up @@ -742,6 +750,13 @@ impl<T: ?Sized + Ord> Ord for RefCell<T> {
}
}

#[stable(feature = "cell_from", since = "1.12.0")]
impl<T> From<T> for RefCell<T> {
fn from(t: T) -> RefCell<T> {
RefCell::new(t)
}
}

struct BorrowRef<'b> {
borrow: &'b Cell<BorrowFlag>,
}
Expand Down Expand Up @@ -1064,3 +1079,10 @@ impl<T: Default> Default for UnsafeCell<T> {
UnsafeCell::new(Default::default())
}
}

#[stable(feature = "cell_from", since = "1.12.0")]
impl<T> From<T> for UnsafeCell<T> {
fn from(t: T) -> UnsafeCell<T> {
UnsafeCell::new(t)
}
}
8 changes: 4 additions & 4 deletions src/libcore/convert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ use result::Result;
///
/// # Generic Impls
///
/// - `AsRef` auto-dereference if the inner type is a reference or a mutable
/// reference (eg: `foo.as_ref()` will work the same if `foo` has type `&mut Foo` or `&&mut Foo`)
/// - `AsRef` auto-dereferences if the inner type is a reference or a mutable
/// reference (e.g.: `foo.as_ref()` will work the same if `foo` has type `&mut Foo` or `&&mut Foo`)
///
#[stable(feature = "rust1", since = "1.0.0")]
pub trait AsRef<T: ?Sized> {
Expand All @@ -88,8 +88,8 @@ pub trait AsRef<T: ?Sized> {
///
/// # Generic Impls
///
/// - `AsMut` auto-dereference if the inner type is a reference or a mutable
/// reference (eg: `foo.as_ref()` will work the same if `foo` has type `&mut Foo` or `&&mut Foo`)
/// - `AsMut` auto-dereferences if the inner type is a reference or a mutable
/// reference (e.g.: `foo.as_ref()` will work the same if `foo` has type `&mut Foo` or `&&mut Foo`)
///
#[stable(feature = "rust1", since = "1.0.0")]
pub trait AsMut<T: ?Sized> {
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/sync/atomic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
//! atomically-reference-counted shared pointer).
//!
//! Most atomic types may be stored in static variables, initialized using
//! the provided static initializers like `INIT_ATOMIC_BOOL`. Atomic statics
//! the provided static initializers like `ATOMIC_BOOL_INIT`. Atomic statics
//! are often used for lazy global initialization.
//!
//!
Expand Down
9 changes: 7 additions & 2 deletions src/librustc/middle/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,13 @@ fn find_item(item: &Item, ctxt: &mut EntryContext, at_root: bool) {
if ctxt.start_fn.is_none() {
ctxt.start_fn = Some((item.id, item.span));
} else {
span_err!(ctxt.session, item.span, E0138,
"multiple 'start' functions");
struct_span_err!(
ctxt.session, item.span, E0138,
"multiple 'start' functions")
.span_label(ctxt.start_fn.unwrap().1,
&format!("previous `start` function here"))
.span_label(item.span, &format!("multiple `start` functions"))
.emit();
}
},
EntryPointType::None => ()
Expand Down
19 changes: 18 additions & 1 deletion src/librustc/ty/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,24 @@ impl<'a, 'gcx, 'lcx, 'tcx> ty::TyS<'tcx> {
ty::TyArray(_, n) => format!("array of {} elements", n),
ty::TySlice(_) => "slice".to_string(),
ty::TyRawPtr(_) => "*-ptr".to_string(),
ty::TyRef(_, _) => "&-ptr".to_string(),
ty::TyRef(region, tymut) => {
let tymut_string = tymut.to_string();
if tymut_string == "_" || //unknown type name,
tymut_string.len() > 10 || //name longer than saying "reference",
region.to_string() != "" //... or a complex type
{
match tymut {
ty::TypeAndMut{mutbl, ..} => {
format!("{}reference", match mutbl {
hir::Mutability::MutMutable => "mutable ",
_ => ""
})
}
}
} else {
format!("&{}", tymut_string)
}
}
ty::TyFnDef(..) => format!("fn item"),
ty::TyFnPtr(_) => "fn pointer".to_string(),
ty::TyTrait(ref inner) => {
Expand Down
Loading

0 comments on commit 13ff307

Please sign in to comment.