Skip to content

Commit 7251402

Browse files
committed
---
yaml --- r: 191485 b: refs/heads/try c: 17c1a46 h: refs/heads/master i: 191483: 66e012a v: v3
1 parent f953302 commit 7251402

File tree

28 files changed

+312
-79
lines changed

28 files changed

+312
-79
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: 809a554fca2d0ebc2ba50077016fe282a4064752
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: c64d671671aea2e44ee7fc6eb00ee75fc30ed7b9
5-
refs/heads/try: 3e3408de0f73f7df7c8a626c64ff4d704f08353d
5+
refs/heads/try: 17c1a46a7d113c81a26eed5be8942be94b78eff2
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
88
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596

branches/try/Makefile.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@
9797
# make check-stage1-rpass TESTNAME=my-shiny-new-test
9898
#
9999
# // Having trouble figuring out which test is failing? Turn off parallel tests
100-
# make check-stage1-std RUST_TEST_TASKS=1
100+
# make check-stage1-std RUST_TEST_THREADS=1
101101
#
102102
# This is hardly all there is to know of The Rust Build System's
103103
# mysteries. The tale continues on the wiki[1].

branches/try/src/compiletest/compiletest.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,15 +224,15 @@ pub fn run_tests(config: &Config) {
224224
// android debug-info test uses remote debugger
225225
// so, we test 1 task at once.
226226
// also trying to isolate problems with adb_run_wrapper.sh ilooping
227-
env::set_var("RUST_TEST_TASKS","1");
227+
env::set_var("RUST_TEST_THREADS","1");
228228
}
229229

230230
match config.mode {
231231
DebugInfoLldb => {
232232
// Some older versions of LLDB seem to have problems with multiple
233233
// instances running in parallel, so only run one test task at a
234234
// time.
235-
env::set_var("RUST_TEST_TASKS", "1");
235+
env::set_var("RUST_TEST_THREADS", "1");
236236
}
237237
_ => { /* proceed */ }
238238
}

branches/try/src/compiletest/header.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ pub fn load_props(testfile: &Path) -> TestProps {
131131
true
132132
});
133133

134-
for key in vec!["RUST_TEST_NOCAPTURE", "RUST_TEST_TASKS"] {
134+
for key in vec!["RUST_TEST_NOCAPTURE", "RUST_TEST_THREADS"] {
135135
match env::var(key) {
136136
Ok(val) =>
137137
if exec_env.iter().find(|&&(ref x, _)| *x == key.to_string()).is_none() {

branches/try/src/libcore/num/mod.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,16 @@ pub trait Int
345345

346346
/// Saturating integer addition. Computes `self + other`, saturating at
347347
/// the numeric bounds instead of overflowing.
348+
///
349+
/// # Examples
350+
///
351+
/// ```
352+
/// use std::num::Int;
353+
///
354+
/// assert_eq!(5u16.saturating_add(65534), 65535);
355+
/// assert_eq!((-5i16).saturating_add(-32767), -32768);
356+
/// assert_eq!(100u32.saturating_add(4294967294), 4294967295);
357+
/// ```
348358
#[stable(feature = "rust1", since = "1.0.0")]
349359
#[inline]
350360
fn saturating_add(self, other: Self) -> Self {
@@ -357,6 +367,16 @@ pub trait Int
357367

358368
/// Saturating integer subtraction. Computes `self - other`, saturating at
359369
/// the numeric bounds instead of overflowing.
370+
///
371+
/// # Examples
372+
///
373+
/// ```
374+
/// use std::num::Int;
375+
///
376+
/// assert_eq!(5u16.saturating_sub(65534), 0);
377+
/// assert_eq!(5i16.saturating_sub(-32767), 32767);
378+
/// assert_eq!(100u32.saturating_sub(4294967294), 0);
379+
/// ```
360380
#[stable(feature = "rust1", since = "1.0.0")]
361381
#[inline]
362382
fn saturating_sub(self, other: Self) -> Self {

branches/try/src/librustc/middle/astencode.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,12 +235,27 @@ impl<'a, 'b, 'tcx> DecodeContext<'a, 'b, 'tcx> {
235235
pub fn tr_span(&self, span: Span) -> Span {
236236
let imported_filemaps = &self.cdata.codemap_import_info[..];
237237

238+
let span = if span.lo > span.hi {
239+
// Currently macro expansion sometimes produces invalid Span values
240+
// where lo > hi. In order not to crash the compiler when trying to
241+
// translate these values, let's transform them into something we
242+
// can handle (and which will produce useful debug locations at
243+
// least some of the time).
244+
// This workaround is only necessary as long as macro expansion is
245+
// not fixed. FIXME(#23480)
246+
codemap::mk_sp(span.lo, span.lo)
247+
} else {
248+
span
249+
};
250+
238251
let filemap_index = {
239252
// Optimize for the case that most spans within a translated item
240253
// originate from the same filemap.
241254
let last_filemap_index = self.last_filemap_index.get();
242255

243256
if span.lo >= imported_filemaps[last_filemap_index].original_start_pos &&
257+
span.lo <= imported_filemaps[last_filemap_index].original_end_pos &&
258+
span.hi >= imported_filemaps[last_filemap_index].original_start_pos &&
244259
span.hi <= imported_filemaps[last_filemap_index].original_end_pos {
245260
last_filemap_index
246261
} else {

branches/try/src/librustc_back/tempdir.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,12 @@ impl TempDir {
6161
let path = tmpdir.join(&leaf);
6262
match fs::create_dir(&path) {
6363
Ok(_) => return Ok(TempDir { path: Some(path) }),
64-
Err(ref e) if e.kind() == ErrorKind::PathAlreadyExists => {}
64+
Err(ref e) if e.kind() == ErrorKind::AlreadyExists => {}
6565
Err(e) => return Err(e)
6666
}
6767
}
6868

69-
Err(Error::new(ErrorKind::PathAlreadyExists,
69+
Err(Error::new(ErrorKind::AlreadyExists,
7070
"too many temporary directories already exist",
7171
None))
7272
}

branches/try/src/librustdoc/html/render.rs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -692,16 +692,23 @@ fn shortty(item: &clean::Item) -> ItemType {
692692

693693
/// Takes a path to a source file and cleans the path to it. This canonicalizes
694694
/// things like ".." to components which preserve the "top down" hierarchy of a
695-
/// static HTML tree.
695+
/// static HTML tree. Each component in the cleaned path will be passed as an
696+
/// argument to `f`. The very last component of the path (ie the file name) will
697+
/// be passed to `f` if `keep_filename` is true, and ignored otherwise.
696698
// FIXME (#9639): The closure should deal with &[u8] instead of &str
697699
// FIXME (#9639): This is too conservative, rejecting non-UTF-8 paths
698-
fn clean_srcpath<F>(src_root: &Path, p: &Path, mut f: F) where
700+
fn clean_srcpath<F>(src_root: &Path, p: &Path, keep_filename: bool, mut f: F) where
699701
F: FnMut(&str),
700702
{
701703
// make it relative, if possible
702704
let p = p.relative_from(src_root).unwrap_or(p);
703705

704-
for c in p.iter().map(|x| x.to_str().unwrap()) {
706+
let mut iter = p.iter().map(|x| x.to_str().unwrap()).peekable();
707+
while let Some(c) = iter.next() {
708+
if !keep_filename && iter.peek().is_none() {
709+
break;
710+
}
711+
705712
if ".." == c {
706713
f("up");
707714
} else {
@@ -803,7 +810,7 @@ impl<'a> SourceCollector<'a> {
803810
// Create the intermediate directories
804811
let mut cur = self.dst.clone();
805812
let mut root_path = String::from_str("../../");
806-
clean_srcpath(&self.cx.src_root, &p, |component| {
813+
clean_srcpath(&self.cx.src_root, &p, false, |component| {
807814
cur.push(component);
808815
mkdir(&cur).unwrap();
809816
root_path.push_str("../");
@@ -1368,7 +1375,7 @@ impl<'a> Item<'a> {
13681375
if ast_util::is_local(self.item.def_id) {
13691376
let mut path = Vec::new();
13701377
clean_srcpath(&cx.src_root, Path::new(&self.item.source.filename),
1371-
|component| {
1378+
true, |component| {
13721379
path.push(component.to_string());
13731380
});
13741381
let href = if self.item.source.loline == self.item.source.hiline {

branches/try/src/librustdoc/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
#![feature(test)]
3636
#![feature(unicode)]
3737
#![feature(str_words)]
38-
#![feature(io)]
3938
#![feature(file_path)]
4039
#![feature(path_ext)]
4140
#![feature(path_relative_from)]

branches/try/src/libserialize/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ Core encoding and decoding interfaces.
3131
#![feature(collections)]
3232
#![feature(core)]
3333
#![feature(int_uint)]
34-
#![feature(io)]
3534
#![feature(old_path)]
3635
#![feature(rustc_private)]
3736
#![feature(staged_api)]

branches/try/src/libstd/fs/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ pub fn copy<P: AsPath, Q: AsPath>(from: P, to: Q) -> io::Result<u64> {
498498
let from = from.as_path();
499499
let to = to.as_path();
500500
if !from.is_file() {
501-
return Err(Error::new(ErrorKind::MismatchedFileTypeForOperation,
501+
return Err(Error::new(ErrorKind::InvalidInput,
502502
"the source path is not an existing file",
503503
None))
504504
}
@@ -1139,7 +1139,7 @@ mod tests {
11391139
let dir = &tmpdir.join("mkdir_error_twice");
11401140
check!(fs::create_dir(dir));
11411141
let e = fs::create_dir(dir).err().unwrap();
1142-
assert_eq!(e.kind(), ErrorKind::PathAlreadyExists);
1142+
assert_eq!(e.kind(), ErrorKind::AlreadyExists);
11431143
}
11441144

11451145
#[test]

branches/try/src/libstd/fs/tempdir.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,12 @@ impl TempDir {
6868
let path = tmpdir.join(&leaf);
6969
match fs::create_dir(&path) {
7070
Ok(_) => return Ok(TempDir { path: Some(path) }),
71-
Err(ref e) if e.kind() == ErrorKind::PathAlreadyExists => {}
71+
Err(ref e) if e.kind() == ErrorKind::AlreadyExists => {}
7272
Err(e) => return Err(e)
7373
}
7474
}
7575

76-
Err(Error::new(ErrorKind::PathAlreadyExists,
76+
Err(Error::new(ErrorKind::AlreadyExists,
7777
"too many temporary directories already exist",
7878
None))
7979
}

branches/try/src/libstd/io/error.rs

Lines changed: 58 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -51,53 +51,77 @@ struct Custom {
5151
}
5252

5353
/// A list specifying general categories of I/O error.
54+
///
55+
/// This list is intended to grow over time and it is not recommended to
56+
/// exhaustively match against it.
5457
#[derive(Copy, PartialEq, Eq, Clone, Debug)]
55-
#[unstable(feature = "io",
56-
reason = "the interaction between OS error codes and how they map to \
57-
these names (as well as the names themselves) has not \
58-
been thoroughly thought out")]
58+
#[stable(feature = "rust1", since = "1.0.0")]
5959
pub enum ErrorKind {
60-
/// The file was not found.
61-
FileNotFound,
62-
/// The file permissions disallowed access to this file.
60+
/// An entity was not found, often a file.
61+
#[stable(feature = "rust1", since = "1.0.0")]
62+
NotFound,
63+
/// The operation lacked the necessary privileges to complete.
64+
#[stable(feature = "rust1", since = "1.0.0")]
6365
PermissionDenied,
6466
/// The connection was refused by the remote server.
67+
#[stable(feature = "rust1", since = "1.0.0")]
6568
ConnectionRefused,
6669
/// The connection was reset by the remote server.
70+
#[stable(feature = "rust1", since = "1.0.0")]
6771
ConnectionReset,
6872
/// The connection was aborted (terminated) by the remote server.
73+
#[stable(feature = "rust1", since = "1.0.0")]
6974
ConnectionAborted,
7075
/// The network operation failed because it was not connected yet.
76+
#[stable(feature = "rust1", since = "1.0.0")]
7177
NotConnected,
78+
/// A socket address could not be bound because the address is already in
79+
/// use elsewhere.
80+
#[stable(feature = "rust1", since = "1.0.0")]
81+
AddrInUse,
82+
/// A nonexistent interface was requested or the requested address was not
83+
/// local.
84+
#[stable(feature = "rust1", since = "1.0.0")]
85+
AddrNotAvailable,
7286
/// The operation failed because a pipe was closed.
87+
#[stable(feature = "rust1", since = "1.0.0")]
7388
BrokenPipe,
74-
/// A file already existed with that name.
75-
PathAlreadyExists,
76-
/// No file exists at that location.
77-
PathDoesntExist,
78-
/// The path did not specify the type of file that this operation required.
79-
/// For example, attempting to copy a directory with the `fs::copy()`
80-
/// operation will fail with this error.
81-
MismatchedFileTypeForOperation,
82-
/// The operation temporarily failed (for example, because a signal was
83-
/// received), and retrying may succeed.
84-
ResourceUnavailable,
85-
/// A parameter was incorrect in a way that caused an I/O error not part of
86-
/// this list.
89+
/// An entity already exists, often a file.
90+
#[stable(feature = "rust1", since = "1.0.0")]
91+
AlreadyExists,
92+
/// The operation needs to block to complete, but the blocking operation was
93+
/// requested to not occur.
94+
#[stable(feature = "rust1", since = "1.0.0")]
95+
WouldBlock,
96+
/// A parameter was incorrect.
97+
#[stable(feature = "rust1", since = "1.0.0")]
8798
InvalidInput,
8899
/// The I/O operation's timeout expired, causing it to be canceled.
100+
#[stable(feature = "rust1", since = "1.0.0")]
89101
TimedOut,
90102
/// An error returned when an operation could not be completed because a
91103
/// call to `write` returned `Ok(0)`.
92104
///
93105
/// This typically means that an operation could only succeed if it wrote a
94106
/// particular number of bytes but only a smaller number of bytes could be
95107
/// written.
108+
#[stable(feature = "rust1", since = "1.0.0")]
96109
WriteZero,
97-
/// This operation was interrupted
110+
/// This operation was interrupted.
111+
///
112+
/// Interrupted operations can typically be retried.
113+
#[stable(feature = "rust1", since = "1.0.0")]
98114
Interrupted,
99115
/// Any I/O error not part of this list.
116+
#[stable(feature = "rust1", since = "1.0.0")]
100117
Other,
118+
119+
/// Any I/O error not part of this list.
120+
#[unstable(feature = "std_misc",
121+
reason = "better expressed through extensible enums that this \
122+
enum cannot be exhaustively matched against")]
123+
#[doc(hidden)]
124+
__Nonexhaustive,
101125
}
102126

103127
impl Error {
@@ -134,6 +158,19 @@ impl Error {
134158
Error { repr: Repr::Os(code) }
135159
}
136160

161+
/// Returns the OS error that this error represents (if any).
162+
///
163+
/// If this `Error` was constructed via `last_os_error` then this function
164+
/// will return `Some`, otherwise it will return `None`.
165+
#[unstable(feature = "io", reason = "function was just added and the return \
166+
type may become an abstract OS error")]
167+
pub fn raw_os_error(&self) -> Option<i32> {
168+
match self.repr {
169+
Repr::Os(i) => Some(i),
170+
Repr::Custom(..) => None,
171+
}
172+
}
173+
137174
/// Return the corresponding `ErrorKind` for this error.
138175
#[stable(feature = "rust1", since = "1.0.0")]
139176
pub fn kind(&self) -> ErrorKind {

branches/try/src/libstd/net/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ pub use self::ip::{Ipv4Addr, Ipv6Addr, Ipv6MulticastScope};
2525
pub use self::addr::{SocketAddr, SocketAddrV4, SocketAddrV6, ToSocketAddrs};
2626
pub use self::tcp::{TcpStream, TcpListener};
2727
pub use self::udp::UdpSocket;
28+
pub use self::parser::AddrParseError;
2829

2930
mod ip;
3031
mod addr;

branches/try/src/libstd/net/parser.rs

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -296,35 +296,40 @@ impl<'a> Parser<'a> {
296296
}
297297
}
298298

299+
#[stable(feature = "rust1", since = "1.0.0")]
299300
impl FromStr for Ipv4Addr {
300-
type Err = ParseError;
301-
fn from_str(s: &str) -> Result<Ipv4Addr, ParseError> {
301+
type Err = AddrParseError;
302+
fn from_str(s: &str) -> Result<Ipv4Addr, AddrParseError> {
302303
match Parser::new(s).read_till_eof(|p| p.read_ipv4_addr()) {
303304
Some(s) => Ok(s),
304-
None => Err(ParseError)
305+
None => Err(AddrParseError(()))
305306
}
306307
}
307308
}
308309

310+
#[stable(feature = "rust1", since = "1.0.0")]
309311
impl FromStr for Ipv6Addr {
310-
type Err = ParseError;
311-
fn from_str(s: &str) -> Result<Ipv6Addr, ParseError> {
312+
type Err = AddrParseError;
313+
fn from_str(s: &str) -> Result<Ipv6Addr, AddrParseError> {
312314
match Parser::new(s).read_till_eof(|p| p.read_ipv6_addr()) {
313315
Some(s) => Ok(s),
314-
None => Err(ParseError)
316+
None => Err(AddrParseError(()))
315317
}
316318
}
317319
}
318320

321+
#[stable(feature = "rust1", since = "1.0.0")]
319322
impl FromStr for SocketAddr {
320-
type Err = ParseError;
321-
fn from_str(s: &str) -> Result<SocketAddr, ParseError> {
323+
type Err = AddrParseError;
324+
fn from_str(s: &str) -> Result<SocketAddr, AddrParseError> {
322325
match Parser::new(s).read_till_eof(|p| p.read_socket_addr()) {
323326
Some(s) => Ok(s),
324-
None => Err(ParseError),
327+
None => Err(AddrParseError(())),
325328
}
326329
}
327330
}
328331

329-
#[derive(Debug, Clone, PartialEq, Copy)]
330-
pub struct ParseError;
332+
/// An error returned when parsing an IP address or a socket address.
333+
#[stable(feature = "rust1", since = "1.0.0")]
334+
#[derive(Debug, Clone, PartialEq)]
335+
pub struct AddrParseError(());

0 commit comments

Comments
 (0)