Skip to content

Commit d8a65cd

Browse files
authored
Auto merge of #34720 - Manishearth:rollup, r=Manishearth
Rollup of 9 pull requests - Successful merges: #34097, #34456, #34610, #34612, #34659, #34688, #34691, #34699, #34700 - Failed merges:
2 parents 9b4e2a5 + fe7dc33 commit d8a65cd

File tree

20 files changed

+125
-119
lines changed

20 files changed

+125
-119
lines changed

src/doc/book/conditional-compilation.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,9 @@ they get set in the [`[features]` section][features] of your `Cargo.toml`:
4141
# no features by default
4242
default = []
4343

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

4849
When you do this, Cargo passes along a flag to `rustc`:

src/doc/book/getting-started.md

+9-6
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ an Internet connection to run the commands in this section, as we’ll be
1111
downloading Rust from the Internet.
1212

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

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

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

340342
```bash
341343
$ dir
342-
main.exe main.rs
344+
main.exe
345+
main.rs
343346
```
344347

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

349352
```bash
350-
$ ./main # or main.exe on Windows
353+
$ ./main # or .\main.exe on Windows
351354
```
352355

353356
If *main.rs* were your "Hello, world!" program, this would print `Hello,

src/liballoc/rc.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010

1111
#![allow(deprecated)]
1212

13-
//! Thread-local reference-counted boxes (the `Rc<T>` type).
13+
//! Unsynchronized reference-counted boxes (the `Rc<T>` type) which are usable
14+
//! only within a single thread.
1415
//!
1516
//! The `Rc<T>` type provides shared ownership of an immutable value.
1617
//! Destruction is deterministic, and will occur as soon as the last owner is

src/libcore/iter/traits.rs

+12-6
Original file line numberDiff line numberDiff line change
@@ -371,13 +371,16 @@ pub trait Extend<A> {
371371
/// Basic usage:
372372
///
373373
/// ```
374-
/// let numbers = vec![1, 2, 3];
374+
/// let numbers = vec![1, 2, 3, 4, 5, 6];
375375
///
376376
/// let mut iter = numbers.iter();
377377
///
378378
/// assert_eq!(Some(&1), iter.next());
379-
/// assert_eq!(Some(&3), iter.next_back());
380-
/// assert_eq!(Some(&2), iter.next_back());
379+
/// assert_eq!(Some(&6), iter.next_back());
380+
/// assert_eq!(Some(&5), iter.next_back());
381+
/// assert_eq!(Some(&2), iter.next());
382+
/// assert_eq!(Some(&3), iter.next());
383+
/// assert_eq!(Some(&4), iter.next());
381384
/// assert_eq!(None, iter.next());
382385
/// assert_eq!(None, iter.next_back());
383386
/// ```
@@ -395,13 +398,16 @@ pub trait DoubleEndedIterator: Iterator {
395398
/// Basic usage:
396399
///
397400
/// ```
398-
/// let numbers = vec![1, 2, 3];
401+
/// let numbers = vec![1, 2, 3, 4, 5, 6];
399402
///
400403
/// let mut iter = numbers.iter();
401404
///
402405
/// assert_eq!(Some(&1), iter.next());
403-
/// assert_eq!(Some(&3), iter.next_back());
404-
/// assert_eq!(Some(&2), iter.next_back());
406+
/// assert_eq!(Some(&6), iter.next_back());
407+
/// assert_eq!(Some(&5), iter.next_back());
408+
/// assert_eq!(Some(&2), iter.next());
409+
/// assert_eq!(Some(&3), iter.next());
410+
/// assert_eq!(Some(&4), iter.next());
405411
/// assert_eq!(None, iter.next());
406412
/// assert_eq!(None, iter.next_back());
407413
/// ```

src/libpanic_unwind/gcc.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
#![allow(private_no_mangle_fns)]
5858

5959
use core::any::Any;
60+
use core::ptr;
6061
use alloc::boxed::Box;
6162

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

9091
pub fn payload() -> *mut u8 {
91-
0 as *mut u8
92+
ptr::null_mut()
9293
}
9394

9495
pub unsafe fn cleanup(ptr: *mut u8) -> Box<Any + Send> {

src/libpanic_unwind/seh64_gnu.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ use alloc::boxed::Box;
1818

1919
use core::any::Any;
2020
use core::intrinsics;
21+
use core::ptr;
2122
use dwarf::eh;
2223
use windows as c;
2324

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

5253
pub fn payload() -> *mut u8 {
53-
0 as *mut u8
54+
ptr::null_mut();
5455
}
5556

5657
pub unsafe fn cleanup(ptr: *mut u8) -> Box<Any + Send> {

src/librustc_trans/base.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ use libc::c_uint;
9898
use std::ffi::{CStr, CString};
9999
use std::cell::{Cell, RefCell};
100100
use std::collections::{HashMap, HashSet};
101+
use std::ptr;
101102
use std::str;
102103
use std::{i8, i16, i32, i64};
103104
use syntax_pos::{Span, DUMMY_SP};
@@ -2420,7 +2421,7 @@ pub fn create_entry_wrapper(ccx: &CrateContext, sp: Span, main_llfn: ValueRef) {
24202421
start_fn,
24212422
args.as_ptr(),
24222423
args.len() as c_uint,
2423-
0 as *mut _,
2424+
ptr::null_mut(),
24242425
noname());
24252426

24262427
llvm::LLVMBuildRet(bld, result);

src/librustc_trans/builder.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
177177

178178
check_call("invoke", llfn, args);
179179

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

182182
unsafe {
183183
llvm::LLVMRustBuildInvoke(self.llbuilder,
@@ -859,7 +859,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
859859

860860
check_call("call", llfn, args);
861861

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

864864
unsafe {
865865
llvm::LLVMRustBuildCall(self.llbuilder, llfn, args.as_ptr(),
@@ -961,7 +961,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
961961
self.count_insn("trap");
962962
llvm::LLVMRustBuildCall(self.llbuilder, t,
963963
args.as_ptr(), args.len() as c_uint,
964-
0 as *mut _,
964+
ptr::null_mut(),
965965
noname());
966966
}
967967
}
@@ -1000,7 +1000,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
10001000
parent: Option<ValueRef>,
10011001
args: &[ValueRef]) -> ValueRef {
10021002
self.count_insn("cleanuppad");
1003-
let parent = parent.unwrap_or(0 as *mut _);
1003+
let parent = parent.unwrap_or(ptr::null_mut());
10041004
let name = CString::new("cleanuppad").unwrap();
10051005
let ret = unsafe {
10061006
llvm::LLVMRustBuildCleanupPad(self.llbuilder,
@@ -1016,7 +1016,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
10161016
pub fn cleanup_ret(&self, cleanup: ValueRef,
10171017
unwind: Option<BasicBlockRef>) -> ValueRef {
10181018
self.count_insn("cleanupret");
1019-
let unwind = unwind.unwrap_or(0 as *mut _);
1019+
let unwind = unwind.unwrap_or(ptr::null_mut());
10201020
let ret = unsafe {
10211021
llvm::LLVMRustBuildCleanupRet(self.llbuilder, cleanup, unwind)
10221022
};
@@ -1052,8 +1052,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
10521052
unwind: Option<BasicBlockRef>,
10531053
num_handlers: usize) -> ValueRef {
10541054
self.count_insn("catchswitch");
1055-
let parent = parent.unwrap_or(0 as *mut _);
1056-
let unwind = unwind.unwrap_or(0 as *mut _);
1055+
let parent = parent.unwrap_or(ptr::null_mut());
1056+
let unwind = unwind.unwrap_or(ptr::null_mut());
10571057
let name = CString::new("catchswitch").unwrap();
10581058
let ret = unsafe {
10591059
llvm::LLVMRustBuildCatchSwitch(self.llbuilder, parent, unwind,

src/libstd/io/error.rs

+24
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,30 @@ impl Error {
214214
}
215215

216216
/// Creates a new instance of an `Error` from a particular OS error code.
217+
///
218+
/// # Examples
219+
///
220+
/// On Linux:
221+
///
222+
/// ```
223+
/// # if cfg!(target_os = "linux") {
224+
/// use std::io;
225+
///
226+
/// let error = io::Error::from_raw_os_error(98);
227+
/// assert_eq!(error.kind(), io::ErrorKind::AddrInUse);
228+
/// # }
229+
/// ```
230+
///
231+
/// On Windows:
232+
///
233+
/// ```
234+
/// # if cfg!(windows) {
235+
/// use std::io;
236+
///
237+
/// let error = io::Error::from_raw_os_error(10048);
238+
/// assert_eq!(error.kind(), io::ErrorKind::AddrInUse);
239+
/// # }
240+
/// ```
217241
#[stable(feature = "rust1", since = "1.0.0")]
218242
pub fn from_raw_os_error(code: i32) -> Error {
219243
Error { repr: Repr::Os(code) }

src/libstd/path.rs

+12-2
Original file line numberDiff line numberDiff line change
@@ -1529,8 +1529,7 @@ impl Path {
15291529

15301530
/// The final component of the path, if it is a normal file.
15311531
///
1532-
/// If the path terminates in `.`, `..`, or consists solely of a root of
1533-
/// prefix, `file_name` will return `None`.
1532+
/// If the path terminates in `..`, `file_name` will return `None`.
15341533
///
15351534
/// # Examples
15361535
///
@@ -1543,6 +1542,17 @@ impl Path {
15431542
///
15441543
/// assert_eq!(Some(os_str), path.file_name());
15451544
/// ```
1545+
///
1546+
/// # Other examples
1547+
///
1548+
/// ```
1549+
/// use std::path::Path;
1550+
/// use std::ffi::OsStr;
1551+
///
1552+
/// assert_eq!(Some(OsStr::new("foo.txt")), Path::new("foo.txt/.").file_name());
1553+
/// assert_eq!(Some(OsStr::new("foo.txt")), Path::new("foo.txt/.//").file_name());
1554+
/// assert_eq!(None, Path::new("foo.txt/..").file_name());
1555+
/// ```
15461556
#[stable(feature = "rust1", since = "1.0.0")]
15471557
pub fn file_name(&self) -> Option<&OsStr> {
15481558
self.components().next_back().and_then(|p| {

src/libstd/sync/once.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
// it!
6666

6767
use marker;
68+
use ptr;
6869
use sync::atomic::{AtomicUsize, AtomicBool, Ordering};
6970
use thread::{self, Thread};
7071

@@ -297,7 +298,7 @@ impl Once {
297298
let mut node = Waiter {
298299
thread: Some(thread::current()),
299300
signaled: AtomicBool::new(false),
300-
next: 0 as *mut Waiter,
301+
next: ptr::null_mut(),
301302
};
302303
let me = &mut node as *mut Waiter as usize;
303304
assert!(me & STATE_MASK == 0);

src/libstd/sys/common/net.rs

+11-1
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,19 @@ pub fn lookup_host(host: &str) -> io::Result<LookupHost> {
152152
init();
153153

154154
let c_host = CString::new(host)?;
155+
let hints = c::addrinfo {
156+
ai_flags: 0,
157+
ai_family: 0,
158+
ai_socktype: c::SOCK_STREAM,
159+
ai_protocol: 0,
160+
ai_addrlen: 0,
161+
ai_addr: ptr::null_mut(),
162+
ai_canonname: ptr::null_mut(),
163+
ai_next: ptr::null_mut()
164+
};
155165
let mut res = ptr::null_mut();
156166
unsafe {
157-
cvt_gai(c::getaddrinfo(c_host.as_ptr(), ptr::null(), ptr::null(),
167+
cvt_gai(c::getaddrinfo(c_host.as_ptr(), ptr::null(), &hints,
158168
&mut res))?;
159169
Ok(LookupHost { original: res, cur: res })
160170
}

src/libstd/sys/unix/os.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -227,11 +227,11 @@ pub fn current_exe() -> io::Result<PathBuf> {
227227
libc::KERN_PROC_ARGV];
228228
let mib = mib.as_mut_ptr();
229229
let mut argv_len = 0;
230-
cvt(libc::sysctl(mib, 4, 0 as *mut _, &mut argv_len,
231-
0 as *mut _, 0))?;
230+
cvt(libc::sysctl(mib, 4, ptr::null_mut(), &mut argv_len,
231+
ptr::null_mut(), 0))?;
232232
let mut argv = Vec::<*const libc::c_char>::with_capacity(argv_len as usize);
233233
cvt(libc::sysctl(mib, 4, argv.as_mut_ptr() as *mut _,
234-
&mut argv_len, 0 as *mut _, 0))?;
234+
&mut argv_len, ptr::null_mut(), 0))?;
235235
argv.set_len(argv_len as usize);
236236
if argv[0].is_null() {
237237
return Err(io::Error::new(io::ErrorKind::Other,

src/libstd/sys/unix/pipe.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use cmp;
1414
use io;
1515
use libc::{self, c_int};
1616
use mem;
17+
use ptr;
1718
use sys::cvt_r;
1819
use sys::fd::FileDesc;
1920

@@ -92,8 +93,8 @@ pub fn read2(p1: AnonPipe,
9293
let mut read: libc::fd_set = mem::zeroed();
9394
libc::FD_SET(p1.raw(), &mut read);
9495
libc::FD_SET(p2.raw(), &mut read);
95-
libc::select(max + 1, &mut read, 0 as *mut _, 0 as *mut _,
96-
0 as *mut _)
96+
libc::select(max + 1, &mut read, ptr::null_mut(), ptr::null_mut(),
97+
ptr::null_mut())
9798
})?;
9899

99100
// Read as much as we can from each pipe, ignoring EWOULDBLOCK or

src/libstd/sys/unix/process.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ impl Command {
9696
let mut saw_nul = false;
9797
let program = os2c(program, &mut saw_nul);
9898
Command {
99-
argv: vec![program.as_ptr(), 0 as *const _],
99+
argv: vec![program.as_ptr(), ptr::null()],
100100
program: program,
101101
args: Vec::new(),
102102
env: None,
@@ -117,7 +117,7 @@ impl Command {
117117
// pointer.
118118
let arg = os2c(arg, &mut self.saw_nul);
119119
self.argv[self.args.len() + 1] = arg.as_ptr();
120-
self.argv.push(0 as *const _);
120+
self.argv.push(ptr::null());
121121

122122
// Also make sure we keep track of the owned value to schedule a
123123
// destructor for this memory.
@@ -134,7 +134,7 @@ impl Command {
134134
envp.push(s.as_ptr());
135135
map.insert(k, (envp.len() - 1, s));
136136
}
137-
envp.push(0 as *const _);
137+
envp.push(ptr::null());
138138
self.env = Some(map);
139139
self.envp = Some(envp);
140140
}
@@ -158,7 +158,7 @@ impl Command {
158158
Entry::Vacant(e) => {
159159
let len = envp.len();
160160
envp[len - 1] = new_key.as_ptr();
161-
envp.push(0 as *const _);
161+
envp.push(ptr::null());
162162
e.insert((len - 1, new_key));
163163
}
164164
}
@@ -183,7 +183,7 @@ impl Command {
183183

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

189189
pub fn cwd(&mut self, dir: &OsStr) {

0 commit comments

Comments
 (0)