Skip to content

Commit

Permalink
Auto merge of #23697 - Manishearth:rollup, r=Manishearth
Browse files Browse the repository at this point in the history
- Successful merges: #23617, #23664, #23680, #23684, #23692, #23693
- Failed merges:
  • Loading branch information
bors committed Mar 25, 2015
2 parents 928e2e2 + e962a1d commit a923278
Show file tree
Hide file tree
Showing 11 changed files with 119 additions and 71 deletions.
2 changes: 2 additions & 0 deletions src/libcollections/binary_heap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,8 @@ impl<T: Ord> BinaryHeap<T> {
pub fn is_empty(&self) -> bool { self.len() == 0 }

/// Clears the binary heap, returning an iterator over the removed elements.
///
/// The elements are removed in arbitrary order.
#[inline]
#[unstable(feature = "collections",
reason = "matches collection reform specification, waiting for dust to settle")]
Expand Down
74 changes: 33 additions & 41 deletions src/libcollections/slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,23 @@
//! The `slice` module contains useful code to help work with slice values.
//! Slices are a view into a block of memory represented as a pointer and a length.
//!
//! ```rust
//! # #![feature(core)]
//! ```
//! // slicing a Vec
//! let vec = vec!(1, 2, 3);
//! let int_slice = vec.as_slice();
//! let vec = vec![1, 2, 3];
//! let int_slice = &vec[..];
//! // coercing an array to a slice
//! let str_slice: &[&str] = &["one", "two", "three"];
//! ```
//!
//! Slices are either mutable or shared. The shared slice type is `&[T]`,
//! while the mutable slice type is `&mut[T]`. For example, you can mutate the
//! block of memory that a mutable slice points to:
//! while the mutable slice type is `&mut [T]`, where `T` represents the element
//! type. For example, you can mutate the block of memory that a mutable slice
//! points to:
//!
//! ```rust
//! let x: &mut[i32] = &mut [1, 2, 3];
//! ```
//! let x = &mut [1, 2, 3];
//! x[1] = 7;
//! assert_eq!(x[0], 1);
//! assert_eq!(x[1], 7);
//! assert_eq!(x[2], 3);
//! assert_eq!(x, &[1, 7, 3]);
//! ```
//!
//! Here are some of the things this module contains:
Expand All @@ -41,49 +39,43 @@
//! There are several structs that are useful for slices, such as `Iter`, which
//! represents iteration over a slice.
//!
//! ## Traits
//!
//! A number of traits add methods that allow you to accomplish tasks
//! with slices, the most important being `SliceExt`. Other traits
//! apply only to slices of elements satisfying certain bounds (like
//! `Ord`).
//!
//! An example is the `slice` method which enables slicing syntax `[a..b]` that
//! returns an immutable "view" into a `Vec` or another slice from the index
//! interval `[a, b)`:
//!
//! ```rust
//! fn main() {
//! let numbers = [0, 1, 2];
//! let last_numbers = &numbers[1..3];
//! // last_numbers is now &[1, 2]
//! }
//! ```
//!
//! ## Implementations of other traits
//! ## Trait Implementations
//!
//! There are several implementations of common traits for slices. Some examples
//! include:
//!
//! * `Clone`
//! * `Eq`, `Ord` - for immutable slices whose element type are `Eq` or `Ord`.
//! * `Eq`, `Ord` - for slices whose element type are `Eq` or `Ord`.
//! * `Hash` - for slices whose element type is `Hash`
//!
//! ## Iteration
//!
//! The method `iter()` returns an iteration value for a slice. The iterator
//! yields references to the slice's elements, so if the element
//! type of the slice is `isize`, the element type of the iterator is `&isize`.
//! The slices implement `IntoIterator`. The iterators of yield references
//! to the slice elements.
//!
//! ```rust
//! let numbers = [0, 1, 2];
//! for &x in numbers.iter() {
//! println!("{} is a number!", x);
//! ```
//! let numbers = &[0, 1, 2];
//! for n in numbers {
//! println!("{} is a number!", n);
//! }
//! ```
//!
//! * `.iter_mut()` returns an iterator that allows modifying each value.
//! * Further iterators exist that split, chunk or permute the slice.
//! The mutable slice yields mutable references to the elements:
//!
//! ```
//! let mut scores = [7, 8, 9];
//! for score in &mut scores[..] {
//! *score += 1;
//! }
//! ```
//!
//! This iterator yields mutable references to the slice's elements, so while the element
//! type of the slice is `i32`, the element type of the iterator is `&mut i32`.
//!
//! * `.iter()` and `.iter_mut()` are the explicit methods to return the default
//! iterators.
//! * Further methods that return iterators are `.split()`, `.splitn()`,
//! `.chunks()`, `.windows()` and more.

#![doc(primitive = "slice")]
#![stable(feature = "rust1", since = "1.0.0")]
Expand Down
2 changes: 1 addition & 1 deletion src/libcollections/str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
//! are owned elsewhere.
//!
//! Basic operations are implemented directly by the compiler, but more advanced
//! operations are defined on the [`StrExt`](trait.StrExt.html) trait.
//! operations are defined as methods on the `str` type.
//!
//! # Examples
//!
Expand Down
15 changes: 7 additions & 8 deletions src/libcore/str/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,7 @@ impl FromStr for bool {
/// assert!(<bool as FromStr>::from_str("not even a boolean").is_err());
/// ```
///
/// Note, in many cases, the StrExt::parse() which is based on
/// this FromStr::from_str() is more proper.
/// Note, in many cases, the `.parse()` method on `str` is more proper.
///
/// ```
/// assert_eq!("true".parse(), Ok(true));
Expand Down Expand Up @@ -531,7 +530,7 @@ impl<'a> DoubleEndedIterator for CharIndices<'a> {
/// External iterator for a string's bytes.
/// Use with the `std::iter` module.
///
/// Created with `StrExt::bytes`
/// Created with `str::bytes`
#[stable(feature = "rust1", since = "1.0.0")]
#[derive(Clone)]
pub struct Bytes<'a>(Map<slice::Iter<'a, u8>, BytesDeref>);
Expand Down Expand Up @@ -1489,27 +1488,27 @@ impl<'a, S: ?Sized> Str for &'a S where S: Str {
fn as_slice(&self) -> &str { Str::as_slice(*self) }
}

/// Return type of `StrExt::split`
/// Return type of `str::split`
#[stable(feature = "rust1", since = "1.0.0")]
pub struct Split<'a, P: Pattern<'a>>(CharSplits<'a, P>);
delegate_iter!{pattern &'a str : Split<'a, P>}

/// Return type of `StrExt::split_terminator`
/// Return type of `str::split_terminator`
#[stable(feature = "rust1", since = "1.0.0")]
pub struct SplitTerminator<'a, P: Pattern<'a>>(CharSplits<'a, P>);
delegate_iter!{pattern &'a str : SplitTerminator<'a, P>}

/// Return type of `StrExt::splitn`
/// Return type of `str::splitn`
#[stable(feature = "rust1", since = "1.0.0")]
pub struct SplitN<'a, P: Pattern<'a>>(CharSplitsN<'a, P>);
delegate_iter!{pattern forward &'a str : SplitN<'a, P>}

/// Return type of `StrExt::rsplit`
/// Return type of `str::rsplit`
#[stable(feature = "rust1", since = "1.0.0")]
pub struct RSplit<'a, P: Pattern<'a>>(RCharSplits<'a, P>);
delegate_iter!{pattern reverse &'a str : RSplit<'a, P>}

/// Return type of `StrExt::rsplitn`
/// Return type of `str::rsplitn`
#[stable(feature = "rust1", since = "1.0.0")]
pub struct RSplitN<'a, P: Pattern<'a>>(RCharSplitsN<'a, P>);
delegate_iter!{pattern reverse &'a str : RSplitN<'a, P>}
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_trans/trans/_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1352,12 +1352,12 @@ impl<'tcx> euv::Delegate<'tcx> for ReassignmentChecker {
fn mutate(&mut self, _: ast::NodeId, _: Span, cmt: mc::cmt, _: euv::MutateMode) {
match cmt.cat {
mc::cat_upvar(mc::Upvar { id: ty::UpvarId { var_id: vid, .. }, .. }) |
mc::cat_local(vid) => self.reassigned = self.node == vid,
mc::cat_local(vid) => self.reassigned |= self.node == vid,
mc::cat_interior(ref base_cmt, mc::InteriorField(field)) => {
match base_cmt.cat {
mc::cat_upvar(mc::Upvar { id: ty::UpvarId { var_id: vid, .. }, .. }) |
mc::cat_local(vid) => {
self.reassigned = self.node == vid && Some(field) == self.field
self.reassigned |= self.node == vid && Some(field) == self.field
},
_ => {}
}
Expand Down
6 changes: 6 additions & 0 deletions src/librustc_trans/trans/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1766,6 +1766,8 @@ fn trans_eager_binop<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
ast::BiAdd => {
if is_float {
FAdd(bcx, lhs, rhs, binop_debug_loc)
} else if is_simd {
Add(bcx, lhs, rhs, binop_debug_loc)
} else {
let (newbcx, res) = with_overflow_check(
bcx, OverflowOp::Add, info, lhs_t, lhs, rhs, binop_debug_loc);
Expand All @@ -1776,6 +1778,8 @@ fn trans_eager_binop<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
ast::BiSub => {
if is_float {
FSub(bcx, lhs, rhs, binop_debug_loc)
} else if is_simd {
Sub(bcx, lhs, rhs, binop_debug_loc)
} else {
let (newbcx, res) = with_overflow_check(
bcx, OverflowOp::Sub, info, lhs_t, lhs, rhs, binop_debug_loc);
Expand All @@ -1786,6 +1790,8 @@ fn trans_eager_binop<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
ast::BiMul => {
if is_float {
FMul(bcx, lhs, rhs, binop_debug_loc)
} else if is_simd {
Mul(bcx, lhs, rhs, binop_debug_loc)
} else {
let (newbcx, res) = with_overflow_check(
bcx, OverflowOp::Mul, info, lhs_t, lhs, rhs, binop_debug_loc);
Expand Down
30 changes: 15 additions & 15 deletions src/libstd/io/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -631,14 +631,14 @@ pub trait BufRead: Read {

/// A `Write` adaptor which will write data to multiple locations.
///
/// For more information, see `WriteExt::broadcast`.
#[unstable(feature = "io", reason = "awaiting stability of WriteExt::broadcast")]
/// For more information, see `Write::broadcast`.
#[unstable(feature = "io", reason = "awaiting stability of Write::broadcast")]
pub struct Broadcast<T, U> {
first: T,
second: U,
}

#[unstable(feature = "io", reason = "awaiting stability of WriteExt::broadcast")]
#[unstable(feature = "io", reason = "awaiting stability of Write::broadcast")]
impl<T: Write, U: Write> Write for Broadcast<T, U> {
fn write(&mut self, data: &[u8]) -> Result<usize> {
let n = try!(self.first.write(data));
Expand All @@ -654,7 +654,7 @@ impl<T: Write, U: Write> Write for Broadcast<T, U> {

/// Adaptor to chain together two instances of `Read`.
///
/// For more information, see `ReadExt::chain`.
/// For more information, see `Read::chain`.
#[stable(feature = "rust1", since = "1.0.0")]
pub struct Chain<T, U> {
first: T,
Expand All @@ -677,7 +677,7 @@ impl<T: Read, U: Read> Read for Chain<T, U> {

/// Reader adaptor which limits the bytes read from an underlying reader.
///
/// For more information, see `ReadExt::take`.
/// For more information, see `Read::take`.
#[stable(feature = "rust1", since = "1.0.0")]
pub struct Take<T> {
inner: T,
Expand Down Expand Up @@ -730,14 +730,14 @@ impl<T: BufRead> BufRead for Take<T> {

/// An adaptor which will emit all read data to a specified writer as well.
///
/// For more information see `ReadExt::tee`
#[unstable(feature = "io", reason = "awaiting stability of ReadExt::tee")]
/// For more information see `Read::tee`
#[unstable(feature = "io", reason = "awaiting stability of Read::tee")]
pub struct Tee<R, W> {
reader: R,
writer: W,
}

#[unstable(feature = "io", reason = "awaiting stability of ReadExt::tee")]
#[unstable(feature = "io", reason = "awaiting stability of Read::tee")]
impl<R: Read, W: Write> Read for Tee<R, W> {
fn read(&mut self, buf: &mut [u8]) -> Result<usize> {
let n = try!(self.reader.read(buf));
Expand All @@ -749,7 +749,7 @@ impl<R: Read, W: Write> Read for Tee<R, W> {

/// A bridge from implementations of `Read` to an `Iterator` of `u8`.
///
/// See `ReadExt::bytes` for more information.
/// See `Read::bytes` for more information.
#[stable(feature = "rust1", since = "1.0.0")]
pub struct Bytes<R> {
inner: R,
Expand All @@ -771,16 +771,16 @@ impl<R: Read> Iterator for Bytes<R> {

/// A bridge from implementations of `Read` to an `Iterator` of `char`.
///
/// See `ReadExt::chars` for more information.
#[unstable(feature = "io", reason = "awaiting stability of ReadExt::chars")]
/// See `Read::chars` for more information.
#[unstable(feature = "io", reason = "awaiting stability of Read::chars")]
pub struct Chars<R> {
inner: R,
}

/// An enumeration of possible errors that can be generated from the `Chars`
/// adapter.
#[derive(PartialEq, Clone, Debug)]
#[unstable(feature = "io", reason = "awaiting stability of ReadExt::chars")]
#[unstable(feature = "io", reason = "awaiting stability of Read::chars")]
pub enum CharsError {
/// Variant representing that the underlying stream was read successfully
/// but it did not contain valid utf8 data.
Expand All @@ -790,7 +790,7 @@ pub enum CharsError {
Other(Error),
}

#[unstable(feature = "io", reason = "awaiting stability of ReadExt::chars")]
#[unstable(feature = "io", reason = "awaiting stability of Read::chars")]
impl<R: Read> Iterator for Chars<R> {
type Item = result::Result<char, CharsError>;

Expand Down Expand Up @@ -822,7 +822,7 @@ impl<R: Read> Iterator for Chars<R> {
}
}

#[unstable(feature = "io", reason = "awaiting stability of ReadExt::chars")]
#[unstable(feature = "io", reason = "awaiting stability of Read::chars")]
impl std_error::Error for CharsError {
fn description(&self) -> &str {
match *self {
Expand All @@ -838,7 +838,7 @@ impl std_error::Error for CharsError {
}
}

#[unstable(feature = "io", reason = "awaiting stability of ReadExt::chars")]
#[unstable(feature = "io", reason = "awaiting stability of Read::chars")]
impl fmt::Display for CharsError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/io/prelude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
//! ```
//!
//! This module contains reexports of many core I/O traits such as `Read`,
//! `Write`, `ReadExt`, and `WriteExt`. Structures and functions are not
//! `Write` and `BufRead`. Structures and functions are not
//! contained in this module.

#![stable(feature = "rust1", since = "1.0.0")]
Expand Down
6 changes: 3 additions & 3 deletions src/libstd/sys/unix/os.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ pub fn current_exe() -> io::Result<PathBuf> {
if err != 0 { return Err(io::Error::last_os_error()); }
if sz == 0 { return Err(io::Error::last_os_error()); }
v.set_len(sz as uint - 1); // chop off trailing NUL
Ok(PathBuf::new::<OsString>(OsStringExt::from_vec(v)))
Ok(PathBuf::from(OsString::from_vec(v)))
}
}

Expand All @@ -232,7 +232,7 @@ pub fn current_exe() -> io::Result<PathBuf> {
Err(io::Error::last_os_error())
} else {
let vec = CStr::from_ptr(v).to_bytes().to_vec();
Ok(PathBuf::new::<OsString>(OsStringExt::from_vec(vec)))
Ok(PathBuf::from(OsString::from_vec(vec)))
}
}
}
Expand Down Expand Up @@ -345,7 +345,7 @@ pub fn args() -> Args {
let utf_c_str: *const libc::c_char =
mem::transmute(objc_msgSend(tmp, utf8_sel));
let bytes = CStr::from_ptr(utf_c_str).to_bytes();
res.push(OsString::from_str(str::from_utf8(bytes).unwrap()))
res.push(OsString::from(str::from_utf8(bytes).unwrap()))
}
}

Expand Down
19 changes: 19 additions & 0 deletions src/test/run-pass/issue-23037.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#![feature(core)]

use std::simd::i32x4;
fn main() {
let foo = i32x4(1,2,3,4);
let bar = i32x4(40,30,20,10);
let baz = foo + bar;
assert!(baz.0 == 41 && baz.1 == 32 && baz.2 == 23 && baz.3 == 14);
}
Loading

0 comments on commit a923278

Please sign in to comment.