]> git.lizzy.rs Git - rust.git/commitdiff
Rollup merge of #23562 - steveklabnik:fix_book_numbers, r=alexcrichton
authorManish Goregaokar <manishsmail@gmail.com>
Sat, 21 Mar 2015 20:06:25 +0000 (01:36 +0530)
committerManish Goregaokar <manishsmail@gmail.com>
Sun, 22 Mar 2015 23:24:27 +0000 (04:54 +0530)
 Rustbook already does this.

124 files changed:
man/rustc.1
src/compiletest/header.rs
src/compiletest/procsrv.rs
src/compiletest/util.rs
src/libcollections/btree/map.rs
src/libcollections/fmt.rs
src/libcore/macros.rs
src/libcore/prelude.rs
src/libcore/result.rs
src/libcoretest/str.rs
src/liblog/lib.rs
src/librustc/README.md [new file with mode: 0644]
src/librustc/README.txt [deleted file]
src/librustc/middle/astencode.rs
src/librustc/middle/cfg/graphviz.rs
src/librustc/middle/infer/region_inference/graphviz.rs
src/librustc_back/fs.rs
src/librustc_borrowck/borrowck/gather_loans/mod.rs
src/librustc_resolve/lib.rs
src/librustc_resolve/resolve_imports.rs
src/librustc_trans/README.txt
src/librustc_trans/trans/_match.rs
src/librustc_trans/trans/base.rs
src/librustc_trans/trans/expr.rs
src/librustc_trans/trans/intrinsic.rs
src/librustc_typeck/check/upvar.rs
src/librustdoc/lib.rs
src/librustdoc/plugins.rs
src/libserialize/json.rs
src/libserialize/serialize.rs
src/libstd/collections/hash/map.rs
src/libstd/dynamic_lib.rs
src/libstd/env.rs
src/libstd/fs/mod.rs
src/libstd/io/cursor.rs
src/libstd/io/prelude.rs
src/libstd/net/addr.rs
src/libstd/num/mod.rs
src/libstd/old_io/buffered.rs
src/libstd/old_io/comm_adapters.rs
src/libstd/old_io/extensions.rs
src/libstd/old_io/fs.rs
src/libstd/old_io/mem.rs
src/libstd/old_io/mod.rs
src/libstd/old_io/net/pipe.rs
src/libstd/old_io/net/tcp.rs
src/libstd/old_io/pipe.rs
src/libstd/old_io/process.rs
src/libstd/old_io/result.rs
src/libstd/old_io/stdio.rs
src/libstd/old_io/tempfile.rs
src/libstd/old_io/test.rs
src/libstd/old_io/util.rs
src/libstd/old_path/mod.rs
src/libstd/old_path/posix.rs
src/libstd/old_path/windows.rs
src/libstd/os.rs
src/libstd/prelude/v1.rs
src/libstd/process.rs
src/libstd/rt/mod.rs
src/libstd/rt/unwind.rs
src/libstd/rt/util.rs
src/libstd/sync/mpsc/mod.rs
src/libstd/sys/common/helper_thread.rs
src/libstd/sys/common/thread_local.rs
src/libstd/sys/unix/backtrace.rs
src/libstd/sys/unix/fs.rs
src/libstd/sys/unix/helper_signal.rs
src/libstd/sys/unix/timer.rs
src/libstd/sys/windows/backtrace.rs
src/libstd/sys/windows/fs.rs
src/libstd/sys/windows/pipe.rs
src/libstd/sys/windows/process.rs
src/libstd/sys/windows/thread_local.rs
src/libstd/sys/windows/timer.rs
src/libstd/sys/windows/tty.rs
src/libstd/thread.rs
src/libsyntax/ext/deriving/encodable.rs
src/libsyntax/parse/lexer/mod.rs
src/libterm/terminfo/mod.rs
src/libtest/stats.rs
src/test/auxiliary/linkage-visibility.rs
src/test/bench/core-std.rs
src/test/bench/shootout-fasta-redux.rs
src/test/bench/shootout-fasta.rs
src/test/bench/shootout-k-nucleotide-pipes.rs
src/test/bench/shootout-mandelbrot.rs
src/test/bench/shootout-reverse-complement.rs
src/test/compile-fail-fulldeps/gated-macro-reexports.rs [new file with mode: 0644]
src/test/compile-fail/cannot-mutate-captured-non-mut-var.rs
src/test/compile-fail/gated-box-patterns.rs [new file with mode: 0644]
src/test/compile-fail/gated-box-syntax.rs [new file with mode: 0644]
src/test/compile-fail/gated-simd-ffi.rs [new file with mode: 0644]
src/test/compile-fail/issue-11374.rs
src/test/run-fail/rt-set-exit-status-panic2.rs
src/test/run-make/cannot-read-embedded-idents/create_and_compile.rs
src/test/run-make/extern-fn-reachable/main.rs
src/test/run-make/unicode-input/multiple_files.rs
src/test/run-make/unicode-input/span_length.rs
src/test/run-pass/backtrace-debuginfo.rs
src/test/run-pass/capturing-logging.rs
src/test/run-pass/colorful-write-macros.rs
src/test/run-pass/foreign-call-no-runtime.rs
src/test/run-pass/into-iterator-type-inference-shift.rs
src/test/run-pass/issue-13304.rs
src/test/run-pass/issue-14940.rs
src/test/run-pass/issue-16272.rs
src/test/run-pass/issue-17121.rs
src/test/run-pass/issue-20091.rs
src/test/run-pass/issue-20644.rs
src/test/run-pass/issue-20797.rs
src/test/run-pass/issue-23550.rs [new file with mode: 0644]
src/test/run-pass/issue22346.rs
src/test/run-pass/match-ref-unsized.rs [new file with mode: 0644]
src/test/run-pass/process-spawn-with-unicode-params.rs
src/test/run-pass/rename-directory.rs
src/test/run-pass/sigpipe-should-be-ignored.rs
src/test/run-pass/spawn2.rs
src/test/run-pass/stat.rs
src/test/run-pass/tcp-stress.rs
src/test/run-pass/tempfile.rs
src/test/run-pass/trait-coercion.rs
src/test/run-pass/unique-send-2.rs
src/test/run-pass/unit-like-struct-drop-run.rs

index 33ef3f9ee4acba4e3078a5a3afb8ac6ccf3849d5..b15829db431dfef89f5d7b6a4fb6217c98874b3b 100644 (file)
@@ -242,7 +242,7 @@ full debug info with variable and type information.
 \fBopt\-level\fR=\fIVAL\fR
 Optimize with possible levels 0\[en]3
 
-.SH ENVIRONMENT VARIABLES
+.SH ENVIRONMENT
 
 Some of these affect the output of the compiler, while others affect programs
 which link to the standard library.
index 6899fa13974e9e4282bafd0fda4021ec4223765e..29123173f5baec5dbf3fa9c3a61065f0b009c503 100644 (file)
@@ -163,6 +163,9 @@ pub fn is_test_ignored(config: &Config, testfile: &Path) -> bool {
     fn ignore_target(config: &Config) -> String {
         format!("ignore-{}", util::get_os(&config.target))
     }
+    fn ignore_architecture(config: &Config) -> String {
+        format!("ignore-{}", util::get_arch(&config.target))
+    }
     fn ignore_stage(config: &Config) -> String {
         format!("ignore-{}",
                 config.stage_id.split('-').next().unwrap())
@@ -226,6 +229,7 @@ fn ignore_lldb(config: &Config, line: &str) -> bool {
     let val = iter_header(testfile, &mut |ln| {
         !parse_name_directive(ln, "ignore-test") &&
         !parse_name_directive(ln, &ignore_target(config)) &&
+        !parse_name_directive(ln, &ignore_architecture(config)) &&
         !parse_name_directive(ln, &ignore_stage(config)) &&
         !(config.mode == common::Pretty && parse_name_directive(ln, "ignore-pretty")) &&
         !(config.target != config.host && parse_name_directive(ln, "ignore-cross-compile")) &&
index 56e37ca1093155175a1dcbc135ad0d74654f3307..ceed88b6236fd5f9a0f5c2bb588f1b49570bb126 100644 (file)
 
 #![allow(deprecated)] // for old path, for dynamic_lib
 
-use std::process::{ExitStatus, Command, Child, Output, Stdio};
-use std::io::prelude::*;
 use std::dynamic_lib::DynamicLibrary;
+use std::io::prelude::*;
+use std::old_path::Path;
+use std::process::{ExitStatus, Command, Child, Output, Stdio};
 
 fn add_target_env(cmd: &mut Command, lib_path: &str, aux_path: Option<&str>) {
     // Need to be sure to put both the lib_path and the aux path in the dylib
index 16e2806f72cecd2bdeef69af472fda23e4798311..2e11cf47d1e56fa2bf7c09e04457ca848cbe3ff1 100644 (file)
     ("openbsd", "openbsd"),
 ];
 
+const ARCH_TABLE: &'static [(&'static str, &'static str)] = &[
+    ("i386", "x86"),
+    ("i686", "x86"),
+    ("amd64", "x86_64"),
+    ("x86_64", "x86_64"),
+    ("sparc", "sparc"),
+    ("powerpc", "powerpc"),
+    ("arm64", "aarch64"),
+    ("arm", "arm"),
+    ("aarch64", "aarch64"),
+    ("mips", "mips"),
+    ("xcore", "xcore"),
+    ("msp430", "msp430"),
+    ("hexagon", "hexagon"),
+    ("s390x", "systemz"),
+];
+
 pub fn get_os(triple: &str) -> &'static str {
     for &(triple_os, os) in OS_TABLE {
         if triple.contains(triple_os) {
@@ -33,6 +50,14 @@ pub fn get_os(triple: &str) -> &'static str {
     }
     panic!("Cannot determine OS from triple");
 }
+pub fn get_arch(triple: &str) -> &'static str {
+    for &(triple_arch, arch) in ARCH_TABLE {
+        if triple.contains(triple_arch) {
+            return arch
+        }
+    }
+    panic!("Cannot determine Architecture from triple");
+}
 
 pub fn make_new_path(path: &str) -> String {
     assert!(cfg!(windows));
index c7e1e3c91766ef297d71fbad17905910d2530c61..a9e1ce8d7ce50db9a5c0b3c3a5c75b561c0ba754 100644 (file)
@@ -24,7 +24,7 @@
 use core::fmt::Debug;
 use core::hash::{Hash, Hasher};
 use core::iter::{Map, FromIterator, IntoIterator};
-use core::ops::{Index, IndexMut};
+use core::ops::{Index};
 use core::{iter, fmt, mem, usize};
 use Bound::{self, Included, Excluded, Unbounded};
 
@@ -925,15 +925,6 @@ fn index(&self, key: &Q) -> &V {
     }
 }
 
-#[stable(feature = "rust1", since = "1.0.0")]
-impl<K: Ord, Q: ?Sized, V> IndexMut<Q> for BTreeMap<K, V>
-    where K: Borrow<Q>, Q: Ord
-{
-    fn index_mut(&mut self, key: &Q) -> &mut V {
-        self.get_mut(key).expect("no entry found for key")
-    }
-}
-
 /// Genericises over how to get the correct type of iterator from the correct type
 /// of Node ownership.
 trait Traverse<N> {
index d2abb59ffabc582eb8f0cb67cd93bd62b068e4f5..3af7485b237efc9c14782f39b511890739c9e67a 100644 (file)
 //!
 //! ```
 //! # #![allow(unused_must_use)]
+//! use std::io::Write;
 //! let mut w = Vec::new();
 //! write!(&mut w, "Hello {}!", "world");
 //! ```
 //!
 //! ```
 //! use std::fmt;
-//! use std::old_io;
+//! use std::io::{self, Write};
 //!
 //! fmt::format(format_args!("this returns {}", "String"));
 //!
-//! let mut some_writer = old_io::stdout();
+//! let mut some_writer = io::stdout();
 //! write!(&mut some_writer, "{}", format_args!("print with a {}", "macro"));
 //!
 //! fn my_fmt_fn(args: fmt::Arguments) {
-//!     write!(&mut old_io::stdout(), "{}", args);
+//!     write!(&mut io::stdout(), "{}", args);
 //! }
 //! my_fmt_fn(format_args!("or a {} too", "function"));
 //! ```
index 6dcae9879a0d0fd5da3f30e61823e1e472153327..c647b037944aec0c401ac1fe14c618024f2effec 100644 (file)
@@ -176,6 +176,7 @@ macro_rules! try {
 ///
 /// ```
 /// # #![allow(unused_must_use)]
+/// use std::io::Write;
 ///
 /// let mut w = Vec::new();
 /// write!(&mut w, "test");
index c668fe80d14520420c6ebb4e1921ad96a98e559a..4bf7f85284cfe94148cef8507d7d80c415921bb0 100644 (file)
@@ -29,8 +29,6 @@
 pub use ops::{Drop, Fn, FnMut, FnOnce};
 
 // Reexported functions
-#[allow(deprecated)]
-pub use iter::range;
 pub use mem::drop;
 
 // Reexported types and traits
index a5b2fddfd5df61dc9d70cea7e11d0e8003ec6c6f..bc8d53e2a5765efc6b7737b00d0e6acb3776eed0 100644 (file)
@@ -78,7 +78,7 @@
 //! let bad_result: Result<int, int> = bad_result.or_else(|i| Ok(11));
 //!
 //! // Consume the result and return the contents with `unwrap`.
-//! let final_awesome_result = good_result.ok().unwrap();
+//! let final_awesome_result = good_result.unwrap();
 //! ```
 //!
 //! # Results must be used
 //! something like this:
 //!
 //! ```{.ignore}
-//! use std::old_io::{File, Open, Write};
+//! use std::old_io::*;
+//! use std::old_path::Path;
 //!
 //! let mut file = File::open_mode(&Path::new("valuable_data.txt"), Open, Write);
 //! // If `write_line` errors, then we'll never know, because the return
 //! a marginally useful message indicating why:
 //!
 //! ```{.no_run}
-//! use std::old_io::{File, Open, Write};
+//! use std::old_io::*;
+//! use std::old_path::Path;
 //!
 //! let mut file = File::open_mode(&Path::new("valuable_data.txt"), Open, Write);
 //! file.write_line("important message").ok().expect("failed to write message");
 //! You might also simply assert success:
 //!
 //! ```{.no_run}
-//! # use std::old_io::{File, Open, Write};
+//! # use std::old_io::*;
+//! # use std::old_path::Path;
 //!
 //! # let mut file = File::open_mode(&Path::new("valuable_data.txt"), Open, Write);
 //! assert!(file.write_line("important message").is_ok());
 //! Or propagate the error up the call stack with `try!`:
 //!
 //! ```
-//! # use std::old_io::{File, Open, Write, IoError};
+//! # use std::old_io::*;
+//! # use std::old_path::Path;
 //! fn write_message() -> Result<(), IoError> {
 //!     let mut file = File::open_mode(&Path::new("valuable_data.txt"), Open, Write);
 //!     try!(file.write_line("important message"));
 //! It replaces this:
 //!
 //! ```
-//! use std::old_io::{File, Open, Write, IoError};
+//! use std::old_io::*;
+//! use std::old_path::Path;
 //!
 //! struct Info {
 //!     name: String,
 //! With this:
 //!
 //! ```
-//! use std::old_io::{File, Open, Write, IoError};
+//! use std::old_io::*;
+//! use std::old_path::Path;
 //!
 //! struct Info {
 //!     name: String,
@@ -446,7 +452,7 @@ pub fn as_mut_slice(&mut self) -> &mut [T] {
     /// ignoring I/O and parse errors:
     ///
     /// ```
-    /// use std::old_io::IoResult;
+    /// use std::old_io::*;
     ///
     /// let mut buffer: &[u8] = b"1\n2\n3\n4\n";
     /// let mut buffer = &mut buffer;
@@ -460,7 +466,7 @@ pub fn as_mut_slice(&mut self) -> &mut [T] {
     ///         line.trim_right().parse::<int>().unwrap_or(0)
     ///     });
     ///     // Add the value if there were no errors, otherwise add 0
-    ///     sum += val.ok().unwrap_or(0);
+    ///     sum += val.unwrap_or(0);
     /// }
     ///
     /// assert!(sum == 10);
index a89d3380707051cbdf8613a9484464f82699d133..cac78363dd53b8e83144b68bad4a38e2925d62a2 100644 (file)
@@ -35,7 +35,7 @@ fn test_bool_from_str() {
 fn check_contains_all_substrings(s: &str) {
     assert!(s.contains(""));
     for i in 0..s.len() {
-        for j in range(i+1, s.len() + 1) {
+        for j in i+1..s.len() + 1 {
             assert!(s.contains(&s[i..j]));
         }
     }
index c634a46888e56e5d5529a0d061a244f3030849de..4537fc763c9536caa7a6ba3ba6312cdff8b71ef4 100644 (file)
 use std::io::prelude::*;
 use std::mem;
 use std::env;
-use std::ptr;
 use std::rt;
 use std::slice;
-use std::sync::{Once, ONCE_INIT};
+use std::sync::{Once, ONCE_INIT, StaticMutex, MUTEX_INIT};
 
 use directive::LOG_LEVEL_NAMES;
 
 /// The default logging level of a crate if no other is specified.
 const DEFAULT_LOG_LEVEL: u32 = 1;
 
+static LOCK: StaticMutex = MUTEX_INIT;
+
 /// An unsafe constant that is the maximum logging level of any module
 /// specified. This is the first line of defense to determining whether a
 /// logging statement should be run.
@@ -286,9 +287,18 @@ fn drop(&mut self) {
 pub fn log(level: u32, loc: &'static LogLocation, args: fmt::Arguments) {
     // Test the literal string from args against the current filter, if there
     // is one.
-    match unsafe { FILTER.as_ref() } {
-        Some(filter) if !args.to_string().contains(&filter[..]) => return,
-        _ => {}
+    unsafe {
+        let _g = LOCK.lock();
+        match FILTER as uint {
+            0 => {}
+            1 => panic!("cannot log after main thread has exited"),
+            n => {
+                let filter = mem::transmute::<_, &String>(n);
+                if !args.to_string().contains(&filter[..]) {
+                    return
+                }
+            }
+        }
     }
 
     // Completely remove the local logger from TLS in case anyone attempts to
@@ -370,9 +380,15 @@ pub fn mod_enabled(level: u32, module: &str) -> bool {
 
     // This assertion should never get tripped unless we're in an at_exit
     // handler after logging has been torn down and a logging attempt was made.
-    assert!(unsafe { !DIRECTIVES.is_null() });
 
-    enabled(level, module, unsafe { (*DIRECTIVES).iter() })
+    let _g = LOCK.lock();
+    unsafe {
+        assert!(DIRECTIVES as uint != 0);
+        assert!(DIRECTIVES as uint != 1,
+                "cannot log after the main thread has exited");
+
+        enabled(level, module, (*DIRECTIVES).iter())
+    }
 }
 
 fn enabled(level: u32,
@@ -428,14 +444,14 @@ fn init() {
 
         // Schedule the cleanup for the globals for when the runtime exits.
         rt::at_exit(move || {
+            let _g = LOCK.lock();
             assert!(!DIRECTIVES.is_null());
-            let _directives: Box<Vec<directive::LogDirective>> =
-                Box::from_raw(DIRECTIVES);
-            DIRECTIVES = ptr::null_mut();
+            let _directives = Box::from_raw(DIRECTIVES);
+            DIRECTIVES = 1 as *mut _;
 
             if !FILTER.is_null() {
-                let _filter: Box<String> = Box::from_raw(FILTER);
-                FILTER = 0 as *mut _;
+                let _filter = Box::from_raw(FILTER);
+                FILTER = 1 as *mut _;
             }
         });
     }
diff --git a/src/librustc/README.md b/src/librustc/README.md
new file mode 100644 (file)
index 0000000..31812e1
--- /dev/null
@@ -0,0 +1,128 @@
+An informal guide to reading and working on the rustc compiler.
+==================================================================
+
+If you wish to expand on this document, or have a more experienced
+Rust contributor add anything else to it, please get in touch:
+
+* http://internals.rust-lang.org/
+* https://chat.mibbit.com/?server=irc.mozilla.org&channel=%23rust
+
+or file a bug:
+
+https://github.com/rust-lang/rust/issues
+
+Your concerns are probably the same as someone else's.
+
+The crates of rustc
+===================
+
+Rustc consists of a number of crates, including `libsyntax`,
+`librustc`, `librustc_back`, `librustc_trans`, and `librustc_driver`
+(the names and divisions are not set in stone and may change;
+in general, a finer-grained division of crates is preferable):
+
+- `libsyntax` contains those things concerned purely with syntax â€“
+  that is, the AST, parser, pretty-printer, lexer, macro expander, and
+  utilities for traversing ASTs â€“ are in a separate crate called
+  "syntax", whose files are in `./../libsyntax`, where `.` is the
+  current directory (that is, the parent directory of front/, middle/,
+  back/, and so on).
+
+- `librustc` (the current directory) contains the high-level analysis
+  passes, such as the type checker, borrow checker, and so forth.
+  It is the heart of the compiler.
+
+- `librustc_back` contains some very low-level details that are
+  specific to different LLVM targets and so forth.
+
+- `librustc_trans` contains the code to convert from Rust IR into LLVM
+  IR, and then from LLVM IR into machine code, as well as the main
+  driver that orchestrates all the other passes and various other bits
+  of miscellany. In general it contains code that runs towards the
+  end of the compilation process.
+
+- `librustc_driver` invokes the compiler from `libsyntax`, then the
+  analysis phases from `librustc`, and finally the lowering and
+  codegen passes from `librustc_trans`.
+
+Roughly speaking the "order" of the three crates is as follows:
+
+    libsyntax -> librustc -> librustc_trans
+    |                                     |
+    +-----------------+-------------------+
+                      |
+              librustc_driver
+
+
+Modules in the rustc crate
+==========================
+
+The rustc crate itself consists of the following submodules
+(mostly, but not entirely, in their own directories):
+
+- session: options and data that pertain to the compilation session as
+  a whole
+- middle: middle-end: name resolution, typechecking, LLVM code
+  generation
+- metadata: encoder and decoder for data required by separate
+  compilation
+- plugin: infrastructure for compiler plugins
+- lint: infrastructure for compiler warnings
+- util: ubiquitous types and helper functions
+- lib: bindings to LLVM
+
+The entry-point for the compiler is main() in the librustc_trans
+crate.
+
+The 3 central data structures:
+------------------------------
+
+1. `./../libsyntax/ast.rs` defines the AST. The AST is treated as
+   immutable after parsing, but it depends on mutable context data
+   structures (mainly hash maps) to give it meaning.
+
+   - Many â€“ though not all â€“ nodes within this data structure are
+     wrapped in the type `spanned<T>`, meaning that the front-end has
+     marked the input coordinates of that node. The member `node` is
+     the data itself, the member `span` is the input location (file,
+     line, column; both low and high).
+
+   - Many other nodes within this data structure carry a
+     `def_id`. These nodes represent the 'target' of some name
+     reference elsewhere in the tree. When the AST is resolved, by
+     `middle/resolve.rs`, all names wind up acquiring a def that they
+     point to. So anything that can be pointed-to by a name winds
+     up with a `def_id`.
+
+2. `middle/ty.rs` defines the datatype `sty`. This is the type that
+   represents types after they have been resolved and normalized by
+   the middle-end. The typeck phase converts every ast type to a
+   `ty::sty`, and the latter is used to drive later phases of
+   compilation. Most variants in the `ast::ty` tag have a
+   corresponding variant in the `ty::sty` tag.
+
+3. `./../librustc_llvm/lib.rs` defines the exported types
+   `ValueRef`, `TypeRef`, `BasicBlockRef`, and several others.
+   Each of these is an opaque pointer to an LLVM type,
+   manipulated through the `lib::llvm` interface.
+
+
+Control and information flow within the compiler:
+-------------------------------------------------
+
+- main() in lib.rs assumes control on startup. Options are
+  parsed, platform is detected, etc.
+
+- `./../libsyntax/parse/parser.rs` parses the input files and produces
+  an AST that represents the input crate.
+
+- Multiple middle-end passes (`middle/resolve.rs`, `middle/typeck.rs`)
+  analyze the semantics of the resulting AST. Each pass generates new
+  information about the AST and stores it in various environment data
+  structures. The driver passes environments to each compiler pass
+  that needs to refer to them.
+
+- Finally, the `trans` module in `librustc_trans` translates the Rust
+  AST to LLVM bitcode in a type-directed way. When it's finished
+  synthesizing LLVM values, rustc asks LLVM to write them out in some
+  form (`.bc`, `.o`) and possibly run the system linker.
diff --git a/src/librustc/README.txt b/src/librustc/README.txt
deleted file mode 100644 (file)
index 9b36476..0000000
+++ /dev/null
@@ -1,124 +0,0 @@
-An informal guide to reading and working on the rustc compiler.
-==================================================================
-
-If you wish to expand on this document, or have a more experienced
-Rust contributor add anything else to it, please get in touch:
-
-* http://internals.rust-lang.org/
-* https://chat.mibbit.com/?server=irc.mozilla.org&channel=%23rust
-
-or file a bug:
-
-https://github.com/rust-lang/rust/issues
-
-Your concerns are probably the same as someone else's.
-
-The crates of rustc
-===================
-
-Rustc consists of four crates altogether: `libsyntax`, `librustc`,
-`librustc_back`, and `librustc_trans` (the names and divisions are not
-set in stone and may change; in general, a finer-grained division of
-crates is preferable):
-
-- `libsyntax` contains those things concerned purely with syntax --
-  that is, the AST, parser, pretty-printer, lexer, macro expander, and
-  utilities for traversing ASTs -- are in a separate crate called
-  "syntax", whose files are in ./../libsyntax, where . is the current
-  directory (that is, the parent directory of front/, middle/, back/,
-  and so on).
-
-- `librustc` (the current directory) contains the high-level analysis
-  passes, such as the type checker, borrow checker, and so forth.
-  It is the heart of the compiler.
-
-- `librustc_back` contains some very low-level details that are
-  specific to different LLVM targets and so forth.
-
-- `librustc_trans` contains the code to convert from Rust IR into LLVM
-  IR, and then from LLVM IR into machine code, as well as the main
-  driver that orchestrates all the other passes and various other bits
-  of miscellany. In general it contains code that runs towards the
-  end of the compilation process.
-
-Roughly speaking the "order" of the three crates is as follows:
-
-    libsyntax -> librustc -> librustc_trans
-    |                                     |
-    +-----------------+-------------------+
-                      |
-             librustc_trans/driver
-
-Here the role of `librustc_trans/driver` is to invoke the compiler
-from libsyntax, then the analysis phases from librustc, and finally
-the lowering and codegen passes from librustc_trans.
-
-Modules in the rustc crate
-==========================
-
-The rustc crate itself consists of the following subdirectories
-(mostly, but not entirely, in their own directories):
-
-session  - options and data that pertain to the compilation session as a whole
-middle   - middle-end: name resolution, typechecking, LLVM code
-                  generation
-metadata - encoder and decoder for data required by
-                    separate compilation
-util     - ubiquitous types and helper functions
-lib      - bindings to LLVM
-
-The entry-point for the compiler is main() in the librustc_trans
-crate.
-
-The 3 central data structures:
-------------------------------
-
-#1: ./../libsyntax/ast.rs defines the AST. The AST is treated as immutable
-    after parsing, but it depends on mutable context data structures
-    (mainly hash maps) to give it meaning.
-
-      - Many -- though not all -- nodes within this data structure are
-        wrapped in the type `spanned<T>`, meaning that the front-end has
-        marked the input coordinates of that node. The member .node is
-        the data itself, the member .span is the input location (file,
-        line, column; both low and high).
-
-      - Many other nodes within this data structure carry a
-        def_id. These nodes represent the 'target' of some name
-        reference elsewhere in the tree. When the AST is resolved, by
-        middle/resolve.rs, all names wind up acquiring a def that they
-        point to. So anything that can be pointed-to by a name winds
-        up with a def_id.
-
-#2: middle/ty.rs defines the datatype sty.  This is the type that
-    represents types after they have been resolved and normalized by
-    the middle-end. The typeck phase converts every ast type to a
-    ty::sty, and the latter is used to drive later phases of
-    compilation.  Most variants in the ast::ty tag have a
-    corresponding variant in the ty::sty tag.
-
-#3: lib/llvm.rs (in librustc_trans) defines the exported types
-    ValueRef, TypeRef, BasicBlockRef, and several others. Each of
-    these is an opaque pointer to an LLVM type, manipulated through
-    the lib::llvm interface.
-
-
-Control and information flow within the compiler:
--------------------------------------------------
-
-- main() in lib.rs assumes control on startup. Options are
-  parsed, platform is detected, etc.
-
-- ./../libsyntax/parse/parser.rs parses the input files and produces an AST
-  that represents the input crate.
-
-- Multiple middle-end passes (middle/resolve.rs, middle/typeck.rs)
-  analyze the semantics of the resulting AST. Each pass generates new
-  information about the AST and stores it in various environment data
-  structures. The driver passes environments to each compiler pass
-  that needs to refer to them.
-
-- Finally, the `trans` module in `librustc_trans` translates the Rust
-  AST to LLVM bitcode in a type-directed way. When it's finished
-  synthesizing LLVM values, rustc asks LLVM to write them out in some
-  form (.bc, .o) and possibly run the system linker.
index 8b2a94025f337441a3fa44b86d7e9d4dd549b228..bffcb93bc6d06382d7d5d20f71be447d7291d1cf 100644 (file)
@@ -43,6 +43,7 @@
 use std::io::prelude::*;
 use std::num::FromPrimitive;
 use std::rc::Rc;
+use std::fmt::Debug;
 
 use rbml::reader;
 use rbml::writer::Encoder;
@@ -313,9 +314,11 @@ trait def_id_encoder_helpers {
     fn emit_def_id(&mut self, did: ast::DefId);
 }
 
-impl<S:serialize::Encoder> def_id_encoder_helpers for S {
+impl<S:serialize::Encoder> def_id_encoder_helpers for S
+    where <S as serialize::serialize::Encoder>::Error: Debug
+{
     fn emit_def_id(&mut self, did: ast::DefId) {
-        did.encode(self).ok().unwrap()
+        did.encode(self).unwrap()
     }
 }
 
@@ -325,15 +328,18 @@ fn read_def_id_nodcx(&mut self,
                          cdata: &cstore::crate_metadata) -> ast::DefId;
 }
 
-impl<D:serialize::Decoder> def_id_decoder_helpers for D {
+impl<D:serialize::Decoder> def_id_decoder_helpers for D
+    where <D as serialize::serialize::Decoder>::Error: Debug
+{
     fn read_def_id(&mut self, dcx: &DecodeContext) -> ast::DefId {
-        let did: ast::DefId = Decodable::decode(self).ok().unwrap();
+        let did: ast::DefId = Decodable::decode(self).unwrap();
         did.tr(dcx)
     }
 
     fn read_def_id_nodcx(&mut self,
-                         cdata: &cstore::crate_metadata) -> ast::DefId {
-        let did: ast::DefId = Decodable::decode(self).ok().unwrap();
+                         cdata: &cstore::crate_metadata)
+                         -> ast::DefId {
+        let did: ast::DefId = Decodable::decode(self).unwrap();
         decoder::translate_def_id(cdata, did)
     }
 }
@@ -1784,7 +1790,7 @@ fn read_unsize_kind<'b, 'c>(&mut self, dcx: &DecodeContext<'b, 'c, 'tcx>)
     fn read_closure_kind<'b, 'c>(&mut self, _dcx: &DecodeContext<'b, 'c, 'tcx>)
                                  -> ty::ClosureKind
     {
-        Decodable::decode(self).ok().unwrap()
+        Decodable::decode(self).unwrap()
     }
 
     fn read_closure_ty<'b, 'c>(&mut self, dcx: &DecodeContext<'b, 'c, 'tcx>)
index ac6524dad805792385953260aac1d9c850ed84ec..3a6966ab112905bee06966be07b48ff0c911175c 100644 (file)
@@ -54,10 +54,10 @@ fn replace_newline_with_backslash_l(s: String) -> String {
 }
 
 impl<'a, 'ast> dot::Labeller<'a, Node<'a>, Edge<'a>> for LabelledCFG<'a, 'ast> {
-    fn graph_id(&'a self) -> dot::Id<'a> { dot::Id::new(&self.name[..]).ok().unwrap() }
+    fn graph_id(&'a self) -> dot::Id<'a> { dot::Id::new(&self.name[..]).unwrap() }
 
     fn node_id(&'a self, &(i,_): &Node<'a>) -> dot::Id<'a> {
-        dot::Id::new(format!("N{}", i.node_id())).ok().unwrap()
+        dot::Id::new(format!("N{}", i.node_id())).unwrap()
     }
 
     fn node_label(&'a self, &(i, n): &Node<'a>) -> dot::LabelText<'a> {
index 6211fde79198af387731e8c3840abedef50a42b3..5be3310926c8764efa6ca14d2bc42a43070428e3 100644 (file)
@@ -69,13 +69,13 @@ pub fn maybe_print_constraints_for<'a, 'tcx>(region_vars: &RegionVarBindings<'a,
         return;
     }
 
-    let requested_output = env::var("RUST_REGION_GRAPH").ok();
+    let requested_output = env::var("RUST_REGION_GRAPH");
     debug!("requested_output: {:?} requested_node: {:?}",
            requested_output, requested_node);
 
     let output_path = {
         let output_template = match requested_output {
-            Some(ref s) if &**s == "help" => {
+            Ok(ref s) if &**s == "help" => {
                 static PRINTED_YET: AtomicBool = ATOMIC_BOOL_INIT;
                 if !PRINTED_YET.load(Ordering::SeqCst) {
                     print_help_message();
@@ -84,8 +84,8 @@ pub fn maybe_print_constraints_for<'a, 'tcx>(region_vars: &RegionVarBindings<'a,
                 return;
             }
 
-            Some(other_path) => other_path,
-            None => "/tmp/constraints.node%.dot".to_string(),
+            Ok(other_path) => other_path,
+            Err(_) => "/tmp/constraints.node%.dot".to_string(),
         };
 
         if output_template.len() == 0 {
@@ -171,7 +171,7 @@ fn new(tcx: &'a ty::ctxt<'tcx>,
 
 impl<'a, 'tcx> dot::Labeller<'a, Node, Edge> for ConstraintGraph<'a, 'tcx> {
     fn graph_id(&self) -> dot::Id {
-        dot::Id::new(&*self.graph_name).ok().unwrap()
+        dot::Id::new(&*self.graph_name).unwrap()
     }
     fn node_id(&self, n: &Node) -> dot::Id {
         let node_id = match self.node_ids.get(n) {
index 6a6502800f683e17bec25099fd490f4683f36ca6..c29cbb352a321ce44bc2a5b911474fbf4787eff1 100644 (file)
@@ -9,7 +9,7 @@
 // except according to those terms.
 
 use std::io;
-#[allow(deprecated)] use std::old_path;
+#[allow(deprecated)] use std::old_path::{self, GenericPath};
 #[allow(deprecated)] use std::old_io;
 use std::path::{Path, PathBuf};
 
@@ -72,6 +72,7 @@ mod test {
     use std::old_io::fs::{File, symlink, mkdir, mkdir_recursive};
     use super::old_realpath as realpath;
     use std::old_io::TempDir;
+    use std::old_path::{Path, GenericPath};
 
     #[test]
     fn realpath_works() {
index d51ad6e0c97b5f3b9a44b73454add2b96f471eae..7d77eb23b6ed01c5f961e1aed739e48c92b2f5c1 100644 (file)
@@ -491,7 +491,7 @@ fn visit_expr(&mut self, ex: &Expr) {
         if let ast::ExprAddrOf(mutbl, ref base) = ex.node {
             let param_env = ty::empty_parameter_environment(self.bccx.tcx);
             let mc = mc::MemCategorizationContext::new(&param_env);
-            let base_cmt = mc.cat_expr(&**base).ok().unwrap();
+            let base_cmt = mc.cat_expr(&**base).unwrap();
             let borrow_kind = ty::BorrowKind::from_mutbl(mutbl);
             // Check that we don't allow borrows of unsafe static items.
             if check_aliasability(self.bccx, ex.span, euv::AddrOf,
index b619c6a77d009597eef5b2f806a9ac4d0722d566..566af2590e6c07cd0ec1a256856951ee36478222 100644 (file)
@@ -900,7 +900,7 @@ fn record_import_use(&mut self, import_id: NodeId, name: Name) {
             return;
         }
         if self.glob_map.contains_key(&import_id) {
-            self.glob_map[import_id].insert(name);
+            self.glob_map.get_mut(&import_id).unwrap().insert(name);
             return;
         }
 
index 737ec71cab3da09273b69f94d3653d37674e91eb..46451019760dd478aa179449473532a32d15fe63 100644 (file)
@@ -603,7 +603,7 @@ fn get_binding(this: &mut Resolver,
 
         // We've successfully resolved the import. Write the results in.
         let mut import_resolutions = module_.import_resolutions.borrow_mut();
-        let import_resolution = &mut (*import_resolutions)[target];
+        let import_resolution = import_resolutions.get_mut(&target).unwrap();
 
         {
             let mut check_and_write_import = |namespace, result: &_, used_public: &mut bool| {
index 3904db4433c892a69bffc712ea2d01afa73788c0..1f416d5404d2778d0fdea4768371232068e2bae8 100644 (file)
@@ -1 +1 @@
-See the README.txt in ../librustc.
+See the README.md in ../librustc.
index 44f6d1bfd0b07fa1a5378096530191e45647a488..c08d3b2be53dd02645b41ba779d1450ffa5f05c8 100644 (file)
@@ -326,7 +326,7 @@ pub enum OptResult<'blk, 'tcx: 'blk> {
     LowerBound(Result<'blk, 'tcx>)
 }
 
-#[derive(Clone, Copy)]
+#[derive(Clone, Copy, PartialEq)]
 pub enum TransBindingMode {
     TrByCopy(/* llbinding */ ValueRef),
     TrByMove,
@@ -1017,9 +1017,14 @@ fn compile_submatch<'a, 'p, 'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
         None => {
             let data = &m[0].data;
             for &(ref ident, ref value_ptr) in &m[0].bound_ptrs {
-                let llmatch = data.bindings_map[*ident].llmatch;
-                call_lifetime_start(bcx, llmatch);
-                Store(bcx, *value_ptr, llmatch);
+                let binfo = data.bindings_map[*ident];
+                call_lifetime_start(bcx, binfo.llmatch);
+                if binfo.trmode == TrByRef && type_is_fat_ptr(bcx.tcx(), binfo.ty) {
+                    expr::copy_fat_ptr(bcx, *value_ptr, binfo.llmatch);
+                }
+                else {
+                    Store(bcx, *value_ptr, binfo.llmatch);
+                }
             }
             match data.arm.guard {
                 Some(ref guard_expr) => {
@@ -1087,7 +1092,6 @@ fn compile_submatch_continue<'a, 'p, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
             _ => None
         }
     };
-
     match adt_vals {
         Some(field_vals) => {
             let pats = enter_match(bcx, dm, m, col, val, |pats|
@@ -1694,8 +1698,14 @@ fn bind_irrefutable_pat<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
 
                             ast::BindByRef(_) => {
                                 // By ref binding: the value of the variable
-                                // is the pointer `val` itself.
-                                Store(bcx, val, llval);
+                                // is the pointer `val` itself or fat pointer referenced by `val`
+                                if type_is_fat_ptr(bcx.tcx(), ty) {
+                                    expr::copy_fat_ptr(bcx, val, llval);
+                                }
+                                else {
+                                    Store(bcx, val, llval);
+                                }
+
                                 bcx
                             }
                         }
index f584de7c47f3b88a22befaa1328e41c4d56053bb..ebd92faaf0f5328dda42d28c11fca41a6b1199ef 100644 (file)
@@ -983,56 +983,72 @@ pub fn load_if_immediate<'blk, 'tcx>(cx: Block<'blk, 'tcx>,
 /// gives us better information about what we are loading.
 pub fn load_ty<'blk, 'tcx>(cx: Block<'blk, 'tcx>,
                            ptr: ValueRef, t: Ty<'tcx>) -> ValueRef {
-    if type_is_zero_size(cx.ccx(), t) {
-        C_undef(type_of::type_of(cx.ccx(), t))
-    } else if type_is_immediate(cx.ccx(), t) && type_of::type_of(cx.ccx(), t).is_aggregate() {
-        // We want to pass small aggregates as immediate values, but using an aggregate LLVM type
-        // for this leads to bad optimizations, so its arg type is an appropriately sized integer
-        // and we have to convert it
-        Load(cx, BitCast(cx, ptr, type_of::arg_type_of(cx.ccx(), t).ptr_to()))
-    } else {
-        unsafe {
-            let global = llvm::LLVMIsAGlobalVariable(ptr);
-            if !global.is_null() && llvm::LLVMIsGlobalConstant(global) == llvm::True {
-                let val = llvm::LLVMGetInitializer(global);
-                if !val.is_null() {
-                    // This could go into its own function, for DRY.
-                    // (something like "pre-store packing/post-load unpacking")
-                    if ty::type_is_bool(t) {
-                        return Trunc(cx, val, Type::i1(cx.ccx()));
-                    } else {
-                        return val;
-                    }
-                }
+    if cx.unreachable.get() || type_is_zero_size(cx.ccx(), t) {
+        return C_undef(type_of::type_of(cx.ccx(), t));
+    }
+
+    let ptr = to_arg_ty_ptr(cx, ptr, t);
+
+    if type_is_immediate(cx.ccx(), t) && type_of::type_of(cx.ccx(), t).is_aggregate() {
+        return Load(cx, ptr);
+    }
+
+    unsafe {
+        let global = llvm::LLVMIsAGlobalVariable(ptr);
+        if !global.is_null() && llvm::LLVMIsGlobalConstant(global) == llvm::True {
+            let val = llvm::LLVMGetInitializer(global);
+            if !val.is_null() {
+                return from_arg_ty(cx, val, t);
             }
         }
-        if ty::type_is_bool(t) {
-            Trunc(cx, LoadRangeAssert(cx, ptr, 0, 2, llvm::False), Type::i1(cx.ccx()))
-        } else if ty::type_is_char(t) {
-            // a char is a Unicode codepoint, and so takes values from 0
-            // to 0x10FFFF inclusive only.
-            LoadRangeAssert(cx, ptr, 0, 0x10FFFF + 1, llvm::False)
-        } else if (ty::type_is_region_ptr(t) || ty::type_is_unique(t))
-                  && !common::type_is_fat_ptr(cx.tcx(), t) {
-            LoadNonNull(cx, ptr)
-        } else {
-            Load(cx, ptr)
-        }
     }
+
+    let val =  if ty::type_is_bool(t) {
+        LoadRangeAssert(cx, ptr, 0, 2, llvm::False)
+    } else if ty::type_is_char(t) {
+        // a char is a Unicode codepoint, and so takes values from 0
+        // to 0x10FFFF inclusive only.
+        LoadRangeAssert(cx, ptr, 0, 0x10FFFF + 1, llvm::False)
+    } else if (ty::type_is_region_ptr(t) || ty::type_is_unique(t))
+        && !common::type_is_fat_ptr(cx.tcx(), t) {
+            LoadNonNull(cx, ptr)
+    } else {
+        Load(cx, ptr)
+    };
+
+    from_arg_ty(cx, val, t)
 }
 
 /// Helper for storing values in memory. Does the necessary conversion if the in-memory type
 /// differs from the type used for SSA values.
 pub fn store_ty<'blk, 'tcx>(cx: Block<'blk, 'tcx>, v: ValueRef, dst: ValueRef, t: Ty<'tcx>) {
-    if ty::type_is_bool(t) {
-        Store(cx, ZExt(cx, v, Type::i8(cx.ccx())), dst);
-    } else if type_is_immediate(cx.ccx(), t) && type_of::type_of(cx.ccx(), t).is_aggregate() {
+    Store(cx, to_arg_ty(cx, v, t), to_arg_ty_ptr(cx, dst, t));
+}
+
+pub fn to_arg_ty(bcx: Block, val: ValueRef, ty: Ty) -> ValueRef {
+    if ty::type_is_bool(ty) {
+        ZExt(bcx, val, Type::i8(bcx.ccx()))
+    } else {
+        val
+    }
+}
+
+pub fn from_arg_ty(bcx: Block, val: ValueRef, ty: Ty) -> ValueRef {
+    if ty::type_is_bool(ty) {
+        Trunc(bcx, val, Type::i1(bcx.ccx()))
+    } else {
+        val
+    }
+}
+
+pub fn to_arg_ty_ptr<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, ptr: ValueRef, ty: Ty<'tcx>) -> ValueRef {
+    if type_is_immediate(bcx.ccx(), ty) && type_of::type_of(bcx.ccx(), ty).is_aggregate() {
         // We want to pass small aggregates as immediate values, but using an aggregate LLVM type
         // for this leads to bad optimizations, so its arg type is an appropriately sized integer
         // and we have to convert it
-        Store(cx, v, BitCast(cx, dst, type_of::arg_type_of(cx.ccx(), t).ptr_to()));
+        BitCast(bcx, ptr, type_of::arg_type_of(bcx.ccx(), ty).ptr_to())
     } else {
-        Store(cx, v, dst);
+        ptr
     }
 }
 
index c316308c618bcb42a12ec9646e99ffd7d1663ab8..4653ef2980a78e6db183b24f76aa7d8c46086fa9 100644 (file)
@@ -285,6 +285,11 @@ pub fn get_dataptr(bcx: Block, fat_ptr: ValueRef) -> ValueRef {
     GEPi(bcx, fat_ptr, &[0, abi::FAT_PTR_ADDR])
 }
 
+pub fn copy_fat_ptr(bcx: Block, src_ptr: ValueRef, dst_ptr: ValueRef) {
+    Store(bcx, Load(bcx, get_dataptr(bcx, src_ptr)), get_dataptr(bcx, dst_ptr));
+    Store(bcx, Load(bcx, get_len(bcx, src_ptr)), get_len(bcx, dst_ptr));
+}
+
 // Retrieve the information we are losing (making dynamic) in an unsizing
 // adjustment.
 //
index 69ca9a5e81cbc81b933e4ac5ed62022cdb261787..d158cfa7b88765b77f12dba0808328ebd9ef630b 100644 (file)
@@ -446,10 +446,15 @@ pub fn trans_intrinsic_call<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
                              call_debug_location)
         }
         (_, "volatile_load") => {
-            VolatileLoad(bcx, llargs[0])
+            let tp_ty = *substs.types.get(FnSpace, 0);
+            let ptr = to_arg_ty_ptr(bcx, llargs[0], tp_ty);
+            from_arg_ty(bcx, VolatileLoad(bcx, ptr), tp_ty)
         },
         (_, "volatile_store") => {
-            VolatileStore(bcx, llargs[1], llargs[0]);
+            let tp_ty = *substs.types.get(FnSpace, 0);
+            let ptr = to_arg_ty_ptr(bcx, llargs[0], tp_ty);
+            let val = to_arg_ty(bcx, llargs[1], tp_ty);
+            VolatileStore(bcx, val, ptr);
             C_nil(ccx)
         },
 
@@ -709,8 +714,11 @@ pub fn trans_intrinsic_call<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
                             llvm::SequentiallyConsistent
                     };
 
-                    let res = AtomicCmpXchg(bcx, llargs[0], llargs[1],
-                                            llargs[2], order,
+                    let tp_ty = *substs.types.get(FnSpace, 0);
+                    let ptr = to_arg_ty_ptr(bcx, llargs[0], tp_ty);
+                    let cmp = to_arg_ty(bcx, llargs[1], tp_ty);
+                    let src = to_arg_ty(bcx, llargs[2], tp_ty);
+                    let res = AtomicCmpXchg(bcx, ptr, cmp, src, order,
                                             strongest_failure_ordering);
                     if unsafe { llvm::LLVMVersionMinor() >= 5 } {
                         ExtractValue(bcx, res, 0)
@@ -720,10 +728,15 @@ pub fn trans_intrinsic_call<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
                 }
 
                 "load" => {
-                    AtomicLoad(bcx, llargs[0], order)
+                    let tp_ty = *substs.types.get(FnSpace, 0);
+                    let ptr = to_arg_ty_ptr(bcx, llargs[0], tp_ty);
+                    from_arg_ty(bcx, AtomicLoad(bcx, ptr, order), tp_ty)
                 }
                 "store" => {
-                    AtomicStore(bcx, llargs[1], llargs[0], order);
+                    let tp_ty = *substs.types.get(FnSpace, 0);
+                    let ptr = to_arg_ty_ptr(bcx, llargs[0], tp_ty);
+                    let val = to_arg_ty(bcx, llargs[1], tp_ty);
+                    AtomicStore(bcx, val, ptr, order);
                     C_nil(ccx)
                 }
 
@@ -749,7 +762,10 @@ pub fn trans_intrinsic_call<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
                         _ => ccx.sess().fatal("unknown atomic operation")
                     };
 
-                    AtomicRMW(bcx, atom_op, llargs[0], llargs[1], order)
+                    let tp_ty = *substs.types.get(FnSpace, 0);
+                    let ptr = to_arg_ty_ptr(bcx, llargs[0], tp_ty);
+                    let val = to_arg_ty(bcx, llargs[1], tp_ty);
+                    AtomicRMW(bcx, atom_op, ptr, val, order)
                 }
             }
 
index 09592db8a116d399abd4bf2d815942672ff56e9c..ce4bb4465517b21ef55189e1fc99f2312fae03ee 100644 (file)
@@ -380,7 +380,7 @@ fn try_adjust_upvar_deref(&self,
                 // borrow_kind of the upvar to make sure it
                 // is inferred to mutable if necessary
                 let mut upvar_capture_map = self.fcx.inh.upvar_capture_map.borrow_mut();
-                let ub = &mut upvar_capture_map[upvar_id];
+                let ub = upvar_capture_map.get_mut(&upvar_id).unwrap();
                 self.adjust_upvar_borrow_kind(upvar_id, ub, borrow_kind);
 
                 // also need to be in an FnMut closure since this is not an ImmBorrow
index 0650b4d515860902ab9409444b96822042a5611c..d747ed3f119c2df095e443daefd785696bc11d0f 100644 (file)
@@ -64,6 +64,8 @@
 use std::rc::Rc;
 use std::sync::mpsc::channel;
 
+#[allow(deprecated)] use std::old_path::Path;
+
 use externalfiles::ExternalHtml;
 use serialize::Decodable;
 use serialize::json::{self, Json};
index 3db0162969f46b04a5a45f7e8f92d95182b11bea..fac8f2e2a9cc2cef926786095fa4466075c2b85d 100644 (file)
@@ -16,6 +16,7 @@
 use serialize::json;
 use std::mem;
 use std::string::String;
+use std::old_path::{Path, GenericPath};
 
 pub type PluginJson = Option<(String, json::Json)>;
 pub type PluginResult = (clean::Crate, PluginJson);
index 529ed8598b1ac13e9ccb2daa4ad0dcac6c62b5cd..096c72e6af2db0fb660c0002aa43c288d5dfe524 100644 (file)
@@ -2622,6 +2622,7 @@ mod tests {
     use std::{i64, u64, f32, f64};
     use std::collections::BTreeMap;
     use std::string;
+    use std::old_io::Writer;
 
     #[derive(RustcDecodable, Eq, PartialEq, Debug)]
     struct OptionData {
index 77e2da7ec79139332a256923f5e8a476bcafa6ae..71f9e01706dab1eb2d93f2207d86fd1546c234dd 100644 (file)
@@ -15,7 +15,7 @@
 */
 
 #[allow(deprecated)]
-use std::old_path;
+use std::old_path::{self, GenericPath};
 use std::path;
 use std::rc::Rc;
 use std::cell::{Cell, RefCell};
index 60b1738d2c98918351082c0da31efbfc78b08aed..9139e182ce479594ba38b0ccc132a33f2f9b98a5 100644 (file)
@@ -23,7 +23,7 @@
 use iter::{self, Iterator, ExactSizeIterator, IntoIterator, IteratorExt, FromIterator, Extend, Map};
 use marker::Sized;
 use mem::{self, replace};
-use ops::{Deref, FnMut, Index, IndexMut};
+use ops::{Deref, FnMut, Index};
 use option::Option::{self, Some, None};
 use rand::{self, Rng};
 use result::Result::{self, Ok, Err};
@@ -1258,18 +1258,6 @@ fn index<'a>(&'a self, index: &Q) -> &'a V {
     }
 }
 
-#[stable(feature = "rust1", since = "1.0.0")]
-impl<K, V, S, Q: ?Sized> IndexMut<Q> for HashMap<K, V, S>
-    where K: Eq + Hash + Borrow<Q>,
-          Q: Eq + Hash,
-          S: HashState,
-{
-    #[inline]
-    fn index_mut<'a>(&'a mut self, index: &Q) -> &'a mut V {
-        self.get_mut(index).expect("no entry found for key")
-    }
-}
-
 /// HashMap iterator.
 #[stable(feature = "rust1", since = "1.0.0")]
 pub struct Iter<'a, K: 'a, V: 'a> {
index a42809127bf5c8912c0568a281607db410f23047..085bf01612d30519172fe94f26775d63fff2a881 100644 (file)
 
 use prelude::v1::*;
 
+use env;
 use ffi::CString;
 use mem;
-use env;
-use str;
+use old_path::{Path, GenericPath};
 use os;
+use str;
 
 pub struct DynamicLibrary {
     handle: *mut u8
@@ -133,6 +134,7 @@ mod test {
     use super::*;
     use prelude::v1::*;
     use libc;
+    use old_path::Path;
     use mem;
 
     #[test]
@@ -140,8 +142,7 @@ mod test {
     fn test_loading_cosine() {
         // The math library does not need to be loaded since it is already
         // statically linked in
-        let none: Option<&Path> = None; // appease the typechecker
-        let libm = match DynamicLibrary::open(none) {
+        let libm = match DynamicLibrary::open(None) {
             Err(error) => panic!("Could not load self as module: {}", error),
             Ok(libm) => libm
         };
index 4b6fbe01f760bbe0b19b85d22f21a34b6561f55a..24882c7f7abfd099c8703909c04c6ed3563247ac 100644 (file)
@@ -729,10 +729,11 @@ mod arch {
 mod tests {
     use prelude::v1::*;
     use super::*;
+
     use iter::repeat;
     use rand::{self, Rng};
     use ffi::{OsString, OsStr};
-    use path::PathBuf;
+    use path::{Path, PathBuf};
 
     fn make_rand_name() -> OsString {
         let mut rng = rand::thread_rng();
index c56852cb18a0577b93ca8895a34c44a1d0c44965..7df6d6887a25892e564dbeb2a11ff0207165bbc6 100644 (file)
@@ -801,6 +801,7 @@ mod tests {
     use prelude::v1::*;
     use io::prelude::*;
 
+    use env;
     use fs::{self, File, OpenOptions};
     use io::{ErrorKind, SeekFrom};
     use path::PathBuf;
@@ -848,8 +849,7 @@ fn drop(&mut self) {
     }
 
     pub fn tmpdir() -> TempDir {
-        let s = os::tmpdir();
-        let p = Path2::new(s.as_str().unwrap());
+        let p = env::temp_dir();
         let ret = p.join(&format!("rust-{}", rand::random::<u32>()));
         check!(fs::create_dir(&ret));
         TempDir(ret)
@@ -1082,7 +1082,7 @@ fn file_test_directoryinfo_readdir() {
         let dir = &tmpdir.join("di_readdir");
         check!(fs::create_dir(dir));
         let prefix = "foo";
-        for n in range(0, 3) {
+        for n in 0..3 {
             let f = dir.join(&format!("{}.txt", n));
             let mut w = check!(File::create(&f));
             let msg_str = format!("{}{}", prefix, n.to_string());
@@ -1537,7 +1537,7 @@ fn utime_noexist() {
     #[test]
     fn binary_file() {
         let mut bytes = [0; 1024];
-        StdRng::new().ok().unwrap().fill_bytes(&mut bytes);
+        StdRng::new().unwrap().fill_bytes(&mut bytes);
 
         let tmpdir = tmpdir();
 
index 365f5e37b0b30a6413bd81f8361dbe560197fd8d..87e5a2a448855f97da265eeeccc38aa1c2ae16fe 100644 (file)
@@ -277,7 +277,7 @@ fn test_mem_reader() {
     fn read_to_end() {
         let mut reader = Cursor::new(vec!(0, 1, 2, 3, 4, 5, 6, 7));
         let mut v = Vec::new();
-        reader.read_to_end(&mut v).ok().unwrap();
+        reader.read_to_end(&mut v).unwrap();
         assert_eq!(v, [0, 1, 2, 3, 4, 5, 6, 7]);
     }
 
index 6bf0ebd1a59e9c8b0a744e7be449f6f83c2d18ef..a2ceacbe1f897ba62c6d4ba46b3daf2ecd4884d9 100644 (file)
@@ -23,8 +23,5 @@
 
 #![stable(feature = "rust1", since = "1.0.0")]
 
-pub use super::{Read, Write, BufRead};
+pub use super::{Read, Write, BufRead, Seek};
 pub use fs::PathExt;
-
-// FIXME: pub use as `Seek` when the name isn't in the actual prelude any more
-pub use super::Seek as NewSeek;
index 702f81db8e22faa07971f65d089ce5125b6da1f8..872411170438cfda13687f5366493105895c849e 100644 (file)
@@ -617,7 +617,7 @@ fn check(str_addr: &str, unspec: bool, loopback: bool,
                  unique_local: bool, global: bool,
                  u_link_local: bool, u_site_local: bool, u_global: bool,
                  m_scope: Option<Ipv6MulticastScope>) {
-            let ip: Ipv6Addr = str_addr.parse().ok().unwrap();
+            let ip: Ipv6Addr = str_addr.parse().unwrap();
             assert_eq!(str_addr, ip.to_string());
 
             assert_eq!(ip.is_unspecified(), unspec);
index 082dad613b5561891bd11be67406f354e198fa9b..562094a87f4e5db0a8a1ccefa2a67e5217d8b490 100644 (file)
@@ -1650,7 +1650,7 @@ fn $test_name() {
                 #![test]
                 assert_eq!((0 as $T).next_power_of_two(), 1);
                 let mut next_power = 1;
-                for i in range::<$T>(1, 40) {
+                for i in 1 as $T..40 {
                      assert_eq!(i.next_power_of_two(), next_power);
                      if i == next_power { next_power *= 2 }
                 }
@@ -1673,7 +1673,7 @@ fn $test_name() {
                 assert_eq!(($T::MAX - 1).checked_next_power_of_two(), None);
                 assert_eq!($T::MAX.checked_next_power_of_two(), None);
                 let mut next_power = 1;
-                for i in range::<$T>(1, 40) {
+                for i in 1 as $T..40 {
                      assert_eq!(i.checked_next_power_of_two(), Some(next_power));
                      if i == next_power { next_power *= 2 }
                 }
index 56bc21303bbcac039278545be16de691caf08894..3e5f732e345453d3f7c9eb396137433d56ad1486 100644 (file)
@@ -33,7 +33,8 @@
 /// # Examples
 ///
 /// ```
-/// use std::old_io::{BufferedReader, File};
+/// use std::old_io::*;
+/// use std::old_path::Path;
 ///
 /// let file = File::open(&Path::new("message.txt"));
 /// let mut reader = BufferedReader::new(file);
@@ -136,7 +137,8 @@ fn read(&mut self, buf: &mut [u8]) -> IoResult<uint> {
 /// # Examples
 ///
 /// ```
-/// use std::old_io::{BufferedWriter, File};
+/// use std::old_io::*;
+/// use std::old_path::Path;
 ///
 /// let file = File::create(&Path::new("message.txt")).unwrap();
 /// let mut writer = BufferedWriter::new(file);
@@ -323,7 +325,8 @@ fn read(&mut self, buf: &mut [u8]) -> IoResult<uint> {
 ///
 /// ```
 /// # #![allow(unused_must_use)]
-/// use std::old_io::{BufferedStream, File};
+/// use std::old_io::*;
+/// use std::old_path::Path;
 ///
 /// let file = File::open(&Path::new("message.txt"));
 /// let mut stream = BufferedStream::new(file);
@@ -422,7 +425,7 @@ fn flush(&mut self) -> IoResult<()> {
 #[cfg(test)]
 mod test {
     extern crate test;
-    use old_io;
+    use old_io::{self, Reader, Writer, Buffer, BufferPrelude};
     use prelude::v1::*;
     use super::*;
     use super::super::{IoResult, EndOfFile};
index 2dc61f409e2a4524cf6e8fa4f7e9698376b926a7..7e62a21f105cd8d43ab16c8c98458db6c9f9f440 100644 (file)
@@ -24,7 +24,7 @@
 ///
 /// ```
 /// use std::sync::mpsc::channel;
-/// use std::old_io::ChanReader;
+/// use std::old_io::*;
 ///
 /// let (tx, rx) = channel();
 /// # drop(tx);
@@ -116,7 +116,7 @@ fn read(&mut self, buf: &mut [u8]) -> IoResult<uint> {
 /// ```
 /// # #![allow(unused_must_use)]
 /// use std::sync::mpsc::channel;
-/// use std::old_io::ChanWriter;
+/// use std::old_io::*;
 ///
 /// let (tx, rx) = channel();
 /// # drop(rx);
@@ -160,7 +160,7 @@ mod test {
 
     use sync::mpsc::channel;
     use super::*;
-    use old_io;
+    use old_io::{self, Reader, Writer, Buffer};
     use thread;
 
     #[test]
index 12c9970aa84393f8ca2b8746e8b22fdec81e25a3..2990c1c265d54fcb14b2efd5fd3d73d5587fb2e8 100644 (file)
@@ -179,7 +179,7 @@ pub fn u64_from_be_bytes(data: &[u8], start: uint, size: uint) -> u64 {
 #[cfg(test)]
 mod test {
     use prelude::v1::*;
-    use old_io;
+    use old_io::{self, Reader, Writer};
     use old_io::{MemReader, BytesReader};
 
     struct InitialZeroByteReader {
index 2df925beb3667e9afe882821f1ae0eacf3733216..87e5b91fc2820d84729252d9234b0a1dcbc5f66b 100644 (file)
@@ -32,7 +32,8 @@
 //! ```rust
 //! # #![allow(unused_must_use)]
 //! use std::old_io::fs::PathExtensions;
-//! use std::old_io::{File, fs};
+//! use std::old_io::*;
+//! use std::old_path::Path;
 //!
 //! let path = Path::new("foo.txt");
 //!
@@ -104,7 +105,8 @@ impl File {
     /// # Examples
     ///
     /// ```rust,should_fail
-    /// use std::old_io::{File, Open, ReadWrite};
+    /// use std::old_io::*;
+    /// use std::old_path::Path;
     ///
     /// let p = Path::new("/some/file/path.txt");
     ///
@@ -175,7 +177,8 @@ pub fn open_mode(path: &Path,
     /// # Examples
     ///
     /// ```
-    /// use std::old_io::File;
+    /// use std::old_io::*;
+    /// use std::old_path::Path;
     ///
     /// let contents = File::open(&Path::new("foo.txt")).read_to_end();
     /// ```
@@ -195,7 +198,8 @@ pub fn open(path: &Path) -> IoResult<File> {
     ///
     /// ```
     /// # #![allow(unused_must_use)]
-    /// use std::old_io::File;
+    /// use std::old_io::*;
+    /// use std::old_path::Path;
     ///
     /// let mut f = File::create(&Path::new("foo.txt"));
     /// f.write(b"This is a sample file");
@@ -286,7 +290,8 @@ pub fn stat(&self) -> IoResult<FileStat> {
 ///
 /// ```
 /// # #![allow(unused_must_use)]
-/// use std::old_io::fs;
+/// use std::old_io::*;
+/// use std::old_path::Path;
 ///
 /// let p = Path::new("/some/file/path.txt");
 /// fs::unlink(&p);
@@ -316,7 +321,8 @@ pub fn unlink(path: &Path) -> IoResult<()> {
 /// # Examples
 ///
 /// ```
-/// use std::old_io::fs;
+/// use std::old_io::*;
+/// use std::old_path::Path;
 ///
 /// let p = Path::new("/some/file/path.txt");
 /// match fs::stat(&p) {
@@ -359,7 +365,8 @@ pub fn lstat(path: &Path) -> IoResult<FileStat> {
 ///
 /// ```
 /// # #![allow(unused_must_use)]
-/// use std::old_io::fs;
+/// use std::old_io::*;
+/// use std::old_path::Path;
 ///
 /// fs::rename(&Path::new("foo"), &Path::new("bar"));
 /// ```
@@ -387,7 +394,8 @@ pub fn rename(from: &Path, to: &Path) -> IoResult<()> {
 ///
 /// ```
 /// # #![allow(unused_must_use)]
-/// use std::old_io::fs;
+/// use std::old_io::*;
+/// use std::old_path::Path;
 ///
 /// fs::copy(&Path::new("foo.txt"), &Path::new("bar.txt"));
 /// ```
@@ -438,7 +446,8 @@ fn update_err<T>(result: IoResult<T>, from: &Path, to: &Path) -> IoResult<T> {
 /// ```
 /// # #![allow(unused_must_use)]
 /// use std::old_io;
-/// use std::old_io::fs;
+/// use std::old_io::*;
+/// use std::old_path::Path;
 ///
 /// fs::chmod(&Path::new("file.txt"), old_io::USER_FILE);
 /// fs::chmod(&Path::new("file.txt"), old_io::USER_READ | old_io::USER_WRITE);
@@ -509,7 +518,8 @@ pub fn readlink(path: &Path) -> IoResult<Path> {
 /// ```
 /// # #![allow(unused_must_use)]
 /// use std::old_io;
-/// use std::old_io::fs;
+/// use std::old_io::*;
+/// use std::old_path::Path;
 ///
 /// let p = Path::new("/some/dir");
 /// fs::mkdir(&p, old_io::USER_RWX);
@@ -532,7 +542,8 @@ pub fn mkdir(path: &Path, mode: FilePermission) -> IoResult<()> {
 ///
 /// ```
 /// # #![allow(unused_must_use)]
-/// use std::old_io::fs;
+/// use std::old_io::*;
+/// use std::old_path::Path;
 ///
 /// let p = Path::new("/some/dir");
 /// fs::rmdir(&p);
@@ -556,8 +567,9 @@ pub fn rmdir(path: &Path) -> IoResult<()> {
 ///
 /// ```
 /// use std::old_io::fs::PathExtensions;
-/// use std::old_io::fs;
 /// use std::old_io;
+/// use std::old_io::*;
+/// use std::old_path::Path;
 ///
 /// // one possible implementation of fs::walk_dir only visiting files
 /// fn visit_dirs<F>(dir: &Path, cb: &mut F) -> old_io::IoResult<()> where
@@ -881,7 +893,8 @@ fn access_string(access: FileAccess) -> &'static str {
 mod test {
     use prelude::v1::*;
     use old_io::{SeekSet, SeekCur, SeekEnd, Read, Open, ReadWrite, FileType};
-    use old_io;
+    use old_io::{self, Reader, Writer, Seek};
+    use old_path::{Path, GenericPath};
     use str;
     use old_io::fs::*;
 
@@ -1608,7 +1621,7 @@ fn binary_file() {
         use rand::{StdRng, Rng};
 
         let mut bytes = [0; 1024];
-        StdRng::new().ok().unwrap().fill_bytes(&mut bytes);
+        StdRng::new().unwrap().fill_bytes(&mut bytes);
 
         let tmpdir = tmpdir();
 
index eb7691361d45c502661c84566411cccde681323a..1acc6abc8506f435f3cf47487670edaba65c132b 100644 (file)
@@ -55,7 +55,7 @@ fn write_all(&mut self, buf: &[u8]) -> IoResult<()> {
 ///
 /// ```
 /// # #![allow(unused_must_use)]
-/// use std::old_io::MemWriter;
+/// use std::old_io::*;
 ///
 /// let mut w = MemWriter::new();
 /// w.write(&[0, 1, 2]);
@@ -115,7 +115,7 @@ fn write_all(&mut self, buf: &[u8]) -> IoResult<()> {
 ///
 /// ```
 /// # #![allow(unused_must_use)]
-/// use std::old_io::MemReader;
+/// use std::old_io::*;
 ///
 /// let mut r = MemReader::new(vec!(0, 1, 2));
 ///
@@ -245,7 +245,7 @@ fn consume(&mut self, amt: uint) {
 ///
 /// ```
 /// # #![allow(unused_must_use)]
-/// use std::old_io::BufWriter;
+/// use std::old_io::*;
 ///
 /// let mut buf = [0; 4];
 /// {
@@ -317,7 +317,7 @@ fn seek(&mut self, pos: i64, style: SeekStyle) -> IoResult<()> {
 ///
 /// ```
 /// # #![allow(unused_must_use)]
-/// use std::old_io::BufReader;
+/// use std::old_io::*;
 ///
 /// let buf = [0, 1, 2, 3];
 /// let mut r = BufReader::new(&buf);
@@ -394,8 +394,8 @@ fn fill_buf(&mut self) -> IoResult<&[u8]> {
 #[cfg(test)]
 mod test {
     extern crate "test" as test_crate;
-    use old_io::{SeekSet, SeekCur, SeekEnd, Reader, Writer, Seek};
-    use prelude::v1::{Ok, Err, range,  Vec, Buffer,  AsSlice};
+    use old_io::{SeekSet, SeekCur, SeekEnd, Reader, Writer, Seek, Buffer};
+    use prelude::v1::{Ok, Err, Vec,  AsSlice};
     use prelude::v1::IteratorExt;
     use old_io;
     use iter::repeat;
index 6b6c36a31ec5bd32592db5ada18125febf97cc72..6dfb54fd66cc4107d167ab893ea4cbd6f57802c8 100644 (file)
@@ -49,6 +49,7 @@
 //!
 //!     ```rust
 //!     use std::old_io as io;
+//!     use std::old_io::*;
 //!
 //!     let mut stdin = io::stdin();
 //!     for line in stdin.lock().lines() {
@@ -59,7 +60,8 @@
 //! * Read a complete file
 //!
 //!     ```rust
-//!     use std::old_io::File;
+//!     use std::old_io::*;
+//!     use std::old_path::Path;
 //!
 //!     let contents = File::open(&Path::new("message.txt")).read_to_end();
 //!     ```
@@ -68,7 +70,8 @@
 //!
 //!     ```rust
 //!     # #![allow(unused_must_use)]
-//!     use std::old_io::File;
+//!     use std::old_io::*;
+//!     use std::old_path::Path;
 //!
 //!     let mut file = File::create(&Path::new("message.txt"));
 //!     file.write_all(b"hello, file!\n");
@@ -79,8 +82,8 @@
 //! * Iterate over the lines of a file
 //!
 //!     ```rust,no_run
-//!     use std::old_io::BufferedReader;
-//!     use std::old_io::File;
+//!     use std::old_io::*;
+//!     use std::old_path::Path;
 //!
 //!     let path = Path::new("message.txt");
 //!     let mut file = BufferedReader::new(File::open(&path));
@@ -92,8 +95,8 @@
 //! * Pull the lines of a file into a vector of strings
 //!
 //!     ```rust,no_run
-//!     use std::old_io::BufferedReader;
-//!     use std::old_io::File;
+//!     use std::old_io::*;
+//!     use std::old_path::Path;
 //!
 //!     let path = Path::new("message.txt");
 //!     let mut file = BufferedReader::new(File::open(&path));
 //!
 //!     ```rust
 //!     # #![allow(unused_must_use)]
-//!     use std::old_io::TcpStream;
+//!     use std::old_io::*;
 //!
 //!     # // connection doesn't fail if a server is running on 8080
 //!     # // locally, we still want to be type checking this code, so lets
 //!     # fn main() { }
 //!     # fn foo() {
 //!     # #![allow(dead_code)]
-//!     use std::old_io::{TcpListener, TcpStream};
-//!     use std::old_io::{Acceptor, Listener};
+//!     use std::old_io::*;
 //!     use std::thread;
 //!
 //!     let listener = TcpListener::bind("127.0.0.1:80");
 //!
 //! ```rust
 //! # #![allow(unused_must_use)]
-//! use std::old_io::File;
+//! use std::old_io::*;
+//! use std::old_path::Path;
 //!
 //! match File::create(&Path::new("diary.txt")).write_all(b"Met a girl.\n") {
 //!     Ok(()) => (), // succeeded
 //! If you wanted to read several `u32`s from a file and return their product:
 //!
 //! ```rust
-//! use std::old_io::{File, IoResult};
+//! use std::old_io::*;
+//! use std::old_path::Path;
 //!
 //! fn file_product(p: &Path) -> IoResult<u32> {
 //!     let mut f = File::open(p);
@@ -945,7 +949,7 @@ unsafe fn slice_vec_capacity<'a, T>(v: &'a mut Vec<T>, start: uint, end: uint) -
 ///
 /// ```
 /// use std::old_io as io;
-/// use std::old_io::ByRefReader;
+/// use std::old_io::*;
 /// use std::old_io::util::LimitReader;
 ///
 /// fn process_input<R: Reader>(r: R) {}
@@ -1279,7 +1283,7 @@ fn flush(&mut self) -> IoResult<()> { (**self).flush() }
 ///
 /// ```
 /// use std::old_io::util::TeeReader;
-/// use std::old_io::{stdin, ByRefWriter};
+/// use std::old_io::*;
 ///
 /// fn process_input<R: Reader>(r: R) {}
 ///
@@ -1403,7 +1407,7 @@ pub trait Buffer: Reader {
     /// # Examples
     ///
     /// ```
-    /// use std::old_io::BufReader;
+    /// use std::old_io::*;
     ///
     /// let mut reader = BufReader::new(b"hello\nworld");
     /// assert_eq!("hello\n", &*reader.read_line().unwrap());
@@ -1717,6 +1721,7 @@ pub enum FileType {
 /// ```no_run
 ///
 /// use std::old_io::fs::PathExtensions;
+/// use std::old_path::Path;
 ///
 /// let info = match Path::new("foo.txt").stat() {
 ///     Ok(stat) => stat,
@@ -1845,7 +1850,8 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
 mod tests {
     use self::BadReaderBehavior::*;
     use super::{IoResult, Reader, MemReader, NoProgress, InvalidInput, Writer};
-    use prelude::v1::{Ok, Vec, Buffer};
+    use super::Buffer;
+    use prelude::v1::{Ok, Vec};
     use usize;
 
     #[derive(Clone, PartialEq, Debug)]
index ad0e7a7284de48c2fb8fe47ddbbe2947b61a4ea1..77efedbc327d4cd06b81195d7de646740f5c53d5 100644 (file)
@@ -31,6 +31,7 @@
 use ffi::CString;
 use old_path::BytesContainer;
 use old_io::{Listener, Acceptor, IoResult, TimedOut, standard_error};
+use old_io::{Reader, Writer};
 use sys::pipe::UnixAcceptor as UnixAcceptorImp;
 use sys::pipe::UnixListener as UnixListenerImp;
 use sys::pipe::UnixStream as UnixStreamImp;
@@ -55,6 +56,8 @@ impl UnixStream {
     /// ```
     /// # #![allow(unused_must_use)]
     /// use std::old_io::net::pipe::UnixStream;
+    /// use std::old_io::*;
+    /// use std::old_path::Path;
     ///
     /// let server = Path::new("path/to/my/socket");
     /// let mut stream = UnixStream::connect(&server);
@@ -180,7 +183,8 @@ impl UnixListener {
     /// ```
     /// # fn foo() {
     /// use std::old_io::net::pipe::UnixListener;
-    /// use std::old_io::{Listener, Acceptor};
+    /// use std::old_io::*;
+    /// use std::old_path::Path;
     ///
     /// let server = Path::new("/path/to/my/socket");
     /// let stream = UnixListener::bind(&server);
@@ -285,6 +289,7 @@ mod tests {
     use old_io::{EndOfFile, TimedOut, ShortWrite, IoError, ConnectionReset};
     use old_io::{NotConnected, BrokenPipe, FileNotFound, InvalidInput, OtherIoError};
     use old_io::{PermissionDenied, Acceptor, Listener};
+    use old_io::{Reader, Writer};
     use old_io::test::*;
     use super::*;
     use sync::mpsc::channel;
index 6fb8020a3d602526393a2b5c6a65d860b5856e62..dbf3c4a4b1ecbf8d153615b18d06c86eef25281d 100644 (file)
@@ -41,7 +41,7 @@
 /// # Examples
 ///
 /// ```no_run
-/// use std::old_io::TcpStream;
+/// use std::old_io::*;
 ///
 /// {
 ///     let mut stream = TcpStream::connect("127.0.0.1:34254");
@@ -134,8 +134,7 @@ pub fn set_keepalive(&mut self, delay_in_seconds: Option<uint>) -> IoResult<()>
     ///
     /// ```no_run
     /// # #![allow(unused_must_use)]
-    /// use std::old_io::timer;
-    /// use std::old_io::TcpStream;
+    /// use std::old_io::*;
     /// use std::time::Duration;
     /// use std::thread;
     ///
@@ -280,8 +279,7 @@ fn as_inner(&self) -> &TcpStreamImp {
 ///
 /// ```
 /// # fn foo() {
-/// use std::old_io::{TcpListener, TcpStream};
-/// use std::old_io::{Acceptor, Listener};
+/// use std::old_io::*;
 /// use std::thread;
 ///
 /// let listener = TcpListener::bind("127.0.0.1:80").unwrap();
@@ -376,8 +374,7 @@ impl TcpAcceptor {
     /// # Examples
     ///
     /// ```no_run
-    /// use std::old_io::TcpListener;
-    /// use std::old_io::{Listener, Acceptor, TimedOut};
+    /// use std::old_io::*;
     ///
     /// let mut a = TcpListener::bind("127.0.0.1:8482").listen().unwrap();
     ///
@@ -420,7 +417,7 @@ impl TcpAcceptor {
     /// # Examples
     ///
     /// ```
-    /// use std::old_io::{TcpListener, Listener, Acceptor, EndOfFile};
+    /// use std::old_io::*;
     /// use std::thread;
     ///
     /// let mut a = TcpListener::bind("127.0.0.1:8482").listen().unwrap();
@@ -496,6 +493,7 @@ mod test {
     use old_io::{ConnectionReset, NotConnected, PermissionDenied, OtherIoError};
     use old_io::{InvalidInput};
     use old_io::{Acceptor, Listener};
+    use old_io::{Reader, Writer};
 
     // FIXME #11530 this fails on android because tests are run as root
     #[cfg_attr(any(windows, target_os = "android"), ignore)]
index b78c8acb1900d2e312ceccc4aaf555c0405c2c39..b2b28453c890514637237e5e77b5e27abe108eb5 100644 (file)
@@ -17,7 +17,7 @@
 
 use prelude::v1::*;
 
-use old_io::IoResult;
+use old_io::{IoResult, Reader, Writer};
 use libc;
 use sync::Arc;
 
@@ -49,7 +49,7 @@ impl PipeStream {
     /// # #![allow(unused_must_use)]
     /// extern crate libc;
     ///
-    /// use std::old_io::pipe::PipeStream;
+    /// use std::old_io::*;
     ///
     /// fn main() {
     ///     let mut pipe = PipeStream::open(libc::STDERR_FILENO);
@@ -114,6 +114,7 @@ fn write_all(&mut self, buf: &[u8]) -> IoResult<()> {
 mod test {
     use prelude::v1::*;
 
+    use old_io::{Writer, Reader};
     use sync::mpsc::channel;
     use thread;
 
index 53b126ec00038f5ca8205abbc0cc9d2fc4055521..54fd20f45e298bd7ae44bf2f49c51075219a19c2 100644 (file)
@@ -24,8 +24,9 @@
 use ffi::CString;
 use fmt;
 use old_io::pipe::{PipeStream, PipePair};
-use old_io::{IoResult, IoError};
+use old_io::{IoResult, IoError, Reader, Writer};
 use old_io;
+use old_path::{Path, GenericPath};
 use libc;
 use os;
 use old_path::BytesContainer;
@@ -60,7 +61,7 @@
 /// # Examples
 ///
 /// ```should_fail
-/// use std::old_io::Command;
+/// use std::old_io::*;
 ///
 /// let mut child = match Command::new("/bin/cat").arg("file.txt").spawn() {
 ///     Ok(child) => child,
@@ -163,7 +164,7 @@ fn container_as_bytes<'a>(&'a self) -> &'a [u8] {
 /// to be changed (for example, by adding arguments) prior to spawning:
 ///
 /// ```
-/// use std::old_io::Command;
+/// use std::old_io::*;
 ///
 /// let mut process = match Command::new("sh").arg("-c").arg("echo hello").spawn() {
 ///   Ok(p) => p,
@@ -759,9 +760,11 @@ fn drop(&mut self) {
 #[cfg(test)]
 mod tests {
     use old_io::{Truncate, Write, TimedOut, timer, process, FileNotFound};
-    use prelude::v1::{Ok, Err, range, drop, Some, None, Vec};
-    use prelude::v1::{Path, String, Reader, Writer, Clone};
-    use prelude::v1::{Str, AsSlice, ToString, GenericPath};
+    use old_io::{Reader, Writer};
+    use prelude::v1::{Ok, Err, drop, Some, None, Vec};
+    use prelude::v1::{String, Clone};
+    use prelude::v1::{Str, AsSlice, ToString};
+    use old_path::{GenericPath, Path};
     use old_io::fs::PathExtensions;
     use old_io::timer::*;
     use rt::running_on_valgrind;
index cdf2bae1cbad3c260e28e36b682b1db6b1a4a201..9dcb487cdb0df0ff78ac9c4948beffb2ad863249 100644 (file)
@@ -80,7 +80,7 @@ fn accept(&mut self) -> IoResult<T> {
 mod test {
     use prelude::v1::*;
     use super::super::mem::*;
-    use old_io;
+    use old_io::{self, Reader, Writer};
 
     #[test]
     fn test_option_writer() {
index 4ca403823753d625a7220f407c0f2a796d89a022..a1c8630e0ec319efb0bfcb3537cbb9e6b8303d30 100644 (file)
@@ -20,6 +20,7 @@
 //! ```rust
 //! # #![allow(unused_must_use)]
 //! use std::old_io;
+//! use std::old_io::*;
 //!
 //! let mut out = old_io::stdout();
 //! out.write_all(b"Hello, world!");
@@ -140,6 +141,7 @@ impl StdinReader {
     ///
     /// ```
     /// use std::old_io;
+    /// use std::old_io::*;
     ///
     /// let mut stdin = old_io::stdin();
     /// for line in stdin.lock().lines() {
index 04bfd4409cf20b68412f39a3a59ba790891b579e..90b3d1004c0b35d95d9b0454e7c3fc89f403855e 100644 (file)
@@ -29,7 +29,8 @@
 /// # Examples
 ///
 /// ```no_run
-/// use std::old_io::TempDir;
+/// use std::old_io::*;
+/// use std::old_path::{Path, GenericPath};
 ///
 /// {
 ///     // create a temporary directory
index 9fbdac84a80dbc79e5fad48372ec75072a92df14..db409ecde452612be8b1fedf2a55c22fc6dbfb63 100644 (file)
@@ -14,7 +14,8 @@
 
 use env;
 use libc;
-use std::old_io::net::ip::*;
+use old_io::net::ip::*;
+use old_path::{Path, GenericPath};
 use sync::atomic::{AtomicUsize, ATOMIC_USIZE_INIT, Ordering};
 
 /// Get a port number, starting at 9600, for use in tests
index 413184c84d2a8e2c9c2373c911b6bdf65e01ff3a..1f782b6f221802308f20d06f18086835396a9a76 100644 (file)
@@ -14,7 +14,7 @@
 
 use prelude::v1::*;
 use cmp;
-use old_io;
+use old_io::{self, Reader, Writer, Buffer};
 use slice::bytes::MutableByteVector;
 
 /// Wraps a `Reader`, limiting the number of bytes that can be read from it.
@@ -325,7 +325,7 @@ fn read(&mut self, buf: &mut [u8]) -> old_io::IoResult<uint> {
 mod test {
     use prelude::v1::*;
 
-    use old_io::{MemReader, ByRefReader};
+    use old_io::{MemReader, ByRefReader, Reader, Writer, Buffer};
     use old_io;
     use super::*;
 
index fd117838f2f5b9d4b5e201a0ac99b90db8190c19..909fa4062b6042086e0748061d613f0d530019cd 100644 (file)
@@ -50,6 +50,7 @@
 //!
 //! ```rust
 //! use std::old_io::fs::PathExtensions;
+//! use std::old_path::{Path, GenericPath};
 //!
 //! let mut path = Path::new("/tmp/path");
 //! println!("path: {}", path.display());
@@ -142,6 +143,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe {
     /// # Examples
     ///
     /// ```
+    /// use std::old_path::{Path, GenericPath};
     /// # foo();
     /// # #[cfg(windows)] fn foo() {}
     /// # #[cfg(unix)] fn foo() {
@@ -166,6 +168,7 @@ fn new<T: BytesContainer>(path: T) -> Self {
     /// # Examples
     ///
     /// ```
+    /// use std::old_path::{Path, GenericPath};
     /// # foo();
     /// # #[cfg(windows)] fn foo() {}
     /// # #[cfg(unix)] fn foo() {
@@ -188,6 +191,7 @@ fn new_opt<T: BytesContainer>(path: T) -> Option<Self> {
     /// # Examples
     ///
     /// ```
+    /// use std::old_path::{Path, GenericPath};
     /// # foo();
     /// # #[cfg(windows)] fn foo() {}
     /// # #[cfg(unix)] fn foo() {
@@ -205,6 +209,7 @@ fn as_str<'a>(&'a self) -> Option<&'a str> {
     /// # Examples
     ///
     /// ```
+    /// use std::old_path::{Path, GenericPath};
     /// # foo();
     /// # #[cfg(windows)] fn foo() {}
     /// # #[cfg(unix)] fn foo() {
@@ -219,6 +224,7 @@ fn as_str<'a>(&'a self) -> Option<&'a str> {
     /// # Examples
     ///
     /// ```
+    /// use std::old_path::{Path, GenericPath};
     /// # foo();
     /// # #[cfg(windows)] fn foo() {}
     /// # #[cfg(unix)] fn foo() {
@@ -234,6 +240,7 @@ fn as_str<'a>(&'a self) -> Option<&'a str> {
     /// # Examples
     ///
     /// ```
+    /// use std::old_path::{Path, GenericPath};
     /// # foo();
     /// # #[cfg(windows)] fn foo() {}
     /// # #[cfg(unix)] fn foo() {
@@ -252,6 +259,7 @@ fn display<'a>(&'a self) -> Display<'a, Self> {
     /// # Examples
     ///
     /// ```
+    /// use std::old_path::{Path, GenericPath};
     /// # foo();
     /// # #[cfg(windows)] fn foo() {}
     /// # #[cfg(unix)] fn foo() {
@@ -269,6 +277,7 @@ fn filename_display<'a>(&'a self) -> Display<'a, Self> {
     /// # Examples
     ///
     /// ```
+    /// use std::old_path::{Path, GenericPath};
     /// # foo();
     /// # #[cfg(windows)] fn foo() {}
     /// # #[cfg(unix)] fn foo() {
@@ -284,6 +293,7 @@ fn filename_display<'a>(&'a self) -> Display<'a, Self> {
     /// # Examples
     ///
     /// ```
+    /// use std::old_path::{Path, GenericPath};
     /// # foo();
     /// # #[cfg(windows)] fn foo() {}
     /// # #[cfg(unix)] fn foo() {
@@ -303,6 +313,7 @@ fn dirname_str<'a>(&'a self) -> Option<&'a str> {
     /// # Examples
     ///
     /// ```
+    /// use std::old_path::{Path, GenericPath};
     /// # foo();
     /// # #[cfg(windows)] fn foo() {}
     /// # #[cfg(unix)] fn foo() {
@@ -318,6 +329,7 @@ fn dirname_str<'a>(&'a self) -> Option<&'a str> {
     /// # Examples
     ///
     /// ```
+    /// use std::old_path::{Path, GenericPath};
     /// # foo();
     /// # #[cfg(windows)] fn foo() {}
     /// # #[cfg(unix)] fn foo() {
@@ -337,6 +349,7 @@ fn filename_str<'a>(&'a self) -> Option<&'a str> {
     /// # Examples
     ///
     /// ```
+    /// use std::old_path::{Path, GenericPath};
     /// # foo();
     /// # #[cfg(windows)] fn foo() {}
     /// # #[cfg(unix)] fn foo() {
@@ -364,6 +377,7 @@ fn filestem<'a>(&'a self) -> Option<&'a [u8]> {
     /// # Examples
     ///
     /// ```
+    /// use std::old_path::{Path, GenericPath};
     /// # foo();
     /// # #[cfg(windows)] fn foo() {}
     /// # #[cfg(unix)] fn foo() {
@@ -384,6 +398,7 @@ fn filestem_str<'a>(&'a self) -> Option<&'a str> {
     /// # Examples
     ///
     /// ```
+    /// use std::old_path::{Path, GenericPath};
     /// # foo();
     /// # #[cfg(windows)] fn foo() {}
     /// # #[cfg(unix)] fn foo() {
@@ -411,6 +426,7 @@ fn extension<'a>(&'a self) -> Option<&'a [u8]> {
     /// # Examples
     ///
     /// ```
+    /// use std::old_path::{Path, GenericPath};
     /// # foo();
     /// # #[cfg(windows)] fn foo() {}
     /// # #[cfg(unix)] fn foo() {
@@ -429,6 +445,7 @@ fn extension_str<'a>(&'a self) -> Option<&'a str> {
     /// # Examples
     ///
     /// ```
+    /// use std::old_path::{Path, GenericPath};
     /// # foo();
     /// # #[cfg(windows)] fn foo() {}
     /// # #[cfg(unix)] fn foo() {
@@ -455,6 +472,7 @@ fn set_filename<T: BytesContainer>(&mut self, filename: T) {
     /// # Examples
     ///
     /// ```
+    /// use std::old_path::{Path, GenericPath};
     /// # foo();
     /// # #[cfg(windows)] fn foo() {}
     /// # #[cfg(unix)] fn foo() {
@@ -505,6 +523,7 @@ fn set_extension<T: BytesContainer>(&mut self, extension: T) {
     /// # Examples
     ///
     /// ```
+    /// use std::old_path::{Path, GenericPath};
     /// # foo();
     /// # #[cfg(windows)] fn foo() {}
     /// # #[cfg(unix)] fn foo() {
@@ -530,6 +549,7 @@ fn with_filename<T: BytesContainer>(&self, filename: T) -> Self {
     /// # Examples
     ///
     /// ```
+    /// use std::old_path::{Path, GenericPath};
     /// # foo();
     /// # #[cfg(windows)] fn foo() {}
     /// # #[cfg(unix)] fn foo() {
@@ -554,6 +574,7 @@ fn with_extension<T: BytesContainer>(&self, extension: T) -> Self {
     /// # Examples
     ///
     /// ```
+    /// use std::old_path::{Path, GenericPath};
     /// # foo();
     /// # #[cfg(windows)] fn foo() {}
     /// # #[cfg(unix)] fn foo() {
@@ -573,6 +594,7 @@ fn dir_path(&self) -> Self {
     /// # Examples
     ///
     /// ```
+    /// use std::old_path::{Path, GenericPath};
     /// # foo();
     /// # #[cfg(windows)] fn foo() {}
     /// # #[cfg(unix)] fn foo() {
@@ -588,6 +610,7 @@ fn dir_path(&self) -> Self {
     /// # Examples
     ///
     /// ```
+    /// use std::old_path::{Path, GenericPath};
     /// # foo();
     /// # #[cfg(windows)] fn foo() {}
     /// # #[cfg(unix)] fn foo() {
@@ -612,6 +635,7 @@ fn push<T: BytesContainer>(&mut self, path: T) {
     /// # Examples
     ///
     /// ```
+    /// use std::old_path::{Path, GenericPath};
     /// # foo();
     /// # #[cfg(windows)] fn foo() {}
     /// # #[cfg(unix)] fn foo() {
@@ -641,6 +665,7 @@ fn push_many<T: BytesContainer>(&mut self, paths: &[T]) {
     /// # Examples
     ///
     /// ```
+    /// use std::old_path::{Path, GenericPath};
     /// # foo();
     /// # #[cfg(windows)] fn foo() {}
     /// # #[cfg(unix)] fn foo() {
@@ -658,6 +683,7 @@ fn push_many<T: BytesContainer>(&mut self, paths: &[T]) {
     /// # Examples
     ///
     /// ```
+    /// use std::old_path::{Path, GenericPath};
     /// # foo();
     /// # #[cfg(windows)] fn foo() {}
     /// # #[cfg(unix)] fn foo() {
@@ -683,6 +709,7 @@ fn join<T: BytesContainer>(&self, path: T) -> Self {
     /// # Examples
     ///
     /// ```
+    /// use std::old_path::{Path, GenericPath};
     /// # foo();
     /// # #[cfg(windows)] fn foo() {}
     /// # #[cfg(unix)] fn foo() {
@@ -705,6 +732,7 @@ fn join_many<T: BytesContainer>(&self, paths: &[T]) -> Self {
     /// # Examples
     ///
     /// ```
+    /// use std::old_path::{Path, GenericPath};
     /// # foo();
     /// # #[cfg(windows)] fn foo() {}
     /// # #[cfg(unix)] fn foo() {
@@ -722,6 +750,7 @@ fn join_many<T: BytesContainer>(&self, paths: &[T]) -> Self {
     /// # Examples
     ///
     /// ```
+    /// use std::old_path::{Path, GenericPath};
     /// # foo();
     /// # #[cfg(windows)] fn foo() {}
     /// # #[cfg(unix)] fn foo() {
@@ -740,6 +769,7 @@ fn is_relative(&self) -> bool {
     /// # Examples
     ///
     /// ```
+    /// use std::old_path::{Path, GenericPath};
     /// # foo();
     /// # #[cfg(windows)] fn foo() {}
     /// # #[cfg(unix)] fn foo() {
@@ -759,6 +789,7 @@ fn is_relative(&self) -> bool {
     /// # Examples
     ///
     /// ```
+    /// use std::old_path::{Path, GenericPath};
     /// # foo();
     /// # #[cfg(windows)] fn foo() {}
     /// # #[cfg(unix)] fn foo() {
@@ -775,6 +806,7 @@ fn is_relative(&self) -> bool {
     /// # Examples
     ///
     /// ```
+    /// use std::old_path::{Path, GenericPath};
     /// # foo();
     /// # #[cfg(windows)] fn foo() {}
     /// # #[cfg(unix)] fn foo() {
index 4f28e9e44f12ef0fd173652ee1d1c1120c1ea2b6..0ab8612a7cb52eacc8ca7a5f65340876b94dfaec 100644 (file)
@@ -1224,7 +1224,8 @@ mod bench {
     extern crate test;
     use self::test::Bencher;
     use super::*;
-    use prelude::v1::{Clone, GenericPath};
+    use old_path::GenericPath;
+    use prelude::v1::Clone;
 
     #[bench]
     fn join_home_dir(b: &mut Bencher) {
index ef873265b7bcdbe21d0a93a9b9eea4e0d9ad9037..cea2c238ecec29d2fe5e565bd1e72d363146e089 100644 (file)
@@ -605,6 +605,7 @@ impl Path {
     /// # Examples
     ///
     /// ```
+    /// use std::old_path::{Path, GenericPath};
     /// println!("{}", Path::new(r"C:\some\path").display());
     /// ```
     #[inline]
@@ -619,6 +620,7 @@ pub fn new<T: BytesContainer>(path: T) -> Path {
     /// # Examples
     ///
     /// ```
+    /// use std::old_path::{Path, GenericPath};
     /// let path = Path::new_opt(r"C:\some\path");
     ///
     /// match path {
index a1a3afca7a9a50196be3730d0709aeecace962e5..3870b8614ffdfe05fbdaafc4c698bb4b34d26dc9 100644 (file)
@@ -126,6 +126,7 @@ pub fn num_cpus() -> uint {
 ///
 /// ```
 /// use std::os;
+/// use std::old_path::{Path, GenericPath};
 ///
 /// // We assume that we are in a valid directory.
 /// let current_working_directory = os::getcwd().unwrap();
@@ -265,6 +266,7 @@ pub fn unsetenv(n: &str) {
 ///
 /// ```
 /// use std::os;
+/// use std::old_path::{Path, GenericPath};
 ///
 /// let key = "PATH";
 /// match os::getenv_as_bytes(key) {
@@ -358,6 +360,7 @@ pub fn dll_filename(base: &str) -> String {
 ///
 /// ```
 /// use std::os;
+/// use std::old_path::{Path, GenericPath};
 ///
 /// match os::self_exe_name() {
 ///     Some(exe_path) => println!("Path of this executable is: {}", exe_path.display()),
@@ -378,6 +381,7 @@ pub fn self_exe_name() -> Option<Path> {
 ///
 /// ```
 /// use std::os;
+/// use std::old_path::{Path, GenericPath};
 ///
 /// match os::self_exe_path() {
 ///     Some(exe_path) => println!("Executable's Path is: {}", exe_path.display()),
@@ -407,6 +411,7 @@ pub fn self_exe_path() -> Option<Path> {
 ///
 /// ```
 /// use std::os;
+/// use std::old_path::{Path, GenericPath};
 ///
 /// match os::homedir() {
 ///     Some(ref p) => println!("{}", p.display()),
@@ -497,7 +502,7 @@ fn lookup() -> Path {
 ///
 /// ```
 /// use std::os;
-/// use std::old_path::Path;
+/// use std::old_path::{Path, GenericPath};
 ///
 /// // Assume we're in a path like /home/someuser
 /// let rel_path = Path::new("..");
@@ -529,7 +534,7 @@ pub fn make_absolute(p: &Path) -> IoResult<Path> {
 ///
 /// ```
 /// use std::os;
-/// use std::old_path::Path;
+/// use std::old_path::{Path, GenericPath};
 ///
 /// let root = Path::new("/");
 /// assert!(os::change_dir(&root).is_ok());
@@ -1496,6 +1501,8 @@ mod tests {
     use os;
     use rand::Rng;
     use rand;
+    use old_path::{Path, GenericPath};
+    use old_io::{Reader, Writer, Seek};
 
     #[test]
     pub fn last_os_error() {
index 2aaf6e8280086b54bc8e84f3ce9a3988e43e70cb..a0b4c80e9f3fa47e886a8434064e9621662f713c 100644 (file)
 #[stable(feature = "rust1", since = "1.0.0")]
 #[doc(no_inline)] pub use vec::Vec;
 
-// NB: remove when path reform lands
-#[doc(no_inline)] pub use old_path::{Path, GenericPath};
-// NB: remove when I/O reform lands
-#[doc(no_inline)] pub use old_io::{Buffer, Writer, Reader, Seek, BufferPrelude};
-// NB: remove when range syntax lands
-#[allow(deprecated)]
-#[doc(no_inline)] pub use iter::range;
-
+// FIXME(#23454) should these be here?
 #[doc(no_inline)] pub use num::wrapping::{Wrapping, WrappingOps};
index cda37b19c48680b4815e579acb839be6faa891ff..6b09636c1df1e8a370621a854db33ff569dbd05e 100644 (file)
@@ -533,8 +533,8 @@ mod tests {
     use io::prelude::*;
     use prelude::v1::{Ok, Err, drop, Some, Vec};
     use prelude::v1::{String, Clone};
-    use prelude::v1::{Str, AsSlice, ToString, GenericPath};
-    use old_path;
+    use prelude::v1::{Str, AsSlice, ToString};
+    use old_path::{self, GenericPath};
     use old_io::fs::PathExtensions;
     use rt::running_on_valgrind;
     use str;
index 5e8abfd0a3f8988a9f4a128e0bc233dd90b6aec8..e52e68dad23faec8358bd4c7f63b501eb1e39e49 100644 (file)
@@ -147,20 +147,14 @@ fn lang_start(main: *const u8, argc: int, argv: *const *const u8) -> int {
     }
 }
 
-/// Enqueues a procedure to run when the runtime is cleaned up
-///
-/// The procedure passed to this function will be executed as part of the
-/// runtime cleanup phase. For normal rust programs, this means that it will run
-/// after all other threads have exited.
-///
-/// The procedure is *not* executed with a local `Thread` available to it, so
-/// primitives like logging, I/O, channels, spawning, etc, are *not* available.
-/// This is meant for "bare bones" usage to clean up runtime details, this is
-/// not meant as a general-purpose "let's clean everything up" function.
+/// Enqueues a procedure to run when the main thread exits.
 ///
 /// It is forbidden for procedures to register more `at_exit` handlers when they
 /// are running, and doing so will lead to a process abort.
-pub fn at_exit<F:FnOnce()+Send+'static>(f: F) {
+///
+/// Note that other threads may still be running when `at_exit` routines start
+/// running.
+pub fn at_exit<F: FnOnce() + Send + 'static>(f: F) {
     at_exit_imp::push(Thunk::new(f));
 }
 
@@ -176,8 +170,5 @@ pub fn at_exit<F:FnOnce()+Send+'static>(f: F) {
 pub unsafe fn cleanup() {
     args::cleanup();
     sys::stack_overflow::cleanup();
-    // FIXME: (#20012): the resources being cleaned up by at_exit
-    // currently are not prepared for cleanup to happen asynchronously
-    // with detached threads using the resources; for now, we leak.
-    // at_exit_imp::cleanup();
+    at_exit_imp::cleanup();
 }
index ebb2a2e4827a10770098405b7c2b3e9d44c60c21..3ee3954ed64343c477afa61cb2963d691be9ebea 100644 (file)
@@ -69,7 +69,7 @@
 use libc::c_void;
 use mem;
 use sync::atomic::{self, Ordering};
-use sync::{Once, ONCE_INIT};
+use sys_common::mutex::{Mutex, MUTEX_INIT};
 
 use rt::libunwind as uw;
 
@@ -534,11 +534,22 @@ pub fn begin_unwind<M: Any + Send>(msg: M, file_line: &(&'static str, uint)) ->
 /// Doing this split took the LLVM IR line counts of `fn main() { panic!()
 /// }` from ~1900/3700 (-O/no opts) to 180/590.
 #[inline(never)] #[cold] // this is the slow path, please never inline this
-fn begin_unwind_inner(msg: Box<Any + Send>, file_line: &(&'static str, uint)) -> ! {
-    // Make sure the default panic handler is registered before we look at the
-    // callbacks.
-    static INIT: Once = ONCE_INIT;
-    INIT.call_once(|| unsafe { register(panicking::on_panic); });
+fn begin_unwind_inner(msg: Box<Any + Send>,
+                      file_line: &(&'static str, uint)) -> ! {
+    // Make sure the default failure handler is registered before we look at the
+    // callbacks. We also use a raw sys-based mutex here instead of a
+    // `std::sync` one as accessing TLS can cause weird recursive problems (and
+    // we don't need poison checking).
+    unsafe {
+        static LOCK: Mutex = MUTEX_INIT;
+        static mut INIT: bool = false;
+        LOCK.lock();
+        if !INIT {
+            register(panicking::on_panic);
+            INIT = true;
+        }
+        LOCK.unlock();
+    }
 
     // First, invoke call the user-defined callbacks triggered on thread panic.
     //
index f1c43a07e6e3895ef35cc52369876cc8f0cc7350..cf627ca254809c95cedafc730dba3d5ef942640a 100644 (file)
@@ -10,7 +10,6 @@
 //
 // ignore-lexer-test FIXME #15677
 
-use prelude::v1::*;
 use io::prelude::*;
 
 use env;
index 01eeed4fb54d018af47bacd1fe249aa4a2364a0b..123dad978f55ad4d30748650f6bfe05b7c840e66 100644 (file)
@@ -592,7 +592,7 @@ pub fn send(&self, t: T) -> Result<(), SendError<T>> {
                                 // asleep (we're looking at it), so the receiver
                                 // can't go away.
                                 (*a.get()).send(t).ok().unwrap();
-                        token.signal();
+                                token.signal();
                                 (a, Ok(()))
                             }
                         }
index 3b5fd5a57146010e08ed7e8a13f2d5a7bf327803..2a852fbcd57e37d3a9399776d34015d83e486f84 100644 (file)
@@ -24,7 +24,6 @@
 
 use boxed;
 use cell::UnsafeCell;
-use ptr;
 use rt;
 use sync::{StaticMutex, StaticCondvar};
 use sync::mpsc::{channel, Sender, Receiver};
@@ -97,7 +96,7 @@ pub fn boot<T, F>(&'static self, f: F, helper: fn(helper_signal::signal, Receive
     {
         unsafe {
             let _guard = self.lock.lock().unwrap();
-            if !*self.initialized.get() {
+            if *self.chan.get() as uint == 0 {
                 let (tx, rx) = channel();
                 *self.chan.get() = boxed::into_raw(box tx);
                 let (receive, send) = helper_signal::new();
@@ -113,8 +112,10 @@ pub fn boot<T, F>(&'static self, f: F, helper: fn(helper_signal::signal, Receive
                     self.cond.notify_one()
                 });
 
-                rt::at_exit(move|| { self.shutdown() });
+                rt::at_exit(move || { self.shutdown() });
                 *self.initialized.get() = true;
+            } else if *self.chan.get() as uint == 1 {
+                panic!("cannot continue usage after shutdown");
             }
         }
     }
@@ -129,7 +130,9 @@ pub fn send(&'static self, msg: M) {
             // Must send and *then* signal to ensure that the child receives the
             // message. Otherwise it could wake up and go to sleep before we
             // send the message.
-            assert!(!self.chan.get().is_null());
+            assert!(*self.chan.get() as uint != 0);
+            assert!(*self.chan.get() as uint != 1,
+                    "cannot continue usage after shutdown");
             (**self.chan.get()).send(msg).unwrap();
             helper_signal::signal(*self.signal.get() as helper_signal::signal);
         }
@@ -142,9 +145,13 @@ fn shutdown(&'static self) {
             // returns.
             let mut guard = self.lock.lock().unwrap();
 
+            let ptr = *self.chan.get();
+            if ptr as uint == 1 {
+                panic!("cannot continue usage after shutdown");
+            }
             // Close the channel by destroying it
-            let chan: Box<Sender<M>> = Box::from_raw(*self.chan.get());
-            *self.chan.get() = ptr::null_mut();
+            let chan = Box::from_raw(*self.chan.get());
+            *self.chan.get() = 1 as *mut Sender<M>;
             drop(chan);
             helper_signal::signal(*self.signal.get() as helper_signal::signal);
 
index ecd047710bb96c7d3bcdf2bbb3ca698c04acbf75..5e2a138fa63bacb208d23d83b9e6cba0159c84b2 100644 (file)
@@ -61,7 +61,6 @@
 use prelude::v1::*;
 
 use sync::atomic::{self, AtomicUsize, Ordering};
-use sync::{Mutex, Once, ONCE_INIT};
 
 use sys::thread_local as imp;
 
@@ -142,9 +141,6 @@ pub struct Key {
     key: atomic::ATOMIC_USIZE_INIT,
 };
 
-static INIT_KEYS: Once = ONCE_INIT;
-static mut KEYS: *mut Mutex<Vec<imp::Key>> = 0 as *mut _;
-
 impl StaticKey {
     /// Gets the value associated with this TLS key
     ///
index 74ab04978cbe264e4685f1e8cc73b9fe8660cbe3..7db64cfb936b5199813f1e9bf8ed84dbc23b6a00 100644 (file)
@@ -454,7 +454,7 @@ fn output(w: &mut Write, idx: int, addr: *mut libc::c_void,
 #[allow(dead_code)]
 fn output_fileline(w: &mut Write, file: &[u8], line: libc::c_int,
                    more: bool) -> io::Result<()> {
-    let file = str::from_utf8(file).ok().unwrap_or("<unknown>");
+    let file = str::from_utf8(file).unwrap_or("<unknown>");
     // prior line: "  ##: {:2$} - func"
     try!(write!(w, "      {:3$}at {}:{}", "", file, line, HEX_WIDTH));
     if more {
index c839ce65298721cea9d8d678f02aff6629d2f153..327ff3953aa32be92a87bb3dba126f177c4d75da 100644 (file)
@@ -20,6 +20,7 @@
 use old_io::{IoResult, FileStat, SeekStyle};
 use old_io::{Read, Truncate, SeekCur, SeekSet, ReadWrite, SeekEnd, Append};
 use old_io;
+use old_path::{Path, GenericPath};
 use libc::{self, c_int, c_void};
 use mem;
 use ptr;
@@ -391,7 +392,7 @@ fn test_file_desc() {
         let mut reader = FileDesc::new(reader, true);
         let mut writer = FileDesc::new(writer, true);
 
-        writer.write(b"test").ok().unwrap();
+        writer.write(b"test").unwrap();
         let mut buf = [0; 4];
         match reader.read(&mut buf) {
             Ok(4) => {
index ff29dea254fc42031c0169a1e029de1bfbd3f590..17c8b21f8b3bcf51cc6861253fd19bd7b67fc91c 100644 (file)
@@ -23,7 +23,7 @@ pub fn new() -> (signal, signal) {
 }
 
 pub fn signal(fd: libc::c_int) {
-    FileDesc::new(fd, false).write(&[0]).ok().unwrap();
+    FileDesc::new(fd, false).write(&[0]).unwrap();
 }
 
 pub fn close(fd: libc::c_int) {
index ef0274fdda92dc223d4e0ae42993a259bd06e82f..b6d2aca9a52365a4eed5a3d66bea8e920f06ad7e 100644 (file)
@@ -170,8 +170,15 @@ fn signal(active: &mut Vec<Box<Inner>>,
             1 => {
                 loop {
                     match messages.try_recv() {
+                        // Once we've been disconnected it means the main thread
+                        // is exiting (at_exit has run). We could still have
+                        // active timers for other threads, so we're just going
+                        // to drop them all on the floor. This is all we can
+                        // really do, however, to prevent resource leakage. The
+                        // remaining timers will likely start panicking quickly
+                        // as they attempt to re-use this thread but are
+                        // disallowed to do so.
                         Err(TryRecvError::Disconnected) => {
-                            assert!(active.len() == 0);
                             break 'outer;
                         }
 
@@ -197,7 +204,7 @@ fn signal(active: &mut Vec<Box<Inner>>,
 
                 // drain the file descriptor
                 let mut buf = [0];
-                assert_eq!(fd.read(&mut buf).ok().unwrap(), 1);
+                assert_eq!(fd.read(&mut buf).unwrap(), 1);
             }
 
             -1 if os::errno() == libc::EINTR as i32 => {}
index 8935f97ce5d02c0fa2a77df39cb06d9591bd863b..ffa4b37b48794c4a32f31a0a512cd69b241f3999 100644 (file)
 #![allow(deprecated)] // for old path for dynamic lib
 
 use prelude::v1::*;
+use io::prelude::*;
 
 use dynamic_lib::DynamicLibrary;
-use io;
-use io::prelude::*;
 use ffi::CStr;
 use intrinsics;
+use io;
 use libc;
 use mem;
+use old_path::Path;
 use ptr;
 use str;
 use sync::{StaticMutex, MUTEX_INIT};
index a218fb26fda7289552be5e1905c5e15a7f69152f..e7a01478908bcafa22ec5db15e360489f4ad286f 100644 (file)
@@ -22,6 +22,7 @@
 use sys;
 use sys_common::{self, mkerr_libc};
 
+use old_path::{Path, GenericPath};
 use old_io::{FilePermission, Write, UnstableFileStat, Open, FileAccess, FileMode};
 use old_io::{IoResult, IoError, FileStat, SeekStyle};
 use old_io::{Read, Truncate, SeekCur, SeekSet, ReadWrite, SeekEnd, Append};
index 2b03e9e743172a80f9898473d3844a78936c9ae5..17fdd6755c6d951bc08c34b8fc41a6196f72b8ec 100644 (file)
@@ -757,10 +757,10 @@ pub fn handle(&self) -> libc::HANDLE {
 
 impl Clone for UnixAcceptor {
     fn clone(&self) -> UnixAcceptor {
-        let name = to_utf16(&self.listener.name).ok().unwrap();
+        let name = to_utf16(&self.listener.name).unwrap();
         UnixAcceptor {
             inner: self.inner.clone(),
-            event: Event::new(true, false).ok().unwrap(),
+            event: Event::new(true, false).unwrap(),
             deadline: 0,
             listener: UnixListener {
                 name: self.listener.name.clone(),
index e465ecaa5f67e8f5085c257d1f8f60b25a58779a..e08a6e6b3cd7bfed95efd98fb9d314e275d6a16d 100644 (file)
@@ -24,7 +24,7 @@
 use old_io::{IoResult, IoError};
 use old_io;
 use os;
-use old_path::BytesContainer;
+use old_path::{BytesContainer, GenericPath};
 use ptr;
 use str;
 use sync::{StaticMutex, MUTEX_INIT};
index 30c483ac52fa261a4c3a0b6d4052b038ef6cd374..1359803070af384d03033e2df2fd0a229cae48e7 100644 (file)
@@ -138,9 +138,9 @@ unsafe fn init_dtors() {
     rt::at_exit(move|| {
         DTOR_LOCK.lock();
         let dtors = DTORS;
-        DTORS = ptr::null_mut();
+        DTORS = 1 as *mut _;
         Box::from_raw(dtors);
-        assert!(DTORS.is_null()); // can't re-init after destructing
+        assert!(DTORS as uint == 1); // can't re-init after destructing
         DTOR_LOCK.unlock();
     });
 }
@@ -148,6 +148,9 @@ unsafe fn init_dtors() {
 unsafe fn register_dtor(key: Key, dtor: Dtor) {
     DTOR_LOCK.lock();
     init_dtors();
+    assert!(DTORS as uint != 0);
+    assert!(DTORS as uint != 1,
+            "cannot create new TLS keys after the main thread has exited");
     (*DTORS).push((key, dtor));
     DTOR_LOCK.unlock();
 }
@@ -155,6 +158,9 @@ unsafe fn register_dtor(key: Key, dtor: Dtor) {
 unsafe fn unregister_dtor(key: Key) -> bool {
     DTOR_LOCK.lock();
     init_dtors();
+    assert!(DTORS as uint != 0);
+    assert!(DTORS as uint != 1,
+            "cannot unregister destructors after the main thread has exited");
     let ret = {
         let dtors = &mut *DTORS;
         let before = dtors.len();
@@ -241,7 +247,7 @@ unsafe fn run_dtors() {
         any_run = false;
         let dtors = {
             DTOR_LOCK.lock();
-            let ret = if DTORS.is_null() {
+            let ret = if DTORS as usize <= 1 {
                 Vec::new()
             } else {
                 (*DTORS).iter().map(|s| *s).collect()
index 91a7f694181f1e2ef5d34345057f489aa519a7f1..9bcae926eeabfca420ad56eb343ddabea3bf1973 100644 (file)
@@ -80,9 +80,10 @@ fn helper(input: libc::HANDLE, messages: Receiver<Req>, _: ()) {
                             None => {}
                         }
                     }
+                    // See the comment in unix::timer for why we don't have any
+                    // asserts here and why we're likely just leaving timers on
+                    // the floor as we exit.
                     Err(TryRecvError::Disconnected) => {
-                        assert_eq!(objs.len(), 1);
-                        assert_eq!(chans.len(), 0);
                         break 'outer;
                     }
                     Err(..) => break
index f542cb2323ebc4839f7747aabd8c0418c6c9da10..52f4cce4aa3bdff763e4d3fb0117589a5257467f 100644 (file)
@@ -29,7 +29,7 @@
 
 use prelude::v1::*;
 
-use old_io::{self, IoError, IoResult, MemReader};
+use old_io::{self, IoError, IoResult, MemReader, Reader};
 use iter::repeat;
 use libc::types::os::arch::extra::LPCVOID;
 use libc::{c_int, HANDLE, LPDWORD, DWORD, LPVOID};
index d2742d4b45a59658e3c9bd711b8027b9d5e182ba..ab74442cac99faa0a68aacd2150b80de1605552d 100644 (file)
 use marker::PhantomData;
 use rt::{self, unwind};
 use sync::{Mutex, Condvar, Arc};
+use sys::thread as imp;
+use sys_common::{stack, thread_info};
 use thunk::Thunk;
 use time::Duration;
 
-use sys::thread as imp;
-use sys_common::{stack, thread_info};
+#[allow(deprecated)] use old_io::Writer;
 
 /// Thread configuration. Provides detailed control over the properties
 /// and behavior of new threads.
@@ -869,7 +870,7 @@ fn test_try_panic_message_static_str() {
             Err(e) => {
                 type T = &'static str;
                 assert!(e.is::<T>());
-                assert_eq!(*e.downcast::<T>().ok().unwrap(), "static string");
+                assert_eq!(*e.downcast::<T>().unwrap(), "static string");
             }
             Ok(()) => panic!()
         }
@@ -883,7 +884,7 @@ fn test_try_panic_message_owned_str() {
             Err(e) => {
                 type T = String;
                 assert!(e.is::<T>());
-                assert_eq!(*e.downcast::<T>().ok().unwrap(), "owned string".to_string());
+                assert_eq!(*e.downcast::<T>().unwrap(), "owned string".to_string());
             }
             Ok(()) => panic!()
         }
@@ -897,9 +898,9 @@ fn test_try_panic_message_any() {
             Err(e) => {
                 type T = Box<Any + Send>;
                 assert!(e.is::<T>());
-                let any = e.downcast::<T>().ok().unwrap();
+                let any = e.downcast::<T>().unwrap();
                 assert!(any.is::<u16>());
-                assert_eq!(*any.downcast::<u16>().ok().unwrap(), 413);
+                assert_eq!(*any.downcast::<u16>().unwrap(), 413);
             }
             Ok(()) => panic!()
         }
index d7961d7da00f1e2e296bfd2e1f04c0a2b4a18398..06255f46779259a67bda3460369cbb3a4e3c0954 100644 (file)
@@ -64,7 +64,7 @@
 //!     fn encode(&self, s: &mut S) -> Result<(), E> {
 //!         s.emit_struct("Spanned", 2, |this| {
 //!             this.emit_struct_field("node", 0, |this| self.node.encode(this))
-//!                 .ok().unwrap();
+//!                 .unwrap();
 //!             this.emit_struct_field("span", 1, |this| self.span.encode(this))
 //!         })
 //!     }
@@ -79,9 +79,9 @@
 //!         d.read_struct("Spanned", 2, |this| {
 //!             Ok(Spanned {
 //!                 node: this.read_struct_field("node", 0, |this| Decodable::decode(this))
-//!                     .ok().unwrap(),
+//!                     .unwrap(),
 //!                 span: this.read_struct_field("span", 1, |this| Decodable::decode(this))
-//!                     .ok().unwrap(),
+//!                     .unwrap(),
 //!             })
 //!         })
 //!     }
index bb8f9da89171c96c8dea5b39f7de55a071ae2e1a..e0953a8ace68d5c646ee23fa436766fca91b9ad5 100644 (file)
@@ -623,7 +623,7 @@ fn bump_expecting_char<'a,D:fmt::Debug>(r: &mut StringReader<'a>,
         // find the integer representing the name
         self.scan_digits(base);
         let encoded_name : u32 = self.with_str_from(start_bpos, |s| {
-            num::from_str_radix(s, 10).ok().unwrap_or_else(|| {
+            num::from_str_radix(s, 10).unwrap_or_else(|_| {
                 panic!("expected digits representing a name, got {:?}, {}, range [{:?},{:?}]",
                       s, whence, start_bpos, self.last_pos);
             })
@@ -641,7 +641,7 @@ fn bump_expecting_char<'a,D:fmt::Debug>(r: &mut StringReader<'a>,
         let start_bpos = self.last_pos;
         self.scan_digits(base);
         let encoded_ctxt : ast::SyntaxContext = self.with_str_from(start_bpos, |s| {
-            num::from_str_radix(s, 10).ok().unwrap_or_else(|| {
+            num::from_str_radix(s, 10).unwrap_or_else(|_| {
                 panic!("expected digits representing a ctxt, got {:?}, {}", s, whence);
             })
         });
index 3c269cc485dad908aec4fda4bb09a50625460ad1..309320b52ffe4aa641abdf485537f5452eb7f64a 100644 (file)
@@ -181,21 +181,24 @@ pub fn new(out: T) -> Option<Box<Terminal<T>+Send+'static>> {
             }
         };
 
-        let entry = open(&term[..]);
-        if entry.is_err() {
-            if env::var("MSYSCON").ok().map_or(false, |s| {
-                    "mintty.exe" == s
-                }) {
-                // msys terminal
-                return Some(box TerminfoTerminal {out: out,
-                                                  ti: msys_terminfo(),
-                                                  num_colors: 8} as Box<Terminal<T>+Send>);
-            }
-            debug!("error finding terminfo entry: {:?}", entry.err().unwrap());
-            return None;
-        }
+        let mut file = match open(&term[..]) {
+            Ok(f) => f,
+            Err(err) => return match env::var("MSYSCON") {
+                Ok(ref val) if &val[..] == "mintty.exe" => {
+                    // msys terminal
+                    Some(box TerminfoTerminal{
+                        out: out,
+                        ti: msys_terminfo(),
+                        num_colors: 8,
+                    } as Box<Terminal<T>+Send>)
+                },
+                _ => {
+                    debug!("error finding terminfo entry: {:?}", err);
+                    None
+                },
+            },
+        };
 
-        let mut file = entry.unwrap();
         let ti = parse(&mut file, false);
         if ti.is_err() {
             debug!("error parsing terminfo entry: {:?}", ti.err().unwrap());
index 84d86c5746c0bcfdaa81c9e62b630c5625fbc8fb..e20e6d4f29bfab982cfcd71846711eee6f78cae8 100644 (file)
@@ -333,7 +333,7 @@ pub fn winsorize<T: Float + FromPrimitive>(samples: &mut [T], pct: T) {
 mod tests {
     use stats::Stats;
     use stats::Summary;
-    use std::old_io;
+    use std::old_io::{self, Writer};
     use std::f64;
 
     macro_rules! assert_approx_eq {
index 6cd94ee5602aa5ccf3db96b0b1f3ccda3dcae6ef..03fe2fd94dd527587e50ea7f88f3b480e582f1f4 100644 (file)
@@ -27,8 +27,7 @@ fn bar() { }
 fn baz() { }
 
 pub fn test() {
-    let none: Option<&Path> = None; // appease the typechecker
-    let lib = DynamicLibrary::open(none).unwrap();
+    let lib = DynamicLibrary::open(None).unwrap();
     unsafe {
         assert!(lib.symbol::<int>("foo").is_ok());
         assert!(lib.symbol::<int>("baz").is_err());
index 4c3b3f42acaa9470b77c294bd9525e8adcf878ab..c2ea097ed751f73940981847e20f29821dc8ab8c 100644 (file)
@@ -13,7 +13,8 @@
 
 #![feature(unboxed_closures)]
 
-use std::old_io::File;
+use std::old_io::*;
+use std::old_path::{Path, GenericPath};
 use std::iter::repeat;
 use std::mem::swap;
 use std::env;
index 9cee75757aa1c13a6805e00424a950173ccfa6d2..289f05a299b9942205dd8c763033d1d99ea02a1a 100644 (file)
@@ -39,7 +39,7 @@
 // OF THE POSSIBILITY OF SUCH DAMAGE.
 
 use std::cmp::min;
-use std::old_io::{stdout, IoResult};
+use std::old_io::*;
 use std::iter::repeat;
 use std::env;
 use std::slice::bytes::copy_memory;
index e15f9d99ff691fa4f3f92d49633e7d0cba306541..df839fc27eec8ee6d8495dfd2a5e64f9fa150992 100644 (file)
@@ -39,8 +39,9 @@
 // OF THE POSSIBILITY OF SUCH DAMAGE.
 
 use std::cmp::min;
-use std::old_io::{BufferedWriter, File};
+use std::old_io::*;
 use std::old_io;
+use std::old_path::Path;
 use std::num::Float;
 use std::env;
 
index 3ea4a10ea8169f7d148f287b937d599616773f1a..88c9f43f6ec7ca434334ab32cf7e7c8e3592aafb 100644 (file)
@@ -147,7 +147,7 @@ fn make_sequence_processor(sz: uint,
 
 // given a FASTA file on stdin, process sequence THREE
 fn main() {
-    use std::old_io::{stdio, MemReader, BufferedReader};
+    use std::old_io::*;
 
     let rdr = if env::var_os("RUST_BENCH").is_some() {
         let foo = include_bytes!("shootout-k-nucleotide.data");
index bddf615322816d40e1212465d46b01e9d2503be0..128c92921fa8616162c88743baf74f3ee01218a3 100644 (file)
@@ -43,6 +43,7 @@
 // ignore-pretty very bad with line comments
 
 use std::old_io;
+use std::old_io::*;
 use std::env;
 use std::simd::f64x2;
 use std::sync::Arc;
index 33d959dfe93e35f592320a4913dd69d3c7c3a313..93aa5f2571bfbd30a138d928c0c3c0feb87735d0 100644 (file)
@@ -45,7 +45,7 @@
 extern crate libc;
 
 use std::old_io::stdio::{stdin_raw, stdout_raw};
-use std::old_io::{IoResult, EndOfFile};
+use std::old_io::*;
 use std::ptr::{copy_memory, Unique};
 use std::thread;
 
diff --git a/src/test/compile-fail-fulldeps/gated-macro-reexports.rs b/src/test/compile-fail-fulldeps/gated-macro-reexports.rs
new file mode 100644 (file)
index 0000000..a88445b
--- /dev/null
@@ -0,0 +1,22 @@
+// Copyright 2014 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.
+
+// Test that macro reexports item are gated by `macro_reexport` feature gate.
+
+// aux-build:macro_reexport_1.rs
+// ignore-stage1
+
+#![crate_type = "dylib"]
+
+#[macro_reexport(reexported)]
+#[macro_use] #[no_link]
+extern crate macro_reexport_1;
+//~^ ERROR macros reexports are experimental and possibly buggy
+//~| HELP add #![feature(macro_reexport)] to the crate attributes to enable
index e59bd62d178549133ae66fe02cd04cc1cb21bbba..5ddde6460b01f9504bf283aa53675e186bb65bf2 100644 (file)
@@ -10,6 +10,8 @@
 
 #![feature(unboxed_closures)]
 
+use std::io::Read;
+
 fn to_fn_once<A,F:FnOnce<A>>(f: F) -> F { f }
 
 fn main() {
@@ -17,7 +19,7 @@ fn main() {
     to_fn_once(move|| { x = 2; });
     //~^ ERROR: cannot assign to immutable captured outer variable
 
-    let s = std::old_io::stdin();
-    to_fn_once(move|| { s.read_to_end(); });
+    let s = std::io::stdin();
+    to_fn_once(move|| { s.read_to_end(&mut Vec::new()); });
     //~^ ERROR: cannot borrow immutable captured outer variable
 }
diff --git a/src/test/compile-fail/gated-box-patterns.rs b/src/test/compile-fail/gated-box-patterns.rs
new file mode 100644 (file)
index 0000000..abaa256
--- /dev/null
@@ -0,0 +1,22 @@
+// 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.
+
+// Test that patterns including the box syntax are gated by `box_patterns` feature gate.
+
+fn main() {
+    let x = Box::new(1);
+
+    match x {
+        box 1 => (),
+        //~^ box pattern syntax is experimental
+        //~| add #![feature(box_patterns)] to the crate attributes to enable
+        _     => ()
+    };
+}
diff --git a/src/test/compile-fail/gated-box-syntax.rs b/src/test/compile-fail/gated-box-syntax.rs
new file mode 100644 (file)
index 0000000..3e08c1f
--- /dev/null
@@ -0,0 +1,17 @@
+// 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.
+
+// Test that the use of the box syntax is gated by `box_syntax` feature gate.
+
+fn main() {
+    let x = box 3;
+    //~^ ERROR box expression syntax is experimental; you can call `Box::new` instead.
+    //~| HELP add #![feature(box_syntax)] to the crate attributes to enable
+}
diff --git a/src/test/compile-fail/gated-simd-ffi.rs b/src/test/compile-fail/gated-simd-ffi.rs
new file mode 100644 (file)
index 0000000..c0a251e
--- /dev/null
@@ -0,0 +1,27 @@
+// 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.
+
+// Test that the use of smid types in the ffi is gated by `smid_ffi` feature gate.
+
+#![feature(simd)]
+
+#[repr(C)]
+#[derive(Copy)]
+#[simd]
+pub struct f32x4(f32, f32, f32, f32);
+
+#[allow(dead_code)]
+extern {
+    fn foo(x: f32x4);
+    //~^ ERROR use of SIMD type `f32x4` in FFI is highly experimental and may result in invalid code
+    //~| HELP add #![feature(simd_ffi)] to the crate attributes to enable
+}
+
+fn main() {}
index 09d7293a3d0c020202b99da5a11299e531d68e74..f78786a2889dab5df60ce1d813fef94b1f00b6b8 100644 (file)
@@ -8,15 +8,15 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use std::old_io;
+use std::io::{self, Read};
 use std::vec;
 
 pub struct Container<'a> {
-    reader: &'a mut Reader
+    reader: &'a mut Read
 }
 
 impl<'a> Container<'a> {
-    pub fn wrap<'s>(reader: &'s mut Reader) -> Container<'s> {
+    pub fn wrap<'s>(reader: &'s mut io::Read) -> Container<'s> {
         Container { reader: reader }
     }
 
@@ -26,8 +26,8 @@ pub fn read_to(&mut self, vec: &mut [u8]) {
 }
 
 pub fn for_stdin<'a>() -> Container<'a> {
-    let mut r = old_io::stdin();
-    Container::wrap(&mut r as &mut Reader)
+    let mut r = io::stdin();
+    Container::wrap(&mut r as &mut io::Read)
 }
 
 fn main() {
index 775d38c8b3044ca917d8729799552664e21e90d2..fb1e03c234d76a3fafe2ecb151ab2d82b54e65d9 100644 (file)
@@ -35,7 +35,7 @@ fn r(x:int) -> r {
 
 fn main() {
     error!("whatever");
-    let _t = thread::spawn(move|| {
+    let _t = thread::scoped(move|| {
       let _i = r(5);
     });
     panic!();
index 89352a16d8ba2fe3792b017c9f66bebae9cd9020..fd69d2786b8d0800adb74bc000a7b73b638e1c0f 100644 (file)
@@ -9,7 +9,10 @@
 // except according to those terms.
 
 use std::env;
-use std::old_io::{File, Command};
+use std::fs::File;
+use std::process::Command;
+use std::io::Write;
+use std::path::Path;
 
 // creates broken.rs, which has the Ident \x00name_0,ctxt_0\x00
 // embedded within it, and then attempts to compile broken.rs with the
@@ -22,21 +25,18 @@ fn main() {
 
     let main_file = tmpdir.join("broken.rs");
     let _ = File::create(&main_file).unwrap()
-        .write_str("pub fn main() {
+        .write_all(b"pub fn main() {
                    let \x00name_0,ctxt_0\x00 = 3;
                    println!(\"{}\", \x00name_0,ctxt_0\x00);
-        }");
+        }").unwrap();
 
     // rustc is passed to us with --out-dir and -L etc., so we
     // can't exec it directly
     let result = Command::new("sh")
         .arg("-c")
-        .arg(&format!("{} {}",
-                      rustc,
-                      main_file.as_str()
-                      .unwrap()))
+        .arg(&format!("{} {}", rustc, main_file.display()))
         .output().unwrap();
-    let err = String::from_utf8_lossy(&result.error);
+    let err = String::from_utf8_lossy(&result.stderr);
 
     // positive test so that this test will be updated when the
     // compiler changes.
index 0f759efb02539bc874d624f4511cd767b819f89e..86eed9dbe0a92e1ae9a151d137496261a68ced11 100644 (file)
@@ -10,6 +10,7 @@
 
 use std::dynamic_lib::DynamicLibrary;
 use std::os;
+use std::old_path::Path;
 
 pub fn main() {
     unsafe {
index ce3e69918ffee927e8c77037456fcc472e6b420c..1826e035e245805964bf7ec8bc91d02ee85d4cb7 100644 (file)
@@ -8,9 +8,12 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use std::{char, env};
-use std::old_io::{File, Command};
+use std::fs::File;
+use std::io::prelude::*;
+use std::path::Path;
+use std::process::Command;
 use std::rand::{thread_rng, Rng};
+use std::{char, env};
 
 // creates unicode_input_multiple_files_{main,chars}.rs, where the
 // former imports the latter. `_chars` just contains an identifier
@@ -40,7 +43,7 @@ fn main() {
     let main_file = tmpdir.join("unicode_input_multiple_files_main.rs");
     {
         let _ = File::create(&main_file).unwrap()
-            .write_str("mod unicode_input_multiple_files_chars;");
+            .write_all(b"mod unicode_input_multiple_files_chars;").unwrap();
     }
 
     for _ in 0..100 {
@@ -48,7 +51,7 @@ fn main() {
             let randoms = tmpdir.join("unicode_input_multiple_files_chars.rs");
             let mut w = File::create(&randoms).unwrap();
             for _ in 0..30 {
-                let _ = w.write_char(random_char());
+                write!(&mut w, "{}", random_char()).unwrap();
             }
         }
 
@@ -58,10 +61,9 @@ fn main() {
                              .arg("-c")
                              .arg(&format!("{} {}",
                                            rustc,
-                                           main_file.as_str()
-                                                    .unwrap()))
+                                           main_file.display()))
                              .output().unwrap();
-        let err = String::from_utf8_lossy(&result.error);
+        let err = String::from_utf8_lossy(&result.stderr);
 
         // positive test so that this test will be updated when the
         // compiler changes.
index a6cb9fe0324d7d7c5cde512aa9ce39506a04a46e..9ed20ccaea5c97c07dffc6abf6a60c2d1f759e5d 100644 (file)
@@ -8,8 +8,11 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use std::old_io::{File, Command};
+use std::fs::File;
+use std::io::prelude::*;
 use std::iter::repeat;
+use std::path::Path;
+use std::process::Command;
 use std::rand::{thread_rng, Rng};
 use std::{char, env};
 
@@ -54,11 +57,11 @@ fn main() {
                              .arg("-c")
                              .arg(&format!("{} {}",
                                            rustc,
-                                           main_file.as_str()
+                                           main_file.to_str()
                                                     .unwrap()))
                              .output().unwrap();
 
-        let err = String::from_utf8_lossy(&result.error);
+        let err = String::from_utf8_lossy(&result.stderr);
 
         // the span should end the line (e.g no extra ~'s)
         let expected_span = format!("^{}\n", repeat("~").take(n - 1)
@@ -73,17 +76,16 @@ fn main() {
     }
 
     // Extra characters. Every line is preceded by `filename:lineno <actual code>`
-    let offset = main_file.as_str().unwrap().len() + 3;
+    let offset = main_file.to_str().unwrap().len() + 3;
 
     let result = Command::new("sh")
                          .arg("-c")
                          .arg(format!("{} {}",
                                       rustc,
-                                      main_file.as_str()
-                                               .unwrap()))
+                                      main_file.display()))
                          .output().unwrap();
 
-    let err = String::from_utf8_lossy(result.error.as_slice());
+    let err = String::from_utf8_lossy(&result.stderr);
 
     // Test both the length of the snake and the leading spaces up to it
 
index 088fa19356c4e4a941e05b77dc872640262033b5..2a74e36aff3ddd8f34beb5dd2b8ad0a2b7f33e26 100644 (file)
@@ -11,7 +11,8 @@
 // compile-flags:-g
 // ignore-pretty as this critically relies on line numbers
 
-use std::old_io::stderr;
+use std::io;
+use std::io::prelude::*;
 use std::env;
 
 #[path = "backtrace-debuginfo-aux.rs"] mod aux;
@@ -124,17 +125,18 @@ fn check_trace(output: &str, error: &str) {
 
 fn run_test(me: &str) {
     use std::str;
-    use std::old_io::process::Command;
+    use std::process::Command;
 
     let mut template = Command::new(me);
     template.env("RUST_BACKTRACE", "1");
 
     let mut i = 0;
     loop {
-        let p = template.clone().arg(i.to_string()).spawn().unwrap();
-        let out = p.wait_with_output().unwrap();
-        let output = str::from_utf8(&out.output).unwrap();
-        let error = str::from_utf8(&out.error).unwrap();
+        let out = Command::new(me)
+                          .env("RUST_BACKTRACE", "1")
+                          .arg(i.to_string()).output().unwrap();
+        let output = str::from_utf8(&out.stdout).unwrap();
+        let error = str::from_utf8(&out.stderr).unwrap();
         if out.status.success() {
             assert!(output.contains("done."), "bad output for successful run: {}", output);
             break;
@@ -150,7 +152,7 @@ fn main() {
     let args: Vec<String> = env::args().collect();
     if args.len() >= 2 {
         let case = args[1].parse().unwrap();
-        writeln!(&mut stderr(), "test case {}", case).unwrap();
+        writeln!(&mut io::stderr(), "test case {}", case).unwrap();
         outer(case, pos!());
         println!("done.");
     } else {
index 70cc0463a6e11bd927f153491775d0f9b1d070e3..be5bb628b7294f3e1b43cca2edffabb2043904f7 100644 (file)
@@ -19,7 +19,7 @@
 use log::{set_logger, Logger, LogRecord};
 use std::sync::mpsc::channel;
 use std::fmt;
-use std::old_io::{ChanReader, ChanWriter};
+use std::old_io::{ChanReader, ChanWriter, Reader, Writer};
 use std::thread::Thread;
 
 struct MyWriter(ChanWriter);
index 841aaa94e9b552e9f4de847450136245e7dff80e..35fe447c5e657335dc32faa7ae5f466880770591 100644 (file)
 
 // no-pretty-expanded
 
-#![allow(unused_must_use, dead_code, deprecated)]
-use std::old_io::MemWriter;
+use std::io::Write;
 use std::fmt;
 
 struct Foo<'a> {
-    writer: &'a mut (Writer+'a),
+    writer: &'a mut (Write+'a),
     other: &'a str,
 }
 
@@ -32,8 +31,8 @@ fn borrowing_writer_from_struct_and_formatting_struct_field(foo: Foo) {
 }
 
 fn main() {
-    let mut w = MemWriter::new();
-    write!(&mut w as &mut Writer, "");
+    let mut w = Vec::new();
+    write!(&mut w as &mut Write, "");
     write!(&mut w, ""); // should coerce
     println!("ok");
 
index 3f226a1985e78e5d3ceccb37437d4b96067b9506..9e05f38af7a4889493ca692612af97ce5c00b89e 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+// ignore-aarch64
+
 extern crate libc;
 
 use std::mem;
index 26a0abc76aee2a668fa4d38e4a801e2fdcc2adf2..01e305581f14e6129e7ffb4d23eea60556b58b8a 100644 (file)
@@ -31,7 +31,7 @@ fn into_iter(self) -> I {
 
 fn desugared_for_loop_bad(byte: u8) -> u8 {
     let mut result = 0;
-    let mut x = IntoIterator::into_iter(range(0, u8::BITS));
+    let mut x = IntoIterator::into_iter(0..u8::BITS);
     let mut y = Iterator::next(&mut x);
     let mut z = y.unwrap();
     byte >> z;
index f1c747eca68406c82bcb7b97738feeabf9c9dde8..bd2ddc6b9b214db01c1100d7bfb8eb758febfe88 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+// ignore-aarch64
+
 use std::env;
 use std::io::prelude::*;
 use std::io;
index ed0e3bddbe515b8d3a5b6abce07d2528ea72ac61..098fa54207f39d8e592fed0feac8daa076444f0f 100644 (file)
@@ -9,12 +9,13 @@
 // except according to those terms.
 
 use std::env;
-use std::old_io::{stdio, Command};
+use std::process::Command;
+use std::io::{self, Write};
 
 fn main() {
     let mut args = env::args();
     if args.len() > 1 {
-        let mut out = stdio::stdout();
+        let mut out = io::stdout();
         out.write(&['a' as u8; 128 * 1024]).unwrap();
     } else {
         let out = Command::new(&args.next().unwrap()).arg("child").output();
index 92d8dfa2cf9a975bc306078ebdfeebe5267c1f63..9562d113ada7059e5d7c487e4225ddb938ea74f0 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+// ignore-aarch64
+
 use std::process::Command;
 use std::env;
 
index 2f0b8c9f19beb1c0f57ded4062ceb73d33ca23bc..6d32ffd6c43ca31791d0889a54a5ac4172ea7ef1 100644 (file)
@@ -8,31 +8,29 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use std::old_io::BufReader;
-use std::old_io::BufferedReader;
-use std::old_io::File;
-use std::old_io::IoResult;
+use std::fs::File;
+use std::io::{self, BufReader, Read};
 
-struct Lexer<R: Reader>
+struct Lexer<R: Read>
 {
-    reader: BufferedReader<R>,
+    reader: BufReader<R>,
 }
 
-impl<R: Reader> Lexer<R>
+impl<R: Read> Lexer<R>
 {
     pub fn new_from_reader(r: R) -> Lexer<R>
     {
-        Lexer{reader: BufferedReader::new(r)}
+        Lexer{reader: BufReader::new(r)}
     }
 
-    pub fn new_from_file(p: Path) -> IoResult<Lexer<File>>
+    pub fn new_from_file(p: &str) -> io::Result<Lexer<File>>
     {
-        Ok(Lexer::new_from_reader(try!(File::open(&p))))
+        Ok(Lexer::new_from_reader(try!(File::open(p))))
     }
 
-    pub fn new_from_str<'a>(s: &'a str) -> Lexer<BufReader<'a>>
+    pub fn new_from_str<'a>(s: &'a str) -> Lexer<&'a [u8]>
     {
-        Lexer::new_from_reader(BufReader::new(s.as_bytes()))
+        Lexer::new_from_reader(s.as_bytes())
     }
 }
 
index ba107dd2cf9a2457b8b41db94e66834b9b56847f..fe9ae022d88b4cc5a372ec970e5991175dc9a5c8 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+// ignore-aarch64
+
 #[cfg(unix)]
 fn main() {
     use std::process::Command;
index 0d482548cc0bf933241d8a6f7407b83e7cba93ec..83b91c93a865f57706d9a81a2b6a55e218bb832a 100644 (file)
 // A reduced version of the rustbook ice. The problem this encountered
 // had to do with trans ignoring binders.
 
-#![feature(associated_types)]
-#![feature(macro_rules)]
-
 use std::iter;
 use std::os;
-use std::old_io::File;
+use std::fs::File;
+use std::io::prelude::*;
+use std::env;
+use std::path::Path;
 
-#[allow(unused)]
-pub fn parse_summary<R: Reader>(_: R, _: &Path) {
+pub fn parse_summary<R: Read>(_: R, _: &Path) {
      let path_from_root = Path::new("");
-     Path::new(iter::repeat("../")
+     Path::new(&iter::repeat("../")
                .take(path_from_root.components().count() - 1)
                .collect::<String>());
  }
 
-fn main() {
-    let cwd = os::getcwd().unwrap();
+fn foo() {
+    let cwd = env::current_dir().unwrap();
     let src = cwd.clone();
-    let summary = File::open(&src.join("SUMMARY.md"));
+    let summary = File::open(&src.join("SUMMARY.md")).unwrap();
     let _ = parse_summary(summary, &src);
 }
+
+fn main() {}
index 049e08d2b94f5b9838a44f8e34c23f8b62e050ab..c5badb614948f4cc738be3a1c6f94127a90e7b31 100644 (file)
@@ -8,24 +8,27 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-// ignore-android
-// ignore-windows
-
 // Regression test for #20797.
 
 use std::default::Default;
-use std::old_io::IoResult;
-use std::old_io::fs;
-use std::old_io::fs::PathExtensions;
+use std::io;
+use std::fs;
+use std::path::{PathBuf, Path};
+
+pub trait PathExtensions {
+    fn is_dir(&self) -> bool { false }
+}
+
+impl PathExtensions for PathBuf {}
 
 /// A strategy for acquiring more subpaths to walk.
 pub trait Strategy {
-  type P: PathExtensions;
-  /// Get additional subpaths from a given path.
-  fn get_more(&self, item: &Self::P) -> IoResult<Vec<Self::P>>;
-  /// Determine whether a path should be walked further.
-  /// This is run against each item from `get_more()`.
-  fn prune(&self, p: &Self::P) -> bool;
+    type P: PathExtensions;
+    /// Get additional subpaths from a given path.
+    fn get_more(&self, item: &Self::P) -> io::Result<Vec<Self::P>>;
+    /// Determine whether a path should be walked further.
+    /// This is run against each item from `get_more()`.
+    fn prune(&self, p: &Self::P) -> bool;
 }
 
 /// The basic fully-recursive strategy. Nothing is pruned.
@@ -33,10 +36,12 @@ pub trait Strategy {
 pub struct Recursive;
 
 impl Strategy for Recursive {
-  type P = Path;
-  fn get_more(&self, p: &Path) -> IoResult<Vec<Path>> { fs::readdir(p) }
+    type P = PathBuf;
+    fn get_more(&self, p: &PathBuf) -> io::Result<Vec<PathBuf>> {
+        Ok(fs::read_dir(p).unwrap().map(|s| s.unwrap().path()).collect())
+    }
 
-  fn prune(&self, _: &Path) -> bool { false }
+    fn prune(&self, _: &PathBuf) -> bool { false }
 }
 
 /// A directory walker of `P` using strategy `S`.
@@ -46,49 +51,51 @@ pub struct Subpaths<S: Strategy> {
 }
 
 impl<S: Strategy> Subpaths<S> {
-  /// Create a directory walker with a root path and strategy.
-  pub fn new(p: &S::P, strategy: S) -> IoResult<Subpaths<S>> {
-    let stack = try!(strategy.get_more(p));
-    Ok(Subpaths { stack: stack, strategy: strategy })
-  }
+    /// Create a directory walker with a root path and strategy.
+    pub fn new(p: &S::P, strategy: S) -> io::Result<Subpaths<S>> {
+        let stack = try!(strategy.get_more(p));
+        Ok(Subpaths { stack: stack, strategy: strategy })
+    }
 }
 
 impl<S: Default + Strategy> Subpaths<S> {
-  /// Create a directory walker with a root path and a default strategy.
-  pub fn walk(p: &S::P) -> IoResult<Subpaths<S>> {
-      Subpaths::new(p, Default::default())
-  }
+    /// Create a directory walker with a root path and a default strategy.
+    pub fn walk(p: &S::P) -> io::Result<Subpaths<S>> {
+        Subpaths::new(p, Default::default())
+    }
 }
 
 impl<S: Default + Strategy> Default for Subpaths<S> {
-  fn default() -> Subpaths<S> {
-    Subpaths { stack: Vec::new(), strategy: Default::default() }
-  }
+    fn default() -> Subpaths<S> {
+        Subpaths { stack: Vec::new(), strategy: Default::default() }
+    }
 }
 
 impl<S: Strategy> Iterator for Subpaths<S> {
-  type Item = S::P;
-  fn next (&mut self) -> Option<S::P> {
-    let mut opt_path = self.stack.pop();
-    while opt_path.is_some() && self.strategy.prune(opt_path.as_ref().unwrap()) {
-      opt_path = self.stack.pop();
-    }
-    match opt_path {
-      Some(path) => {
-        if PathExtensions::is_dir(&path) {
-          let result = self.strategy.get_more(&path);
-          match result {
-            Ok(dirs) => { self.stack.extend(dirs.into_iter()); },
-            Err(..) => { }
-          }
+    type Item = S::P;
+    fn next (&mut self) -> Option<S::P> {
+        let mut opt_path = self.stack.pop();
+        while opt_path.is_some() && self.strategy.prune(opt_path.as_ref().unwrap()) {
+            opt_path = self.stack.pop();
+        }
+        match opt_path {
+            Some(path) => {
+                if path.is_dir() {
+                    let result = self.strategy.get_more(&path);
+                    match result {
+                        Ok(dirs) => { self.stack.extend(dirs.into_iter()); },
+                        Err(..) => { }
+                    }
+                }
+                Some(path)
+            }
+            None => None,
         }
-        Some(path)
-      }
-      None => None,
     }
-  }
 }
 
-fn main() {
-  let mut walker: Subpaths<Recursive> = Subpaths::walk(&Path::new("/home")).unwrap();
+fn foo() {
+    let mut walker: Subpaths<Recursive> = Subpaths::walk(&PathBuf::new("/home")).unwrap();
 }
+
+fn main() {}
diff --git a/src/test/run-pass/issue-23550.rs b/src/test/run-pass/issue-23550.rs
new file mode 100644 (file)
index 0000000..97357c1
--- /dev/null
@@ -0,0 +1,39 @@
+// 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)]
+#![allow(warnings)]
+
+use std::intrinsics;
+
+#[derive(Copy)]
+struct Wrap(i64);
+
+// These volatile and atomic intrinsics used to cause an ICE
+
+unsafe fn test_bool(p: &mut bool, v: bool) {
+    intrinsics::volatile_load(p);
+    intrinsics::volatile_store(p, v);
+    intrinsics::atomic_load(p);
+    intrinsics::atomic_cxchg(p, v, v);
+    intrinsics::atomic_store(p, v);
+    intrinsics::atomic_xchg(p, v);
+}
+
+unsafe fn test_immediate_fca(p: &mut Wrap, v: Wrap) {
+    intrinsics::volatile_load(p);
+    intrinsics::volatile_store(p, v);
+    intrinsics::atomic_load(p);
+    intrinsics::atomic_cxchg(p, v, v);
+    intrinsics::atomic_store(p, v);
+    intrinsics::atomic_xchg(p, v);
+}
+
+fn main() {}
index 3193e5c5fc2477f9005f9ba79580d93c41de4444..d30a0be5feeb5873e89ca062c59e89e1d914ad28 100644 (file)
@@ -10,7 +10,7 @@
 
 // This used to cause an ICE because the retslot for the "return" had the wrong type
 fn testcase<'a>() -> Box<Iterator<Item=usize> + 'a> {
-    return Box::new(range(0, 3).map(|i| { return i; }));
+    return Box::new((0..3).map(|i| { return i; }));
 }
 
 fn main() {
diff --git a/src/test/run-pass/match-ref-unsized.rs b/src/test/run-pass/match-ref-unsized.rs
new file mode 100644 (file)
index 0000000..4de0282
--- /dev/null
@@ -0,0 +1,20 @@
+// 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.
+
+// Binding unsized expressions to ref patterns
+
+pub fn main() {
+    let ref a = *"abcdef";
+    assert_eq!(a, "abcdef");
+
+    match *"12345" {
+        ref b => { assert_eq!(b, "12345") }
+    }
+}
index 3e5f84fa26fe075769334e213e478b5acf3234e5..72998133af19ddecd89565b0b708e0b050854acd 100644 (file)
@@ -16,6 +16,8 @@
 // non-ASCII characters.  The child process ensures all the strings are
 // intact.
 
+// ignore-aarch64
+
 use std::io::prelude::*;
 use std::io;
 use std::fs;
@@ -26,9 +28,9 @@
 
 fn main() {
     let my_args = env::args().collect::<Vec<_>>();
-    let my_cwd  = PathBuf::new(os::getcwd().unwrap().as_str().unwrap());
+    let my_cwd  = env::current_dir().unwrap();
     let my_env  = env::vars().collect::<Vec<_>>();
-    let my_path = PathBuf::new(os::self_exe_name().unwrap().as_str().unwrap());
+    let my_path = env::current_exe().unwrap();
     let my_dir  = my_path.parent().unwrap();
     let my_ext  = my_path.extension().and_then(|s| s.to_str()).unwrap_or("");
 
index e0810d395558ef38bd686e7bb692c455018e5494..656fe89896932bf159e146b975d7abada6dcb9ee 100644 (file)
 // This test can't be a unit test in std,
 // because it needs TempDir, which is in extra
 
-extern crate libc;
-
 use std::ffi::CString;
-use std::old_io::TempDir;
-use std::old_io::fs::PathExtensions;
-use std::old_io::fs;
-use std::old_io;
-use std::os;
+use std::fs::{self, TempDir, File, PathExt};
 
 fn rename_directory() {
-    unsafe {
-        static U_RWX: i32 = (libc::S_IRUSR | libc::S_IWUSR | libc::S_IXUSR) as i32;
-
-        let tmpdir = TempDir::new("rename_directory").ok().expect("rename_directory failed");
-        let tmpdir = tmpdir.path();
-        let old_path = tmpdir.join_many(&["foo", "bar", "baz"]);
-        fs::mkdir_recursive(&old_path, old_io::USER_RWX);
-        let test_file = &old_path.join("temp.txt");
-
-        /* Write the temp input file */
-        let fromp = CString::new(test_file.as_vec()).unwrap();
-        let modebuf = CString::new(&b"w+b"[..]).unwrap();
-        let ostream = libc::fopen(fromp.as_ptr(), modebuf.as_ptr());
-        assert!((ostream as uint != 0));
-        let s = "hello".to_string();
-        let buf = CString::new(&b"hello"[..]).unwrap();
-        let write_len = libc::fwrite(buf.as_ptr() as *mut _,
-                                     1_usize as libc::size_t,
-                                     (s.len() + 1_usize) as libc::size_t,
-                                     ostream);
-        assert_eq!(write_len, (s.len() + 1) as libc::size_t);
-        assert_eq!(libc::fclose(ostream), (0_usize as libc::c_int));
-
-        let new_path = tmpdir.join_many(&["quux", "blat"]);
-        fs::mkdir_recursive(&new_path, old_io::USER_RWX);
-        fs::rename(&old_path, &new_path.join("newdir"));
-        assert!(new_path.join("newdir").is_dir());
-        assert!(new_path.join_many(&["newdir", "temp.txt"]).exists());
-    }
+    let tmpdir = TempDir::new("rename_directory").ok().expect("rename_directory failed");
+    let tmpdir = tmpdir.path();
+    let old_path = tmpdir.join("foo/bar/baz");
+    fs::create_dir_all(&old_path).unwrap();
+    let test_file = &old_path.join("temp.txt");
+
+    File::create(test_file).unwrap();
+
+    let new_path = tmpdir.join("quux/blat");
+    fs::create_dir_all(&new_path).unwrap();
+    fs::rename(&old_path, &new_path.join("newdir"));
+    assert!(new_path.join("newdir").is_dir());
+    assert!(new_path.join("newdir/temp.txt").exists());
 }
 
 pub fn main() { rename_directory() }
index d1428c6be19ef880f06645c74a59908b90dd7b04..665b582581cfb88f42745995fd31e183c76452e0 100644 (file)
 // Be sure that when a SIGPIPE would have been received that the entire process
 // doesn't die in a ball of fire, but rather it's gracefully handled.
 
-use std::os;
 use std::env;
-use std::old_io::PipeStream;
-use std::old_io::Command;
+use std::io::prelude::*;
+use std::io;
+use std::process::{Command, Stdio};
 
 fn test() {
-    let os::Pipe { reader, writer } = unsafe { os::pipe().unwrap() };
-    let reader = PipeStream::open(reader);
-    let mut writer = PipeStream::open(writer);
-    drop(reader);
-
-    let _ = writer.write(&[1]);
+    let _ = io::stdin().read_line(&mut String::new());
+    io::stdout().write(&[1]);
+    assert!(io::stdout().flush().is_err());
 }
 
 fn main() {
@@ -32,6 +29,9 @@ fn main() {
     }
 
     let mut p = Command::new(&args[0])
+                        .stdout(Stdio::piped())
+                        .stdin(Stdio::piped())
                         .arg("test").spawn().unwrap();
+    drop(p.stdout.take());
     assert!(p.wait().unwrap().success());
 }
index 91edb5fd9c1e837e162fd600b7d6e867663b9b0a..b808ea472a28a93b0621662bbacff81727e9c6b2 100644 (file)
@@ -12,7 +12,7 @@
 
 pub fn main() {
     let t = thread::spawn(move|| child((10, 20, 30, 40, 50, 60, 70, 80, 90)) );
-    t.join().ok().unwrap();
+    t.join().ok().unwrap(); // forget Err value, since it doesn't implement Debug
 }
 
 fn child(args: (int, int, int, int, int, int, int, int, int)) {
index 87d7376c243bcd6fa0fcdd0ea099d55b54f32ffb..1ccc189dc81808f7479e5c03d6afab77ab20cf5b 100644 (file)
@@ -8,11 +8,11 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use std::old_io::fs::PathExtensions;
-use std::old_io::{File, TempDir};
+use std::fs::{File, TempDir};
+use std::io::prelude::*;
 
 pub fn main() {
-    let dir = TempDir::new_in(&Path::new("."), "").unwrap();
+    let dir = TempDir::new_in(".", "").unwrap();
     let path = dir.path().join("file");
 
     {
@@ -20,7 +20,7 @@ pub fn main() {
             Err(..) => unreachable!(),
             Ok(f) => {
                 let mut f = f;
-                for _ in 0_usize..1000 {
+                for _ in 0..1000 {
                     f.write(&[0]);
                 }
             }
@@ -28,5 +28,5 @@ pub fn main() {
     }
 
     assert!(path.exists());
-    assert_eq!(path.stat().unwrap().size, 1000);
+    assert_eq!(path.metadata().unwrap().len(), 1000);
 }
index 23ea998c026085331ab204c30a17cd5799937c08..e06e6883a75aa4d2e05532280d2c7ed6ca33f9ce 100644 (file)
@@ -19,7 +19,7 @@
 
 use std::sync::mpsc::channel;
 use std::old_io::net::tcp::{TcpListener, TcpStream};
-use std::old_io::{Acceptor, Listener};
+use std::old_io::{Acceptor, Listener, Reader, Writer};
 use std::thread::{Builder, Thread};
 use std::time::Duration;
 
index 053df3a57f329361b33707084f23e329b99dc7b8..bc655837babb9d74a35b9ee73576afacb4fa8106 100644 (file)
@@ -18,6 +18,7 @@
 // they're in a different location than before. Hence, these tests are all run
 // serially here.
 
+use std::old_path::{Path, GenericPath};
 use std::old_io::fs::PathExtensions;
 use std::old_io::{fs, TempDir};
 use std::old_io;
index b02f8eb0aa9d532012522c4f5460e5ba96505b5c..d1af6b746ac421af95a2016adbf4714d226f61c8 100644 (file)
@@ -8,10 +8,9 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-#![allow(unknown_features)]
 #![feature(box_syntax)]
 
-use std::old_io;
+use std::io::{self, Write};
 
 trait Trait {
     fn f(&self);
@@ -29,9 +28,7 @@ fn f(&self) {
     }
 }
 
-fn foo(mut a: Box<Writer>) {
-    a.write(b"Hello\n");
-}
+fn foo(mut a: Box<Write>) {}
 
 // FIXME (#22405): Replace `Box::new` with `box` here when/if possible.
 
@@ -42,6 +39,6 @@ pub fn main() {
     let c: &Trait = &a;
     c.f();
 
-    let out = old_io::stdout();
+    let out = io::stdout();
     foo(Box::new(out));
 }
index 654ac9a095cb10d12ee181dde40c8243b72fcbd4..e0785779ab3c29667665c77b94aac8c7b21cc6db 100644 (file)
@@ -25,7 +25,7 @@ pub fn main() {
     let _t = (0..n).map(|i| {
         expected += i;
         let tx = tx.clone();
-        thread::spawn(move|| {
+        thread::scoped(move|| {
             child(&tx, i)
         })
     }).collect::<Vec<_>>();
index ac46187f03a71d90f09c3859a529b235779a52e7..66cc8d658c0a63ac3acdffb8816f39480c4614d8 100644 (file)
@@ -26,6 +26,6 @@ pub fn main() {
         let _b = Foo;
     }).join();
 
-    let s = x.err().unwrap().downcast::<&'static str>().ok().unwrap();
+    let s = x.err().unwrap().downcast::<&'static str>().unwrap();
     assert_eq!(&**s, "This panic should happen.");
 }