Test fixes and rebase conflicts, round 2

This commit is contained in:
Alex Crichton 2015-03-23 15:54:39 -07:00
parent 3112716f12
commit 29b54387b8
26 changed files with 179 additions and 149 deletions

View File

@ -361,7 +361,8 @@ Heres an example of documenting a macro:
#[macro_export]
macro_rules! panic_unless {
($condition:expr, $($rest:expr),+) => ({ if ! $condition { panic!($($rest),+); } });
}
}
# fn main() {}
```
Youll note three things: we need to add our own `extern crate` line, so that

View File

@ -128,8 +128,8 @@ unsafe impl<T: Sync + Send> Sync for Arc<T> { }
/// A weak pointer to an `Arc`.
///
/// Weak pointers will not keep the data inside of the `Arc` alive, and can be used to break cycles
/// between `Arc` pointers.
/// Weak pointers will not keep the data inside of the `Arc` alive, and can be
/// used to break cycles between `Arc` pointers.
#[unsafe_no_drop_flag]
#[unstable(feature = "alloc",
reason = "Weak pointers may not belong in this module.")]
@ -218,8 +218,8 @@ impl<T> Arc<T> {
unsafe fn drop_slow(&mut self) {
let ptr = *self._ptr;
// Destroy the data at this time, even though we may not free the box allocation itself
// (there may still be weak pointers lying around).
// Destroy the data at this time, even though we may not free the box
// allocation itself (there may still be weak pointers lying around).
drop(ptr::read(&self.inner().data));
if self.inner().weak.fetch_sub(1, Release) == 1 {
@ -286,8 +286,8 @@ impl<T> Deref for Arc<T> {
impl<T: Send + Sync + Clone> Arc<T> {
/// Make a mutable reference from the given `Arc<T>`.
///
/// This is also referred to as a copy-on-write operation because the inner data is cloned if
/// the reference count is greater than one.
/// This is also referred to as a copy-on-write operation because the inner
/// data is cloned if the reference count is greater than one.
///
/// # Examples
///
@ -302,16 +302,18 @@ impl<T: Send + Sync + Clone> Arc<T> {
#[inline]
#[unstable(feature = "alloc")]
pub fn make_unique(&mut self) -> &mut T {
// Note that we hold a strong reference, which also counts as a weak reference, so we only
// clone if there is an additional reference of either kind.
// Note that we hold a strong reference, which also counts as a weak
// reference, so we only clone if there is an additional reference of
// either kind.
if self.inner().strong.load(SeqCst) != 1 ||
self.inner().weak.load(SeqCst) != 1 {
*self = Arc::new((**self).clone())
}
// This unsafety is ok because we're guaranteed that the pointer returned is the *only*
// pointer that will ever be returned to T. Our reference count is guaranteed to be 1 at
// this point, and we required the Arc itself to be `mut`, so we're returning the only
// possible reference to the inner data.
// This unsafety is ok because we're guaranteed that the pointer
// returned is the *only* pointer that will ever be returned to T. Our
// reference count is guaranteed to be 1 at this point, and we required
// the Arc itself to be `mut`, so we're returning the only possible
// reference to the inner data.
let inner = unsafe { &mut **self._ptr };
&mut inner.data
}
@ -322,8 +324,9 @@ impl<T: Send + Sync + Clone> Arc<T> {
impl<T: Sync + Send> Drop for Arc<T> {
/// Drops the `Arc<T>`.
///
/// This will decrement the strong reference count. If the strong reference count becomes zero
/// and the only other references are `Weak<T>` ones, `drop`s the inner value.
/// This will decrement the strong reference count. If the strong reference
/// count becomes zero and the only other references are `Weak<T>` ones,
/// `drop`s the inner value.
///
/// # Examples
///
@ -347,29 +350,32 @@ impl<T: Sync + Send> Drop for Arc<T> {
/// ```
#[inline]
fn drop(&mut self) {
// This structure has #[unsafe_no_drop_flag], so this drop glue may run more than once (but
// it is guaranteed to be zeroed after the first if it's run more than once)
// This structure has #[unsafe_no_drop_flag], so this drop glue may run
// more than once (but it is guaranteed to be zeroed after the first if
// it's run more than once)
let ptr = *self._ptr;
if ptr.is_null() { return }
// Because `fetch_sub` is already atomic, we do not need to synchronize with other threads
// unless we are going to delete the object. This same logic applies to the below
// `fetch_sub` to the `weak` count.
// Because `fetch_sub` is already atomic, we do not need to synchronize
// with other threads unless we are going to delete the object. This
// same logic applies to the below `fetch_sub` to the `weak` count.
if self.inner().strong.fetch_sub(1, Release) != 1 { return }
// This fence is needed to prevent reordering of use of the data and deletion of the data.
// Because it is marked `Release`, the decreasing of the reference count synchronizes with
// this `Acquire` fence. This means that use of the data happens before decreasing the
// reference count, which happens before this fence, which happens before the deletion of
// the data.
// This fence is needed to prevent reordering of use of the data and
// deletion of the data. Because it is marked `Release`, the decreasing
// of the reference count synchronizes with this `Acquire` fence. This
// means that use of the data happens before decreasing the reference
// count, which happens before this fence, which happens before the
// deletion of the data.
//
// As explained in the [Boost documentation][1],
//
// > It is important to enforce any possible access to the object in one thread (through an
// > existing reference) to *happen before* deleting the object in a different thread. This
// > is achieved by a "release" operation after dropping a reference (any access to the
// > object through this reference must obviously happened before), and an "acquire"
// > operation before deleting the object.
// > It is important to enforce any possible access to the object in one
// > thread (through an existing reference) to *happen before* deleting
// > the object in a different thread. This is achieved by a "release"
// > operation after dropping a reference (any access to the object
// > through this reference must obviously happened before), and an
// > "acquire" operation before deleting the object.
//
// [1]: (www.boost.org/doc/libs/1_55_0/doc/html/atomic/usage_examples.html)
atomic::fence(Acquire);
@ -387,7 +393,8 @@ impl<T: Sync + Send> Weak<T> {
///
/// Upgrades the `Weak<T>` reference to an `Arc<T>`, if possible.
///
/// Returns `None` if there were no strong references and the data was destroyed.
/// Returns `None` if there were no strong references and the data was
/// destroyed.
///
/// # Examples
///
@ -402,8 +409,8 @@ impl<T: Sync + Send> Weak<T> {
/// let strong_five: Option<Arc<_>> = weak_five.upgrade();
/// ```
pub fn upgrade(&self) -> Option<Arc<T>> {
// We use a CAS loop to increment the strong count instead of a fetch_add because once the
// count hits 0 is must never be above 0.
// We use a CAS loop to increment the strong count instead of a
// fetch_add because once the count hits 0 is must never be above 0.
let inner = self.inner();
loop {
let n = inner.strong.load(SeqCst);
@ -480,8 +487,9 @@ impl<T: Sync + Send> Drop for Weak<T> {
// see comments above for why this check is here
if ptr.is_null() { return }
// If we find out that we were the last weak pointer, then its time to deallocate the data
// entirely. See the discussion in Arc::drop() about the memory orderings
// If we find out that we were the last weak pointer, then its time to
// deallocate the data entirely. See the discussion in Arc::drop() about
// the memory orderings
if self.inner().weak.fetch_sub(1, Release) == 1 {
atomic::fence(Acquire);
unsafe { deallocate(ptr as *mut u8, size_of::<ArcInner<T>>(),

View File

@ -59,12 +59,12 @@
//!
//! drop(gadget_owner);
//!
//! // Despite dropping gadget_owner, we're still able to print out the name of
//! // the Owner of the Gadgets. This is because we've only dropped the
//! // Despite dropping gadget_owner, we're still able to print out the name
//! // of the Owner of the Gadgets. This is because we've only dropped the
//! // reference count object, not the Owner it wraps. As long as there are
//! // other `Rc<T>` objects pointing at the same Owner, it will remain allocated. Notice
//! // that the `Rc<T>` wrapper around Gadget.owner gets automatically dereferenced
//! // for us.
//! // other `Rc<T>` objects pointing at the same Owner, it will remain
//! // allocated. Notice that the `Rc<T>` wrapper around Gadget.owner gets
//! // automatically dereferenced for us.
//! println!("Gadget {} owned by {}", gadget1.id, gadget1.owner.name);
//! println!("Gadget {} owned by {}", gadget2.id, gadget2.owner.name);
//!
@ -74,19 +74,22 @@
//! }
//! ```
//!
//! If our requirements change, and we also need to be able to traverse from Owner → Gadget, we
//! will run into problems: an `Rc<T>` pointer from Owner → Gadget introduces a cycle between the
//! objects. This means that their reference counts can never reach 0, and the objects will remain
//! allocated: a memory leak. In order to get around this, we can use `Weak<T>` pointers. These
//! pointers don't contribute to the total count.
//! If our requirements change, and we also need to be able to traverse from
//! Owner → Gadget, we will run into problems: an `Rc<T>` pointer from Owner
//! → Gadget introduces a cycle between the objects. This means that their
//! reference counts can never reach 0, and the objects will remain allocated: a
//! memory leak. In order to get around this, we can use `Weak<T>` pointers.
//! These pointers don't contribute to the total count.
//!
//! Rust actually makes it somewhat difficult to produce this loop in the first place: in order to
//! end up with two objects that point at each other, one of them needs to be mutable. This is
//! problematic because `Rc<T>` enforces memory safety by only giving out shared references to the
//! object it wraps, and these don't allow direct mutation. We need to wrap the part of the object
//! we wish to mutate in a `RefCell`, which provides *interior mutability*: a method to achieve
//! mutability through a shared reference. `RefCell` enforces Rust's borrowing rules at runtime.
//! Read the `Cell` documentation for more details on interior mutability.
//! Rust actually makes it somewhat difficult to produce this loop in the first
//! place: in order to end up with two objects that point at each other, one of
//! them needs to be mutable. This is problematic because `Rc<T>` enforces
//! memory safety by only giving out shared references to the object it wraps,
//! and these don't allow direct mutation. We need to wrap the part of the
//! object we wish to mutate in a `RefCell`, which provides *interior
//! mutability*: a method to achieve mutability through a shared reference.
//! `RefCell` enforces Rust's borrowing rules at runtime. Read the `Cell`
//! documentation for more details on interior mutability.
//!
//! ```rust
//! # #![feature(alloc)]
@ -130,9 +133,10 @@
//! for gadget_opt in gadget_owner.gadgets.borrow().iter() {
//!
//! // gadget_opt is a Weak<Gadget>. Since weak pointers can't guarantee
//! // that their object is still allocated, we need to call upgrade() on them
//! // to turn them into a strong reference. This returns an Option, which
//! // contains a reference to our object if it still exists.
//! // that their object is still allocated, we need to call upgrade()
//! // on them to turn them into a strong reference. This returns an
//! // Option, which contains a reference to our object if it still
//! // exists.
//! let gadget = gadget_opt.upgrade().unwrap();
//! println!("Gadget {} owned by {}", gadget.id, gadget.owner.name);
//! }
@ -180,8 +184,8 @@ struct RcBox<T> {
#[unsafe_no_drop_flag]
#[stable(feature = "rust1", since = "1.0.0")]
pub struct Rc<T> {
// FIXME #12808: strange names to try to avoid interfering with field accesses of the contained
// type via Deref
// FIXME #12808: strange names to try to avoid interfering with field
// accesses of the contained type via Deref
_ptr: NonZero<*mut RcBox<T>>,
}
@ -203,9 +207,10 @@ impl<T> Rc<T> {
pub fn new(value: T) -> Rc<T> {
unsafe {
Rc {
// there is an implicit weak pointer owned by all the strong pointers, which
// ensures that the weak destructor never frees the allocation while the strong
// destructor is running, even if the weak pointer is stored inside the strong one.
// there is an implicit weak pointer owned by all the strong
// pointers, which ensures that the weak destructor never frees
// the allocation while the strong destructor is running, even
// if the weak pointer is stored inside the strong one.
_ptr: NonZero::new(boxed::into_raw(box RcBox {
value: value,
strong: Cell::new(1),
@ -245,7 +250,8 @@ pub fn weak_count<T>(this: &Rc<T>) -> usize { this.weak() - 1 }
#[unstable(feature = "alloc")]
pub fn strong_count<T>(this: &Rc<T>) -> usize { this.strong() }
/// Returns true if there are no other `Rc` or `Weak<T>` values that share the same inner value.
/// Returns true if there are no other `Rc` or `Weak<T>` values that share the
/// same inner value.
///
/// # Examples
///
@ -330,8 +336,8 @@ pub fn get_mut<'a, T>(rc: &'a mut Rc<T>) -> Option<&'a mut T> {
impl<T: Clone> Rc<T> {
/// Make a mutable reference from the given `Rc<T>`.
///
/// This is also referred to as a copy-on-write operation because the inner data is cloned if
/// the reference count is greater than one.
/// This is also referred to as a copy-on-write operation because the inner
/// data is cloned if the reference count is greater than one.
///
/// # Examples
///
@ -349,10 +355,11 @@ impl<T: Clone> Rc<T> {
if !is_unique(self) {
*self = Rc::new((**self).clone())
}
// This unsafety is ok because we're guaranteed that the pointer returned is the *only*
// pointer that will ever be returned to T. Our reference count is guaranteed to be 1 at
// this point, and we required the `Rc<T>` itself to be `mut`, so we're returning the only
// possible reference to the inner value.
// This unsafety is ok because we're guaranteed that the pointer
// returned is the *only* pointer that will ever be returned to T. Our
// reference count is guaranteed to be 1 at this point, and we required
// the `Rc<T>` itself to be `mut`, so we're returning the only possible
// reference to the inner value.
let inner = unsafe { &mut **self._ptr };
&mut inner.value
}
@ -373,8 +380,9 @@ impl<T> Deref for Rc<T> {
impl<T> Drop for Rc<T> {
/// Drops the `Rc<T>`.
///
/// This will decrement the strong reference count. If the strong reference count becomes zero
/// and the only other references are `Weak<T>` ones, `drop`s the inner value.
/// This will decrement the strong reference count. If the strong reference
/// count becomes zero and the only other references are `Weak<T>` ones,
/// `drop`s the inner value.
///
/// # Examples
///
@ -404,8 +412,8 @@ impl<T> Drop for Rc<T> {
if self.strong() == 0 {
ptr::read(&**self); // destroy the contained object
// remove the implicit "strong weak" pointer now that we've destroyed the
// contents.
// remove the implicit "strong weak" pointer now that we've
// destroyed the contents.
self.dec_weak();
if self.weak() == 0 {
@ -627,7 +635,8 @@ impl<T: fmt::Debug> fmt::Debug for Rc<T> {
/// A weak version of `Rc<T>`.
///
/// Weak references do not count when determining if the inner value should be dropped.
/// Weak references do not count when determining if the inner value should be
/// dropped.
///
/// See the [module level documentation](./index.html) for more.
#[unsafe_no_drop_flag]
@ -652,7 +661,8 @@ impl<T> Weak<T> {
///
/// Upgrades the `Weak<T>` reference to an `Rc<T>`, if possible.
///
/// Returns `None` if there were no strong references and the data was destroyed.
/// Returns `None` if there were no strong references and the data was
/// destroyed.
///
/// # Examples
///
@ -710,8 +720,8 @@ impl<T> Drop for Weak<T> {
let ptr = *self._ptr;
if !ptr.is_null() {
self.dec_weak();
// the weak count starts at 1, and will only go to zero if all the strong pointers
// have disappeared.
// the weak count starts at 1, and will only go to zero if all
// the strong pointers have disappeared.
if self.weak() == 0 {
deallocate(ptr as *mut u8, size_of::<RcBox<T>>(),
min_align_of::<RcBox<T>>())

View File

@ -8,7 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
//! A growable list type with heap-allocated contents, written `Vec<T>` but pronounced 'vector.'
//! A growable list type with heap-allocated contents, written `Vec<T>` but
//! pronounced 'vector.'
//!
//! Vectors have `O(1)` indexing, push (to the end) and pop (from the end).
//!
@ -124,17 +125,19 @@ use borrow::{Cow, IntoCow};
///
/// # Capacity and reallocation
///
/// The capacity of a vector is the amount of space allocated for any future elements that will be
/// added onto the vector. This is not to be confused with the *length* of a vector, which
/// specifies the number of actual elements within the vector. If a vector's length exceeds its
/// capacity, its capacity will automatically be increased, but its elements will have to be
/// The capacity of a vector is the amount of space allocated for any future
/// elements that will be added onto the vector. This is not to be confused with
/// the *length* of a vector, which specifies the number of actual elements
/// within the vector. If a vector's length exceeds its capacity, its capacity
/// will automatically be increased, but its elements will have to be
/// reallocated.
///
/// For example, a vector with capacity 10 and length 0 would be an empty vector with space for 10
/// more elements. Pushing 10 or fewer elements onto the vector will not change its capacity or
/// cause reallocation to occur. However, if the vector's length is increased to 11, it will have
/// to reallocate, which can be slow. For this reason, it is recommended to use
/// `Vec::with_capacity` whenever possible to specify how big the vector is expected to get.
/// For example, a vector with capacity 10 and length 0 would be an empty vector
/// with space for 10 more elements. Pushing 10 or fewer elements onto the
/// vector will not change its capacity or cause reallocation to occur. However,
/// if the vector's length is increased to 11, it will have to reallocate, which
/// can be slow. For this reason, it is recommended to use `Vec::with_capacity`
/// whenever possible to specify how big the vector is expected to get.
#[unsafe_no_drop_flag]
#[stable(feature = "rust1", since = "1.0.0")]
pub struct Vec<T> {
@ -1429,7 +1432,7 @@ impl<T> ops::Index<ops::RangeFull> for Vec<T> {
#[cfg(not(stage0))]
#[inline]
fn index(&self, _index: ops::RangeFull) -> &[T] {
self.as_slice()
self
}
}
@ -1733,15 +1736,20 @@ impl<T> AsRef<[T]> for Vec<T> {
#[stable(feature = "rust1", since = "1.0.0")]
impl<'a, T: Clone> From<&'a [T]> for Vec<T> {
#[cfg(not(test))]
fn from(s: &'a [T]) -> Vec<T> {
s.to_vec()
}
#[cfg(test)]
fn from(s: &'a [T]) -> Vec<T> {
::slice::to_vec(s)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
impl<'a> From<&'a str> for Vec<u8> {
fn from(s: &'a str) -> Vec<u8> {
s.as_bytes().to_vec()
From::from(s.as_bytes())
}
}

View File

@ -20,6 +20,7 @@
#![feature(unboxed_closures)]
#![feature(unicode)]
#![feature(unsafe_destructor)]
#![feature(into_cow)]
#![cfg_attr(test, feature(str_char))]
#[macro_use] extern crate log;

View File

@ -47,13 +47,13 @@
//! which is cyclic.
//!
//! ```rust
//! # #![feature(rustc_private, core)]
//! # #![feature(rustc_private, core, into_cow)]
//! use std::borrow::IntoCow;
//! use std::io::Write;
//! use graphviz as dot;
//!
//! type Nd = int;
//! type Ed = (int,int);
//! type Nd = isize;
//! type Ed = (isize,isize);
//! struct Edges(Vec<Ed>);
//!
//! pub fn render_to<W: Write>(output: &mut W) {
@ -133,7 +133,7 @@
//! direct reference to the `(source,target)` pair stored in the graph's
//! internal vector (rather than passing around a copy of the pair
//! itself). Note that this implies that `fn edges(&'a self)` must
//! construct a fresh `Vec<&'a (uint,uint)>` from the `Vec<(uint,uint)>`
//! construct a fresh `Vec<&'a (usize,usize)>` from the `Vec<(usize,usize)>`
//! edges stored in `self`.
//!
//! Since both the set of nodes and the set of edges are always
@ -149,14 +149,14 @@
//! entity `&sube`).
//!
//! ```rust
//! # #![feature(rustc_private, core)]
//! # #![feature(rustc_private, core, into_cow)]
//! use std::borrow::IntoCow;
//! use std::io::Write;
//! use graphviz as dot;
//!
//! type Nd = uint;
//! type Ed<'a> = &'a (uint, uint);
//! struct Graph { nodes: Vec<&'static str>, edges: Vec<(uint,uint)> }
//! type Nd = usize;
//! type Ed<'a> = &'a (usize, usize);
//! struct Graph { nodes: Vec<&'static str>, edges: Vec<(usize,usize)> }
//!
//! pub fn render_to<W: Write>(output: &mut W) {
//! let nodes = vec!("{x,y}","{x}","{y}","{}");
@ -207,14 +207,14 @@
//! Hasse-diagram for the subsets of the set `{x, y}`.
//!
//! ```rust
//! # #![feature(rustc_private, core)]
//! # #![feature(rustc_private, core, into_cow)]
//! use std::borrow::IntoCow;
//! use std::io::Write;
//! use graphviz as dot;
//!
//! type Nd<'a> = (uint, &'a str);
//! type Nd<'a> = (usize, &'a str);
//! type Ed<'a> = (Nd<'a>, Nd<'a>);
//! struct Graph { nodes: Vec<&'static str>, edges: Vec<(uint,uint)> }
//! struct Graph { nodes: Vec<&'static str>, edges: Vec<(usize,usize)> }
//!
//! pub fn render_to<W: Write>(output: &mut W) {
//! let nodes = vec!("{x,y}","{x}","{y}","{}");
@ -231,7 +231,7 @@
//! }
//! fn node_label<'b>(&'b self, n: &Nd<'b>) -> dot::LabelText<'b> {
//! let &(i, _) = n;
//! dot::LabelText::LabelStr(self.nodes[i].as_slice().into_cow())
//! dot::LabelText::LabelStr(self.nodes[i].into_cow())
//! }
//! fn edge_label<'b>(&'b self, _: &Ed<'b>) -> dot::LabelText<'b> {
//! dot::LabelText::LabelStr("&sube;".into_cow())
@ -240,12 +240,12 @@
//!
//! impl<'a> dot::GraphWalk<'a, Nd<'a>, Ed<'a>> for Graph {
//! fn nodes(&'a self) -> dot::Nodes<'a,Nd<'a>> {
//! self.nodes.iter().map(|s|s.as_slice()).enumerate().collect()
//! self.nodes.iter().map(|s| &s[..]).enumerate().collect()
//! }
//! fn edges(&'a self) -> dot::Edges<'a,Ed<'a>> {
//! self.edges.iter()
//! .map(|&(i,j)|((i, self.nodes[i].as_slice()),
//! (j, self.nodes[j].as_slice())))
//! .map(|&(i,j)|((i, &self.nodes[i][..]),
//! (j, &self.nodes[j][..])))
//! .collect()
//! }
//! fn source(&self, e: &Ed<'a>) -> Nd<'a> { let &(s,_) = e; s }
@ -385,7 +385,7 @@ impl<'a> Id<'a> {
is_letter_or_underscore(c) || in_range('0', c, '9')
}
fn in_range(low: char, c: char, high: char) -> bool {
low as uint <= c as uint && c as uint <= high as uint
low as usize <= c as usize && c as usize <= high as usize
}
}
@ -602,12 +602,12 @@ mod tests {
use std::iter::repeat;
/// each node is an index in a vector in the graph.
type Node = uint;
type Node = usize;
struct Edge {
from: uint, to: uint, label: &'static str
from: usize, to: usize, label: &'static str
}
fn edge(from: uint, to: uint, label: &'static str) -> Edge {
fn edge(from: usize, to: usize, label: &'static str) -> Edge {
Edge { from: from, to: to, label: label }
}
@ -637,7 +637,7 @@ mod tests {
enum NodeLabels<L> {
AllNodesLabelled(Vec<L>),
UnlabelledNodes(uint),
UnlabelledNodes(usize),
SomeNodesLabelled(Vec<Option<L>>),
}

View File

@ -47,7 +47,6 @@
#![feature(rand)]
#![feature(path_ext)]
#![feature(std_misc)]
#![feature(path_relative_from)]
#![feature(step_by)]
#![feature(convert)]
#![cfg_attr(test, feature(test, rand))]

View File

@ -228,7 +228,7 @@ mod test {
used_crates: Vec::new(),
has_rpath: true,
is_like_osx: true,
out_filename: PathBuf::new("bin/rustc"),
out_filename: PathBuf::from("bin/rustc"),
get_install_prefix_lib_path: &mut || panic!(),
realpath: &mut |p| Ok(p.to_path_buf()),
};
@ -238,7 +238,7 @@ mod test {
} else {
let config = &mut RPathConfig {
used_crates: Vec::new(),
out_filename: PathBuf::new("bin/rustc"),
out_filename: PathBuf::from("bin/rustc"),
get_install_prefix_lib_path: &mut || panic!(),
has_rpath: true,
is_like_osx: false,

View File

@ -40,7 +40,6 @@
#![feature(rustc_private)]
#![feature(unsafe_destructor)]
#![feature(staged_api)]
#![feature(std_misc)]
#![feature(str_char)]
#![cfg_attr(test, feature(test))]

View File

@ -81,7 +81,7 @@ pub fn trans_inline_asm<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, ia: &ast::InlineAsm)
// Default per-arch clobbers
// Basically what clang does
let arch_clobbers = match bcx.sess().target.target.arch.as_slice() {
let arch_clobbers = match &bcx.sess().target.target.arch[..] {
"x86" | "x86_64" => vec!("~{dirflag}", "~{fpsr}", "~{flags}"),
_ => Vec::new()
};

View File

@ -80,7 +80,6 @@ This API is completely unstable and subject to change.
#![feature(collections)]
#![feature(core)]
#![feature(int_uint)]
#![feature(std_misc)]
#![feature(quote)]
#![feature(rustc_diagnostic_macros)]
#![feature(rustc_private)]

View File

@ -327,12 +327,13 @@ pub struct JoinPathsError {
/// # Examples
///
/// ```
/// # #![feature(convert)]
/// use std::env;
/// use std::path::PathBuf;
///
/// if let Some(path) = env::var_os("PATH") {
/// let mut paths = env::split_paths(&path).collect::<Vec<_>>();
/// paths.push(PathBuf::new("/home/xyz/bin"));
/// paths.push(PathBuf::from("/home/xyz/bin"));
/// let new_path = env::join_paths(paths.iter()).unwrap();
/// env::set_var("PATH", &new_path);
/// }
@ -853,7 +854,7 @@ mod tests {
fn split_paths_unix() {
fn check_parse(unparsed: &str, parsed: &[&str]) -> bool {
split_paths(unparsed).collect::<Vec<_>>() ==
parsed.iter().map(|s| PathBuf::new(*s)).collect::<Vec<_>>()
parsed.iter().map(|s| PathBuf::from(*s)).collect::<Vec<_>>()
}
assert!(check_parse("", &mut [""]));

View File

@ -35,9 +35,10 @@
//! To build or modify paths, use `PathBuf`:
//!
//! ```rust
//! # #![feature(convert)]
//! use std::path::PathBuf;
//!
//! let mut path = PathBuf::new("c:\\");
//! let mut path = PathBuf::from("c:\\");
//! path.push("windows");
//! path.push("system32");
//! path.set_extension("dll");
@ -892,9 +893,10 @@ impl<'a> cmp::Ord for Components<'a> {
/// # Examples
///
/// ```
/// # #![feature(convert)]
/// use std::path::PathBuf;
///
/// let mut path = PathBuf::new("c:\\");
/// let mut path = PathBuf::from("c:\\");
/// path.push("windows");
/// path.push("system32");
/// path.set_extension("dll");
@ -983,15 +985,16 @@ impl PathBuf {
/// # Examples
///
/// ```
/// # #![feature(convert)]
/// use std::path::PathBuf;
///
/// let mut buf = PathBuf::new("/");
/// let mut buf = PathBuf::from("/");
/// assert!(buf.file_name() == None);
/// buf.set_file_name("bar");
/// assert!(buf == PathBuf::new("/bar"));
/// assert!(buf == PathBuf::from("/bar"));
/// assert!(buf.file_name().is_some());
/// buf.set_file_name("baz.txt");
/// assert!(buf == PathBuf::new("/baz.txt"));
/// assert!(buf == PathBuf::from("/baz.txt"));
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
pub fn set_file_name<S: AsRef<OsStr>>(&mut self, file_name: S) {
@ -1661,7 +1664,7 @@ mod tests {
let static_path = Path::new("/home/foo");
let static_cow_path: Cow<'static, Path> = static_path.into_cow();
let pathbuf = PathBuf::new("/home/foo");
let pathbuf = PathBuf::from("/home/foo");
{
let path: &Path = &pathbuf;
@ -2543,7 +2546,7 @@ mod tests {
pub fn test_push() {
macro_rules! tp(
($path:expr, $push:expr, $expected:expr) => ( {
let mut actual = PathBuf::new($path);
let mut actual = PathBuf::from($path);
actual.push($push);
assert!(actual.to_str() == Some($expected),
"pushing {:?} onto {:?}: Expected {:?}, got {:?}",
@ -2631,7 +2634,7 @@ mod tests {
pub fn test_pop() {
macro_rules! tp(
($path:expr, $expected:expr, $output:expr) => ( {
let mut actual = PathBuf::new($path);
let mut actual = PathBuf::from($path);
let output = actual.pop();
assert!(actual.to_str() == Some($expected) && output == $output,
"popping from {:?}: Expected {:?}/{:?}, got {:?}/{:?}",
@ -2685,7 +2688,7 @@ mod tests {
pub fn test_set_file_name() {
macro_rules! tfn(
($path:expr, $file:expr, $expected:expr) => ( {
let mut p = PathBuf::new($path);
let mut p = PathBuf::from($path);
p.set_file_name($file);
assert!(p.to_str() == Some($expected),
"setting file name of {:?} to {:?}: Expected {:?}, got {:?}",
@ -2719,7 +2722,7 @@ mod tests {
pub fn test_set_extension() {
macro_rules! tfe(
($path:expr, $ext:expr, $expected:expr, $output:expr) => ( {
let mut p = PathBuf::new($path);
let mut p = PathBuf::from($path);
let output = p.set_extension($ext);
assert!(p.to_str() == Some($expected) && output == $output,
"setting extension of {:?} to {:?}: Expected {:?}/{:?}, got {:?}/{:?}",

View File

@ -770,7 +770,7 @@ mod tests {
// test changing to the parent of os::getcwd() because we know
// the path exists (and os::getcwd() is not expected to be root)
let parent_dir = os::getcwd().unwrap().dir_path();
let result = pwd_cmd().current_dir(&parent_dir).output().unwrap();
let result = pwd_cmd().current_dir(parent_dir.as_str().unwrap()).output().unwrap();
let output = String::from_utf8(result.stdout).unwrap();
let child_dir = old_path::Path::new(output.trim());

View File

@ -13,14 +13,12 @@
use core::prelude::*;
use cmp;
use dynamic_lib::DynamicLibrary;
use ffi::CString;
use io;
use libc::consts::os::posix01::PTHREAD_STACK_MIN;
use libc;
use mem;
use ptr;
use sync::{Once, ONCE_INIT};
use sys::os;
use thunk::Thunk;
use time::Duration;
@ -322,6 +320,9 @@ pub fn sleep(dur: Duration) {
// dependency on libc6 (#23628).
#[cfg(target_os = "linux")]
fn min_stack_size(attr: *const libc::pthread_attr_t) -> libc::size_t {
use dynamic_lib::DynamicLibrary;
use sync::{Once, ONCE_INIT};
type F = unsafe extern "C" fn(*const libc::pthread_attr_t) -> libc::size_t;
static INIT: Once = ONCE_INIT;
static mut __pthread_get_minstack: Option<F> = None;

View File

@ -372,7 +372,7 @@ pub fn readlink(p: &Path) -> io::Result<PathBuf> {
sz - 1,
libc::VOLUME_NAME_DOS)
}, |s| OsStringExt::from_wide(s)));
Ok(PathBuf::new(&ret))
Ok(PathBuf::from(&ret))
}
pub fn symlink(src: &Path, dst: &Path) -> io::Result<()> {

View File

@ -304,9 +304,7 @@ fn fill_utf16_buf_new<F1, F2, T>(f1: F1, f2: F2) -> io::Result<T>
}
fn os2path(s: &[u16]) -> PathBuf {
let os = <OsString as OsStringExt>::from_wide(s);
// FIXME(#22751) should consume `os`
PathBuf::new(&os)
PathBuf::from(OsString::from_wide(s))
}
pub fn truncate_utf16_at_nul<'a>(v: &'a [u16]) -> &'a [u16] {

View File

@ -363,10 +363,7 @@ pub fn temp_dir() -> PathBuf {
pub fn home_dir() -> Option<PathBuf> {
getenv("HOME".as_os_str()).or_else(|| {
getenv("USERPROFILE".as_os_str())
}).map(|os| {
// FIXME(#22751) should consume `os`
PathBuf::new(&os)
}).or_else(|| unsafe {
}).map(PathBuf::from).or_else(|| unsafe {
let me = c::GetCurrentProcess();
let mut token = ptr::null_mut();
if c::OpenProcessToken(me, c::TOKEN_READ, &mut token) == 0 {

View File

@ -24,7 +24,7 @@
//! # Examples
//!
//! ```
//! # #![feature(std_misc)]
//! # #![feature(scoped_tls)]
//! scoped_thread_local!(static FOO: u32);
//!
//! // Initially each scoped slot is empty.
@ -147,7 +147,7 @@ impl<T> ScopedKey<T> {
/// # Examples
///
/// ```
/// # #![feature(std_misc)]
/// # #![feature(scoped_tls)]
/// scoped_thread_local!(static FOO: u32);
///
/// FOO.set(&100, || {
@ -200,7 +200,7 @@ impl<T> ScopedKey<T> {
/// # Examples
///
/// ```no_run
/// # #![feature(std_misc)]
/// # #![feature(scoped_tls)]
/// scoped_thread_local!(static FOO: u32);
///
/// FOO.with(|slot| {

View File

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(rustc_private, path)]
#![feature(rustc_private, path, convert)]
extern crate rustc;
extern crate rustc_driver;
@ -33,9 +33,9 @@ fn main() {
panic!("expected rustc path");
}
let tmpdir = PathBuf::new(&args[1]);
let tmpdir = PathBuf::from(&args[1]);
let mut sysroot = PathBuf::new(&args[3]);
let mut sysroot = PathBuf::from(&args[3]);
sysroot.pop();
sysroot.pop();

View File

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(tempdir)]
use std::env;
use std::fs::{self, TempDir};

View File

@ -12,12 +12,12 @@
// pretty-expanded FIXME #23616
#![feature(old_io, old_path)]
#![feature(convert)]
use std::default::Default;
use std::io;
use std::fs;
use std::path::{PathBuf, Path};
use std::path::PathBuf;
pub trait PathExtensions {
fn is_dir(&self) -> bool { false }
@ -98,8 +98,8 @@ impl<S: Strategy> Iterator for Subpaths<S> {
}
}
fn foo() {
let mut walker: Subpaths<Recursive> = Subpaths::walk(&PathBuf::new("/home")).unwrap();
fn _foo() {
let _walker: Subpaths<Recursive> = Subpaths::walk(&PathBuf::from("/home")).unwrap();
}
fn main() {}

View File

@ -10,7 +10,7 @@
// pretty-expanded FIXME #23616
#![feature(collections)]
#![feature(collections, into_cow)]
extern crate collections;

View File

@ -10,7 +10,7 @@
// pretty-expanded FIXME #23616
#![feature(collections)]
#![feature(collections, into_cow)]
extern crate collections;

View File

@ -13,6 +13,9 @@
// ignore-openbsd system ulimit (Too many open files)
// exec-env:RUST_LOG=debug
#![feature(rustc_private, libc, old_io, io, std_misc)]
#![allow(deprecated, unused_must_use)]
#[macro_use]
extern crate log;
extern crate libc;

View File

@ -10,7 +10,7 @@
// pretty-expanded FIXME #23616
#![feature(collections, rand)]
#![feature(collections, rand, into_cow)]
use std::borrow::{Cow, IntoCow};
use std::collections::BitVec;