Skip to content

Commit

Permalink
Auto merge of #34720 - Manishearth:rollup, r=Manishearth
Browse files Browse the repository at this point in the history
Rollup of 9 pull requests

- Successful merges: #34097, #34456, #34610, #34612, #34659, #34688, #34691, #34699, #34700
- Failed merges:
  • Loading branch information
bors authored Jul 8, 2016
2 parents 9b4e2a5 + fe7dc33 commit d8a65cd
Show file tree
Hide file tree
Showing 20 changed files with 125 additions and 119 deletions.
5 changes: 3 additions & 2 deletions src/doc/book/conditional-compilation.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ they get set in the [`[features]` section][features] of your `Cargo.toml`:
# no features by default
default = []

# The “secure-password” feature depends on the bcrypt package.
secure-password = ["bcrypt"]
# Add feature "foo" here, then you can use it.
# Our "foo" feature depends on nothing else.
foo = []
```

When you do this, Cargo passes along a flag to `rustc`:
Expand Down
15 changes: 9 additions & 6 deletions src/doc/book/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ an Internet connection to run the commands in this section, as we’ll be
downloading Rust from the Internet.

We’ll be showing off a number of commands using a terminal, and those lines all
start with `$`. We don't need to type in the `$`s, they are there to indicate
start with `$`. You don't need to type in the `$`s, they are there to indicate
the start of each command. We’ll see many tutorials and examples around the web
that follow this convention: `$` for commands run as our regular user, and `#`
for commands we should be running as an administrator.
Expand Down Expand Up @@ -159,9 +159,11 @@ You should see the version number, commit hash, and commit date.
If you do, Rust has been installed successfully! Congrats!

If you don't and you're on Windows, check that Rust is in your %PATH% system
variable. If it isn't, run the installer again, select "Change" on the "Change,
repair, or remove installation" page and ensure "Add to PATH" is installed on
the local hard drive.
variable: `$ echo %PATH%`. If it isn't, run the installer again, select "Change"
on the "Change, repair, or remove installation" page and ensure "Add to PATH" is
installed on the local hard drive. If you need to configure your path manually,
you can find the Rust executables in a directory like
`"C:\Program Files\Rust stable GNU 1.x\bin"`.

Rust does not do its own linking, and so you’ll need to have a linker
installed. Doing so will depend on your specific system, consult its
Expand Down Expand Up @@ -339,15 +341,16 @@ On Windows, you'd enter:

```bash
$ dir
main.exe main.rs
main.exe
main.rs
```

This shows we have two files: the source code, with an `.rs` extension, and the
executable (`main.exe` on Windows, `main` everywhere else). All that's left to
do from here is run the `main` or `main.exe` file, like this:

```bash
$ ./main # or main.exe on Windows
$ ./main # or .\main.exe on Windows
```

If *main.rs* were your "Hello, world!" program, this would print `Hello,
Expand Down
3 changes: 2 additions & 1 deletion src/liballoc/rc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@

#![allow(deprecated)]

//! Thread-local reference-counted boxes (the `Rc<T>` type).
//! Unsynchronized reference-counted boxes (the `Rc<T>` type) which are usable
//! only within a single thread.
//!
//! The `Rc<T>` type provides shared ownership of an immutable value.
//! Destruction is deterministic, and will occur as soon as the last owner is
Expand Down
18 changes: 12 additions & 6 deletions src/libcore/iter/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -371,13 +371,16 @@ pub trait Extend<A> {
/// Basic usage:
///
/// ```
/// let numbers = vec![1, 2, 3];
/// let numbers = vec![1, 2, 3, 4, 5, 6];
///
/// let mut iter = numbers.iter();
///
/// assert_eq!(Some(&1), iter.next());
/// assert_eq!(Some(&3), iter.next_back());
/// assert_eq!(Some(&2), iter.next_back());
/// assert_eq!(Some(&6), iter.next_back());
/// assert_eq!(Some(&5), iter.next_back());
/// assert_eq!(Some(&2), iter.next());
/// assert_eq!(Some(&3), iter.next());
/// assert_eq!(Some(&4), iter.next());
/// assert_eq!(None, iter.next());
/// assert_eq!(None, iter.next_back());
/// ```
Expand All @@ -395,13 +398,16 @@ pub trait DoubleEndedIterator: Iterator {
/// Basic usage:
///
/// ```
/// let numbers = vec![1, 2, 3];
/// let numbers = vec![1, 2, 3, 4, 5, 6];
///
/// let mut iter = numbers.iter();
///
/// assert_eq!(Some(&1), iter.next());
/// assert_eq!(Some(&3), iter.next_back());
/// assert_eq!(Some(&2), iter.next_back());
/// assert_eq!(Some(&6), iter.next_back());
/// assert_eq!(Some(&5), iter.next_back());
/// assert_eq!(Some(&2), iter.next());
/// assert_eq!(Some(&3), iter.next());
/// assert_eq!(Some(&4), iter.next());
/// assert_eq!(None, iter.next());
/// assert_eq!(None, iter.next_back());
/// ```
Expand Down
3 changes: 2 additions & 1 deletion src/libpanic_unwind/gcc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
#![allow(private_no_mangle_fns)]

use core::any::Any;
use core::ptr;
use alloc::boxed::Box;

use unwind as uw;
Expand Down Expand Up @@ -88,7 +89,7 @@ pub unsafe fn panic(data: Box<Any + Send>) -> u32 {
}

pub fn payload() -> *mut u8 {
0 as *mut u8
ptr::null_mut()
}

pub unsafe fn cleanup(ptr: *mut u8) -> Box<Any + Send> {
Expand Down
3 changes: 2 additions & 1 deletion src/libpanic_unwind/seh64_gnu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use alloc::boxed::Box;

use core::any::Any;
use core::intrinsics;
use core::ptr;
use dwarf::eh;
use windows as c;

Expand Down Expand Up @@ -50,7 +51,7 @@ pub unsafe fn panic(data: Box<Any + Send>) -> u32 {
}

pub fn payload() -> *mut u8 {
0 as *mut u8
ptr::null_mut();
}

pub unsafe fn cleanup(ptr: *mut u8) -> Box<Any + Send> {
Expand Down
3 changes: 2 additions & 1 deletion src/librustc_trans/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ use libc::c_uint;
use std::ffi::{CStr, CString};
use std::cell::{Cell, RefCell};
use std::collections::{HashMap, HashSet};
use std::ptr;
use std::str;
use std::{i8, i16, i32, i64};
use syntax_pos::{Span, DUMMY_SP};
Expand Down Expand Up @@ -2420,7 +2421,7 @@ pub fn create_entry_wrapper(ccx: &CrateContext, sp: Span, main_llfn: ValueRef) {
start_fn,
args.as_ptr(),
args.len() as c_uint,
0 as *mut _,
ptr::null_mut(),
noname());

llvm::LLVMBuildRet(bld, result);
Expand Down
14 changes: 7 additions & 7 deletions src/librustc_trans/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {

check_call("invoke", llfn, args);

let bundle = bundle.as_ref().map(|b| b.raw()).unwrap_or(0 as *mut _);
let bundle = bundle.as_ref().map(|b| b.raw()).unwrap_or(ptr::null_mut());

unsafe {
llvm::LLVMRustBuildInvoke(self.llbuilder,
Expand Down Expand Up @@ -859,7 +859,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {

check_call("call", llfn, args);

let bundle = bundle.as_ref().map(|b| b.raw()).unwrap_or(0 as *mut _);
let bundle = bundle.as_ref().map(|b| b.raw()).unwrap_or(ptr::null_mut());

unsafe {
llvm::LLVMRustBuildCall(self.llbuilder, llfn, args.as_ptr(),
Expand Down Expand Up @@ -961,7 +961,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
self.count_insn("trap");
llvm::LLVMRustBuildCall(self.llbuilder, t,
args.as_ptr(), args.len() as c_uint,
0 as *mut _,
ptr::null_mut(),
noname());
}
}
Expand Down Expand Up @@ -1000,7 +1000,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
parent: Option<ValueRef>,
args: &[ValueRef]) -> ValueRef {
self.count_insn("cleanuppad");
let parent = parent.unwrap_or(0 as *mut _);
let parent = parent.unwrap_or(ptr::null_mut());
let name = CString::new("cleanuppad").unwrap();
let ret = unsafe {
llvm::LLVMRustBuildCleanupPad(self.llbuilder,
Expand All @@ -1016,7 +1016,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
pub fn cleanup_ret(&self, cleanup: ValueRef,
unwind: Option<BasicBlockRef>) -> ValueRef {
self.count_insn("cleanupret");
let unwind = unwind.unwrap_or(0 as *mut _);
let unwind = unwind.unwrap_or(ptr::null_mut());
let ret = unsafe {
llvm::LLVMRustBuildCleanupRet(self.llbuilder, cleanup, unwind)
};
Expand Down Expand Up @@ -1052,8 +1052,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
unwind: Option<BasicBlockRef>,
num_handlers: usize) -> ValueRef {
self.count_insn("catchswitch");
let parent = parent.unwrap_or(0 as *mut _);
let unwind = unwind.unwrap_or(0 as *mut _);
let parent = parent.unwrap_or(ptr::null_mut());
let unwind = unwind.unwrap_or(ptr::null_mut());
let name = CString::new("catchswitch").unwrap();
let ret = unsafe {
llvm::LLVMRustBuildCatchSwitch(self.llbuilder, parent, unwind,
Expand Down
24 changes: 24 additions & 0 deletions src/libstd/io/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,30 @@ impl Error {
}

/// Creates a new instance of an `Error` from a particular OS error code.
///
/// # Examples
///
/// On Linux:
///
/// ```
/// # if cfg!(target_os = "linux") {
/// use std::io;
///
/// let error = io::Error::from_raw_os_error(98);
/// assert_eq!(error.kind(), io::ErrorKind::AddrInUse);
/// # }
/// ```
///
/// On Windows:
///
/// ```
/// # if cfg!(windows) {
/// use std::io;
///
/// let error = io::Error::from_raw_os_error(10048);
/// assert_eq!(error.kind(), io::ErrorKind::AddrInUse);
/// # }
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
pub fn from_raw_os_error(code: i32) -> Error {
Error { repr: Repr::Os(code) }
Expand Down
14 changes: 12 additions & 2 deletions src/libstd/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1529,8 +1529,7 @@ impl Path {

/// The final component of the path, if it is a normal file.
///
/// If the path terminates in `.`, `..`, or consists solely of a root of
/// prefix, `file_name` will return `None`.
/// If the path terminates in `..`, `file_name` will return `None`.
///
/// # Examples
///
Expand All @@ -1543,6 +1542,17 @@ impl Path {
///
/// assert_eq!(Some(os_str), path.file_name());
/// ```
///
/// # Other examples
///
/// ```
/// use std::path::Path;
/// use std::ffi::OsStr;
///
/// assert_eq!(Some(OsStr::new("foo.txt")), Path::new("foo.txt/.").file_name());
/// assert_eq!(Some(OsStr::new("foo.txt")), Path::new("foo.txt/.//").file_name());
/// assert_eq!(None, Path::new("foo.txt/..").file_name());
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
pub fn file_name(&self) -> Option<&OsStr> {
self.components().next_back().and_then(|p| {
Expand Down
3 changes: 2 additions & 1 deletion src/libstd/sync/once.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
// it!

use marker;
use ptr;
use sync::atomic::{AtomicUsize, AtomicBool, Ordering};
use thread::{self, Thread};

Expand Down Expand Up @@ -297,7 +298,7 @@ impl Once {
let mut node = Waiter {
thread: Some(thread::current()),
signaled: AtomicBool::new(false),
next: 0 as *mut Waiter,
next: ptr::null_mut(),
};
let me = &mut node as *mut Waiter as usize;
assert!(me & STATE_MASK == 0);
Expand Down
12 changes: 11 additions & 1 deletion src/libstd/sys/common/net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,19 @@ pub fn lookup_host(host: &str) -> io::Result<LookupHost> {
init();

let c_host = CString::new(host)?;
let hints = c::addrinfo {
ai_flags: 0,
ai_family: 0,
ai_socktype: c::SOCK_STREAM,
ai_protocol: 0,
ai_addrlen: 0,
ai_addr: ptr::null_mut(),
ai_canonname: ptr::null_mut(),
ai_next: ptr::null_mut()
};
let mut res = ptr::null_mut();
unsafe {
cvt_gai(c::getaddrinfo(c_host.as_ptr(), ptr::null(), ptr::null(),
cvt_gai(c::getaddrinfo(c_host.as_ptr(), ptr::null(), &hints,
&mut res))?;
Ok(LookupHost { original: res, cur: res })
}
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 @@ -227,11 +227,11 @@ pub fn current_exe() -> io::Result<PathBuf> {
libc::KERN_PROC_ARGV];
let mib = mib.as_mut_ptr();
let mut argv_len = 0;
cvt(libc::sysctl(mib, 4, 0 as *mut _, &mut argv_len,
0 as *mut _, 0))?;
cvt(libc::sysctl(mib, 4, ptr::null_mut(), &mut argv_len,
ptr::null_mut(), 0))?;
let mut argv = Vec::<*const libc::c_char>::with_capacity(argv_len as usize);
cvt(libc::sysctl(mib, 4, argv.as_mut_ptr() as *mut _,
&mut argv_len, 0 as *mut _, 0))?;
&mut argv_len, ptr::null_mut(), 0))?;
argv.set_len(argv_len as usize);
if argv[0].is_null() {
return Err(io::Error::new(io::ErrorKind::Other,
Expand Down
5 changes: 3 additions & 2 deletions src/libstd/sys/unix/pipe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use cmp;
use io;
use libc::{self, c_int};
use mem;
use ptr;
use sys::cvt_r;
use sys::fd::FileDesc;

Expand Down Expand Up @@ -92,8 +93,8 @@ pub fn read2(p1: AnonPipe,
let mut read: libc::fd_set = mem::zeroed();
libc::FD_SET(p1.raw(), &mut read);
libc::FD_SET(p2.raw(), &mut read);
libc::select(max + 1, &mut read, 0 as *mut _, 0 as *mut _,
0 as *mut _)
libc::select(max + 1, &mut read, ptr::null_mut(), ptr::null_mut(),
ptr::null_mut())
})?;

// Read as much as we can from each pipe, ignoring EWOULDBLOCK or
Expand Down
10 changes: 5 additions & 5 deletions src/libstd/sys/unix/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ impl Command {
let mut saw_nul = false;
let program = os2c(program, &mut saw_nul);
Command {
argv: vec![program.as_ptr(), 0 as *const _],
argv: vec![program.as_ptr(), ptr::null()],
program: program,
args: Vec::new(),
env: None,
Expand All @@ -117,7 +117,7 @@ impl Command {
// pointer.
let arg = os2c(arg, &mut self.saw_nul);
self.argv[self.args.len() + 1] = arg.as_ptr();
self.argv.push(0 as *const _);
self.argv.push(ptr::null());

// Also make sure we keep track of the owned value to schedule a
// destructor for this memory.
Expand All @@ -134,7 +134,7 @@ impl Command {
envp.push(s.as_ptr());
map.insert(k, (envp.len() - 1, s));
}
envp.push(0 as *const _);
envp.push(ptr::null());
self.env = Some(map);
self.envp = Some(envp);
}
Expand All @@ -158,7 +158,7 @@ impl Command {
Entry::Vacant(e) => {
let len = envp.len();
envp[len - 1] = new_key.as_ptr();
envp.push(0 as *const _);
envp.push(ptr::null());
e.insert((len - 1, new_key));
}
}
Expand All @@ -183,7 +183,7 @@ impl Command {

pub fn env_clear(&mut self) {
self.env = Some(HashMap::new());
self.envp = Some(vec![0 as *const _]);
self.envp = Some(vec![ptr::null()]);
}

pub fn cwd(&mut self, dir: &OsStr) {
Expand Down
Loading

0 comments on commit d8a65cd

Please sign in to comment.