about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Cargo.lock20
-rw-r--r--src/bootstrap/dist.rs1
-rw-r--r--src/libgetopts/Cargo.toml9
-rw-r--r--src/librustc/lib.rs4
-rw-r--r--src/librustc/session/config.rs124
-rw-r--r--src/librustc_driver/lib.rs20
-rw-r--r--src/librustdoc/lib.rs211
-rw-r--r--src/libtest/Cargo.toml2
-rw-r--r--src/libtest/lib.rs49
-rw-r--r--src/test/run-pass/auxiliary/allocator-dummy.rs21
-rw-r--r--src/test/run-pass/getopts_ref.rs28
-rw-r--r--src/test/run-pass/smallest-hello-world.rs1
-rw-r--r--src/tools/compiletest/Cargo.toml7
-rw-r--r--src/tools/compiletest/src/main.rs97
14 files changed, 317 insertions, 277 deletions
diff --git a/src/Cargo.lock b/src/Cargo.lock
index 4adc0a1e3ca..6d7fcb71efa 100644
--- a/src/Cargo.lock
+++ b/src/Cargo.lock
@@ -285,6 +285,7 @@ dependencies = [
  "diff 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
  "env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
  "filetime 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
+ "getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)",
  "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
  "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
@@ -423,14 +424,6 @@ dependencies = [
 ]
 
 [[package]]
-name = "flate"
-version = "0.0.0"
-dependencies = [
- "build_helper 0.1.0",
- "gcc 0.3.51 (registry+https://github.com/rust-lang/crates.io-index)",
-]
-
-[[package]]
 name = "flate2"
 version = "0.2.19"
 source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -465,10 +458,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 
 [[package]]
 name = "getopts"
-version = "0.0.0"
-
-[[package]]
-name = "getopts"
 version = "0.2.14"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 
@@ -1107,6 +1096,7 @@ name = "rustc"
 version = "0.0.0"
 dependencies = [
  "arena 0.0.0",
+ "flate2 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)",
  "fmt_macros 0.0.0",
  "graphviz 0.0.0",
  "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1296,7 +1286,7 @@ dependencies = [
 name = "rustc_metadata"
 version = "0.0.0"
 dependencies = [
- "flate 0.0.0",
+ "flate2 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)",
  "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
  "owning_ref 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
  "proc_macro 0.0.0",
@@ -1404,7 +1394,7 @@ dependencies = [
 name = "rustc_trans"
 version = "0.0.0"
 dependencies = [
- "flate 0.0.0",
+ "flate2 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)",
  "gcc 0.3.51 (registry+https://github.com/rust-lang/crates.io-index)",
  "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
  "owning_ref 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1790,7 +1780,7 @@ dependencies = [
 name = "test"
 version = "0.0.0"
 dependencies = [
- "getopts 0.0.0",
+ "getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)",
  "term 0.0.0",
 ]
 
diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs
index f92e6f50eb3..753bd1df0d8 100644
--- a/src/bootstrap/dist.rs
+++ b/src/bootstrap/dist.rs
@@ -567,7 +567,6 @@ pub fn rust_src(build: &Build) {
         "src/rustc/libc_shim",
         "src/libtest",
         "src/libterm",
-        "src/libgetopts",
         "src/compiler-rt",
         "src/jemalloc",
         "src/libprofiler_builtins",
diff --git a/src/libgetopts/Cargo.toml b/src/libgetopts/Cargo.toml
deleted file mode 100644
index 99e3b892858..00000000000
--- a/src/libgetopts/Cargo.toml
+++ /dev/null
@@ -1,9 +0,0 @@
-[package]
-authors = ["The Rust Project Developers"]
-name = "getopts"
-version = "0.0.0"
-
-[lib]
-name = "getopts"
-path = "lib.rs"
-crate-type = ["dylib", "rlib"]
diff --git a/src/librustc/lib.rs b/src/librustc/lib.rs
index 11db68cbf23..77a43c5319c 100644
--- a/src/librustc/lib.rs
+++ b/src/librustc/lib.rs
@@ -41,6 +41,7 @@
 #![feature(discriminant_value)]
 #![feature(sort_unstable)]
 #![feature(trace_macros)]
+#![feature(test)]
 
 #![recursion_limit="256"]
 
@@ -63,7 +64,10 @@ extern crate syntax_pos;
 
 extern crate serialize as rustc_serialize; // used by deriving
 
+// Note that librustc doesn't actually depend on these crates, see the note in
+// `Cargo.toml` for this crate about why these are here.
 extern crate flate2;
+extern crate test;
 
 #[macro_use]
 mod macros;
diff --git a/src/librustc/session/config.rs b/src/librustc/session/config.rs
index 7b4394f2ac9..4f7ad5ea939 100644
--- a/src/librustc/session/config.rs
+++ b/src/librustc/session/config.rs
@@ -1135,9 +1135,9 @@ pub enum OptionStability {
     Unstable,
 }
 
-#[derive(Clone, PartialEq, Eq)]
 pub struct RustcOptGroup {
-    pub opt_group: getopts::OptGroup,
+    pub apply: Box<Fn(&mut getopts::Options) -> &mut getopts::Options>,
+    pub name: &'static str,
     pub stability: OptionStability,
 }
 
@@ -1146,12 +1146,24 @@ impl RustcOptGroup {
         self.stability == OptionStability::Stable
     }
 
-    pub fn stable(g: getopts::OptGroup) -> RustcOptGroup {
-        RustcOptGroup { opt_group: g, stability: OptionStability::Stable }
+    pub fn stable<F>(name: &'static str, f: F) -> RustcOptGroup
+        where F: Fn(&mut getopts::Options) -> &mut getopts::Options + 'static,
+    {
+        RustcOptGroup {
+            name: name,
+            apply: Box::new(f),
+            stability: OptionStability::Stable,
+        }
     }
 
-    pub fn unstable(g: getopts::OptGroup) -> RustcOptGroup {
-        RustcOptGroup { opt_group: g, stability: OptionStability::Unstable }
+    pub fn unstable<F>(name: &'static str, f: F) -> RustcOptGroup
+        where F: Fn(&mut getopts::Options) -> &mut getopts::Options + 'static,
+    {
+        RustcOptGroup {
+            name: name,
+            apply: Box::new(f),
+            stability: OptionStability::Unstable,
+        }
     }
 }
 
@@ -1170,41 +1182,58 @@ mod opt {
     use super::RustcOptGroup;
 
     pub type R = RustcOptGroup;
-    pub type S<'a> = &'a str;
+    pub type S = &'static str;
+
+    fn stable<F>(name: S, f: F) -> R
+        where F: Fn(&mut getopts::Options) -> &mut getopts::Options + 'static
+    {
+        RustcOptGroup::stable(name, f)
+    }
 
-    fn stable(g: getopts::OptGroup) -> R { RustcOptGroup::stable(g) }
-    fn unstable(g: getopts::OptGroup) -> R { RustcOptGroup::unstable(g) }
+    fn unstable<F>(name: S, f: F) -> R
+        where F: Fn(&mut getopts::Options) -> &mut getopts::Options + 'static
+    {
+        RustcOptGroup::unstable(name, f)
+    }
+
+    fn longer(a: S, b: S) -> S {
+        if a.len() > b.len() {
+            a
+        } else {
+            b
+        }
+    }
 
     pub fn opt_s(a: S, b: S, c: S, d: S) -> R {
-        stable(getopts::optopt(a, b, c, d))
+        stable(longer(a, b), move |opts| opts.optopt(a, b, c, d))
     }
     pub fn multi_s(a: S, b: S, c: S, d: S) -> R {
-        stable(getopts::optmulti(a, b, c, d))
+        stable(longer(a, b), move |opts| opts.optmulti(a, b, c, d))
     }
     pub fn flag_s(a: S, b: S, c: S) -> R {
-        stable(getopts::optflag(a, b, c))
+        stable(longer(a, b), move |opts| opts.optflag(a, b, c))
     }
     pub fn flagopt_s(a: S, b: S, c: S, d: S) -> R {
-        stable(getopts::optflagopt(a, b, c, d))
+        stable(longer(a, b), move |opts| opts.optflagopt(a, b, c, d))
     }
     pub fn flagmulti_s(a: S, b: S, c: S) -> R {
-        stable(getopts::optflagmulti(a, b, c))
+        stable(longer(a, b), move |opts| opts.optflagmulti(a, b, c))
     }
 
     pub fn opt(a: S, b: S, c: S, d: S) -> R {
-        unstable(getopts::optopt(a, b, c, d))
+        unstable(longer(a, b), move |opts| opts.optopt(a, b, c, d))
     }
     pub fn multi(a: S, b: S, c: S, d: S) -> R {
-        unstable(getopts::optmulti(a, b, c, d))
+        unstable(longer(a, b), move |opts| opts.optmulti(a, b, c, d))
     }
     pub fn flag(a: S, b: S, c: S) -> R {
-        unstable(getopts::optflag(a, b, c))
+        unstable(longer(a, b), move |opts| opts.optflag(a, b, c))
     }
     pub fn flagopt(a: S, b: S, c: S, d: S) -> R {
-        unstable(getopts::optflagopt(a, b, c, d))
+        unstable(longer(a, b), move |opts| opts.optflagopt(a, b, c, d))
     }
     pub fn flagmulti(a: S, b: S, c: S) -> R {
-        unstable(getopts::optflagmulti(a, b, c))
+        unstable(longer(a, b), move |opts| opts.optflagmulti(a, b, c))
     }
 }
 
@@ -1212,13 +1241,6 @@ mod opt {
 /// including metadata for each option, such as whether the option is
 /// part of the stable long-term interface for rustc.
 pub fn rustc_short_optgroups() -> Vec<RustcOptGroup> {
-    let mut print_opts = vec!["crate-name", "file-names", "sysroot", "cfg",
-                              "target-list", "target-cpus", "target-features",
-                              "relocation-models", "code-models"];
-    if nightly_options::is_nightly_build() {
-        print_opts.push("target-spec-json");
-    }
-
     vec![
         opt::flag_s("h", "help", "Display this message"),
         opt::multi_s("", "cfg", "Configure the compilation environment", "SPEC"),
@@ -1238,8 +1260,10 @@ pub fn rustc_short_optgroups() -> Vec<RustcOptGroup> {
                               the compiler to emit",
                  "[asm|llvm-bc|llvm-ir|obj|metadata|link|dep-info|mir]"),
         opt::multi_s("", "print", "Comma separated list of compiler information to \
-                               print on stdout", &format!("[{}]",
-                               &print_opts.join("|"))),
+                               print on stdout",
+                     "[crate-name|file-names|sysroot|cfg|target-list|\
+                       target-cpus|target-features|relocation-models|\
+                       code-models|target-spec-json]"),
         opt::flagmulti_s("g",  "",  "Equivalent to -C debuginfo=2"),
         opt::flagmulti_s("O", "", "Equivalent to -C opt-level=2"),
         opt::opt_s("o", "", "Write output to <filename>", "FILENAME"),
@@ -1267,7 +1291,7 @@ pub fn rustc_short_optgroups() -> Vec<RustcOptGroup> {
 /// long-term interface for rustc.
 pub fn rustc_optgroups() -> Vec<RustcOptGroup> {
     let mut opts = rustc_short_optgroups();
-    opts.extend_from_slice(&[
+    opts.extend(vec![
         opt::multi_s("", "extern", "Specify where an external rust library is located",
                      "NAME=PATH"),
         opt::opt_s("", "sysroot", "Override the system root", "PATH"),
@@ -1680,19 +1704,14 @@ pub mod nightly_options {
             if opt.stability == OptionStability::Stable {
                 continue
             }
-            let opt_name = if opt.opt_group.long_name.is_empty() {
-                &opt.opt_group.short_name
-            } else {
-                &opt.opt_group.long_name
-            };
-            if !matches.opt_present(opt_name) {
+            if !matches.opt_present(opt.name) {
                 continue
             }
-            if opt_name != "Z" && !has_z_unstable_option {
+            if opt.name != "Z" && !has_z_unstable_option {
                 early_error(ErrorOutputType::default(),
                             &format!("the `-Z unstable-options` flag must also be passed to enable \
                                       the flag `{}`",
-                                     opt_name));
+                                     opt.name));
             }
             if really_allows_unstable_options {
                 continue
@@ -1700,7 +1719,7 @@ pub mod nightly_options {
             match opt.stability {
                 OptionStability::Unstable => {
                     let msg = format!("the option `{}` is only accepted on the \
-                                       nightly compiler", opt_name);
+                                       nightly compiler", opt.name);
                     early_error(ErrorOutputType::default(), &msg);
                 }
                 OptionStability::Stable => {}
@@ -1869,7 +1888,7 @@ mod dep_tracking {
 mod tests {
     use dep_graph::DepGraph;
     use errors;
-    use getopts::{getopts, OptGroup};
+    use getopts;
     use lint;
     use middle::cstore::{self, DummyCrateStore};
     use session::config::{build_configuration, build_session_options_and_crate_config};
@@ -1882,10 +1901,12 @@ mod tests {
     use rustc_back::PanicStrategy;
     use syntax::symbol::Symbol;
 
-    fn optgroups() -> Vec<OptGroup> {
-        super::rustc_optgroups().into_iter()
-                                .map(|a| a.opt_group)
-                                .collect()
+    fn optgroups() -> getopts::Options {
+        let mut opts = getopts::Options::new();
+        for group in super::rustc_optgroups() {
+            (group.apply)(&mut opts);
+        }
+        return opts
     }
 
     fn mk_map<K: Ord, V>(entries: Vec<(K, V)>) -> BTreeMap<K, V> {
@@ -1901,7 +1922,7 @@ mod tests {
     fn test_switch_implies_cfg_test() {
         let dep_graph = DepGraph::new(false);
         let matches =
-            &match getopts(&["--test".to_string()], &optgroups()) {
+            &match optgroups().parse(&["--test".to_string()]) {
               Ok(m) => m,
               Err(f) => panic!("test_switch_implies_cfg_test: {}", f)
             };
@@ -1918,8 +1939,7 @@ mod tests {
     fn test_switch_implies_cfg_test_unless_cfg_test() {
         let dep_graph = DepGraph::new(false);
         let matches =
-            &match getopts(&["--test".to_string(), "--cfg=test".to_string()],
-                           &optgroups()) {
+            &match optgroups().parse(&["--test".to_string(), "--cfg=test".to_string()]) {
               Ok(m) => m,
               Err(f) => {
                 panic!("test_switch_implies_cfg_test_unless_cfg_test: {}", f)
@@ -1939,9 +1959,9 @@ mod tests {
     fn test_can_print_warnings() {
         let dep_graph = DepGraph::new(false);
         {
-            let matches = getopts(&[
+            let matches = optgroups().parse(&[
                 "-Awarnings".to_string()
-            ], &optgroups()).unwrap();
+            ]).unwrap();
             let registry = errors::registry::Registry::new(&[]);
             let (sessopts, _) = build_session_options_and_crate_config(&matches);
             let sess = build_session(sessopts, &dep_graph, None, registry,
@@ -1950,10 +1970,10 @@ mod tests {
         }
 
         {
-            let matches = getopts(&[
+            let matches = optgroups().parse(&[
                 "-Awarnings".to_string(),
                 "-Dwarnings".to_string()
-            ], &optgroups()).unwrap();
+            ]).unwrap();
             let registry = errors::registry::Registry::new(&[]);
             let (sessopts, _) = build_session_options_and_crate_config(&matches);
             let sess = build_session(sessopts, &dep_graph, None, registry,
@@ -1962,9 +1982,9 @@ mod tests {
         }
 
         {
-            let matches = getopts(&[
+            let matches = optgroups().parse(&[
                 "-Adead_code".to_string()
-            ], &optgroups()).unwrap();
+            ]).unwrap();
             let registry = errors::registry::Registry::new(&[]);
             let (sessopts, _) = build_session_options_and_crate_config(&matches);
             let sess = build_session(sessopts, &dep_graph, None, registry,
diff --git a/src/librustc_driver/lib.rs b/src/librustc_driver/lib.rs
index cf5d963ff73..b4a4aaaaf5c 100644
--- a/src/librustc_driver/lib.rs
+++ b/src/librustc_driver/lib.rs
@@ -725,10 +725,10 @@ fn usage(verbose: bool, include_unstable_options: bool) {
     } else {
         config::rustc_short_optgroups()
     };
-    let groups: Vec<_> = groups.into_iter()
-                               .filter(|x| include_unstable_options || x.is_stable())
-                               .map(|x| x.opt_group)
-                               .collect();
+    let mut options = getopts::Options::new();
+    for option in groups.iter().filter(|x| include_unstable_options || x.is_stable()) {
+        (option.apply)(&mut options);
+    }
     let message = format!("Usage: rustc [OPTIONS] INPUT");
     let extra_help = if verbose {
         ""
@@ -741,7 +741,7 @@ fn usage(verbose: bool, include_unstable_options: bool) {
               Print 'lint' options and default settings
     -Z help             Print internal \
               options for debugging rustc{}\n",
-             getopts::usage(&message, &groups),
+             options.usage(&message),
              extra_help);
 }
 
@@ -955,11 +955,11 @@ pub fn handle_options(args: &[String]) -> Option<getopts::Matches> {
 
     // Parse with *all* options defined in the compiler, we don't worry about
     // option stability here we just want to parse as much as possible.
-    let all_groups: Vec<getopts::OptGroup> = config::rustc_optgroups()
-                                                 .into_iter()
-                                                 .map(|x| x.opt_group)
-                                                 .collect();
-    let matches = match getopts::getopts(&args, &all_groups) {
+    let mut options = getopts::Options::new();
+    for option in config::rustc_optgroups() {
+        (option.apply)(&mut options);
+    }
+    let matches = match options.parse(args) {
         Ok(m) => m,
         Err(f) => early_error(ErrorOutputType::default(), &f.to_string()),
     };
diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs
index f0b16ccf975..496662f442c 100644
--- a/src/librustdoc/lib.rs
+++ b/src/librustdoc/lib.rs
@@ -116,94 +116,149 @@ fn get_args() -> Option<Vec<String>> {
         .collect()
 }
 
-fn stable(g: getopts::OptGroup) -> RustcOptGroup { RustcOptGroup::stable(g) }
-fn unstable(g: getopts::OptGroup) -> RustcOptGroup { RustcOptGroup::unstable(g) }
+fn stable<F>(name: &'static str, f: F) -> RustcOptGroup
+    where F: Fn(&mut getopts::Options) -> &mut getopts::Options + 'static
+{
+    RustcOptGroup::stable(name, f)
+}
+
+fn unstable<F>(name: &'static str, f: F) -> RustcOptGroup
+    where F: Fn(&mut getopts::Options) -> &mut getopts::Options + 'static
+{
+    RustcOptGroup::unstable(name, f)
+}
 
 pub fn opts() -> Vec<RustcOptGroup> {
-    use getopts::*;
     vec![
-        stable(optflag("h", "help", "show this help message")),
-        stable(optflag("V", "version", "print rustdoc's version")),
-        stable(optflag("v", "verbose", "use verbose output")),
-        stable(optopt("r", "input-format", "the input type of the specified file",
-                      "[rust]")),
-        stable(optopt("w", "output-format", "the output type to write",
-                      "[html]")),
-        stable(optopt("o", "output", "where to place the output", "PATH")),
-        stable(optopt("", "crate-name", "specify the name of this crate", "NAME")),
-        stable(optmulti("L", "library-path", "directory to add to crate search path",
-                        "DIR")),
-        stable(optmulti("", "cfg", "pass a --cfg to rustc", "")),
-        stable(optmulti("", "extern", "pass an --extern to rustc", "NAME=PATH")),
-        stable(optmulti("", "plugin-path", "directory to load plugins from", "DIR")),
-        stable(optmulti("", "passes",
-                        "list of passes to also run, you might want \
-                         to pass it multiple times; a value of `list` \
-                         will print available passes",
-                        "PASSES")),
-        stable(optmulti("", "plugins", "space separated list of plugins to also load",
-                        "PLUGINS")),
-        stable(optflag("", "no-defaults", "don't run the default passes")),
-        stable(optflag("", "test", "run code examples as tests")),
-        stable(optmulti("", "test-args", "arguments to pass to the test runner",
-                        "ARGS")),
-        stable(optopt("", "target", "target triple to document", "TRIPLE")),
-        stable(optmulti("", "markdown-css",
-                        "CSS files to include via <link> in a rendered Markdown file",
-                        "FILES")),
-        stable(optmulti("", "html-in-header",
-                        "files to include inline in the <head> section of a rendered Markdown file \
-                         or generated documentation",
-                        "FILES")),
-        stable(optmulti("", "html-before-content",
-                        "files to include inline between <body> and the content of a rendered \
-                         Markdown file or generated documentation",
-                        "FILES")),
-        stable(optmulti("", "html-after-content",
-                        "files to include inline between the content and </body> of a rendered \
-                         Markdown file or generated documentation",
-                        "FILES")),
-        unstable(optmulti("", "markdown-before-content",
-                          "files to include inline between <body> and the content of a rendered \
-                           Markdown file or generated documentation",
-                          "FILES")),
-        unstable(optmulti("", "markdown-after-content",
-                          "files to include inline between the content and </body> of a rendered \
-                           Markdown file or generated documentation",
-                          "FILES")),
-        stable(optopt("", "markdown-playground-url",
-                      "URL to send code snippets to", "URL")),
-        stable(optflag("", "markdown-no-toc", "don't include table of contents")),
-        stable(optopt("e", "extend-css",
-                      "To add some CSS rules with a given file to generate doc with your \
-                       own theme. However, your theme might break if the rustdoc's generated HTML \
-                       changes, so be careful!", "PATH")),
-        unstable(optmulti("Z", "",
-                          "internal and debugging options (only on nightly build)", "FLAG")),
-        stable(optopt("", "sysroot", "Override the system root", "PATH")),
-        unstable(optopt("", "playground-url",
-                        "URL to send code snippets to, may be reset by --markdown-playground-url \
-                         or `#![doc(html_playground_url=...)]`",
-                        "URL")),
-        unstable(optflag("", "enable-commonmark", "to enable commonmark doc rendering/testing")),
-        unstable(optflag("", "display-warnings", "to print code warnings when testing doc")),
+        stable("h", |o| o.optflag("h", "help", "show this help message")),
+        stable("V", |o| o.optflag("V", "version", "print rustdoc's version")),
+        stable("v", |o| o.optflag("v", "verbose", "use verbose output")),
+        stable("r", |o| {
+            o.optopt("r", "input-format", "the input type of the specified file",
+                     "[rust]")
+        }),
+        stable("w", |o| {
+            o.optopt("w", "output-format", "the output type to write", "[html]")
+        }),
+        stable("o", |o| o.optopt("o", "output", "where to place the output", "PATH")),
+        stable("crate-name", |o| {
+            o.optopt("", "crate-name", "specify the name of this crate", "NAME")
+        }),
+        stable("L", |o| {
+            o.optmulti("L", "library-path", "directory to add to crate search path",
+                       "DIR")
+        }),
+        stable("cfg", |o| o.optmulti("", "cfg", "pass a --cfg to rustc", "")),
+        stable("extern", |o| {
+            o.optmulti("", "extern", "pass an --extern to rustc", "NAME=PATH")
+        }),
+        stable("plugin-path", |o| {
+            o.optmulti("", "plugin-path", "directory to load plugins from", "DIR")
+        }),
+        stable("passes", |o| {
+            o.optmulti("", "passes",
+                       "list of passes to also run, you might want \
+                        to pass it multiple times; a value of `list` \
+                        will print available passes",
+                       "PASSES")
+        }),
+        stable("plugins", |o| {
+            o.optmulti("", "plugins", "space separated list of plugins to also load",
+                       "PLUGINS")
+        }),
+        stable("no-default", |o| {
+            o.optflag("", "no-defaults", "don't run the default passes")
+        }),
+        stable("test", |o| o.optflag("", "test", "run code examples as tests")),
+        stable("test-args", |o| {
+            o.optmulti("", "test-args", "arguments to pass to the test runner",
+                       "ARGS")
+        }),
+        stable("target", |o| o.optopt("", "target", "target triple to document", "TRIPLE")),
+        stable("markdown-css", |o| {
+            o.optmulti("", "markdown-css",
+                       "CSS files to include via <link> in a rendered Markdown file",
+                       "FILES")
+        }),
+        stable("html-in-header", |o|  {
+            o.optmulti("", "html-in-header",
+                       "files to include inline in the <head> section of a rendered Markdown file \
+                        or generated documentation",
+                       "FILES")
+        }),
+        stable("html-before-content", |o| {
+            o.optmulti("", "html-before-content",
+                       "files to include inline between <body> and the content of a rendered \
+                        Markdown file or generated documentation",
+                       "FILES")
+        }),
+        stable("html-after-content", |o| {
+            o.optmulti("", "html-after-content",
+                       "files to include inline between the content and </body> of a rendered \
+                        Markdown file or generated documentation",
+                       "FILES")
+        }),
+        unstable("markdown-before-content", |o| {
+            o.optmulti("", "markdown-before-content",
+                       "files to include inline between <body> and the content of a rendered \
+                        Markdown file or generated documentation",
+                       "FILES")
+        }),
+        unstable("markdown-after-content", |o| {
+            o.optmulti("", "markdown-after-content",
+                       "files to include inline between the content and </body> of a rendered \
+                        Markdown file or generated documentation",
+                       "FILES")
+        }),
+        stable("markdown-playground-url", |o| {
+            o.optopt("", "markdown-playground-url",
+                     "URL to send code snippets to", "URL")
+        }),
+        stable("markdown-no-toc", |o| {
+            o.optflag("", "markdown-no-toc", "don't include table of contents")
+        }),
+        stable("e", |o| {
+            o.optopt("e", "extend-css",
+                     "To add some CSS rules with a given file to generate doc with your \
+                      own theme. However, your theme might break if the rustdoc's generated HTML \
+                      changes, so be careful!", "PATH")
+        }),
+        unstable("Z", |o| {
+            o.optmulti("Z", "",
+                       "internal and debugging options (only on nightly build)", "FLAG")
+        }),
+        stable("sysroot", |o| {
+            o.optopt("", "sysroot", "Override the system root", "PATH")
+        }),
+        unstable("playground-url", |o| {
+            o.optopt("", "playground-url",
+                     "URL to send code snippets to, may be reset by --markdown-playground-url \
+                      or `#![doc(html_playground_url=...)]`",
+                     "URL")
+        }),
+        unstable("enable-commonmark", |o| {
+            o.optflag("", "enable-commonmark", "to enable commonmark doc rendering/testing")
+        }),
+        unstable("display-warnings", |o| {
+            o.optflag("", "display-warnings", "to print code warnings when testing doc")
+        }),
     ]
 }
 
 pub fn usage(argv0: &str) {
-    println!("{}",
-             getopts::usage(&format!("{} [options] <input>", argv0),
-                            &opts().into_iter()
-                                   .map(|x| x.opt_group)
-                                   .collect::<Vec<getopts::OptGroup>>()));
+    let mut options = getopts::Options::new();
+    for option in opts() {
+        (option.apply)(&mut options);
+    }
+    println!("{}", options.usage(&format!("{} [options] <input>", argv0)));
 }
 
 pub fn main_args(args: &[String]) -> isize {
-    let all_groups: Vec<getopts::OptGroup> = opts()
-                                             .into_iter()
-                                             .map(|x| x.opt_group)
-                                             .collect();
-    let matches = match getopts::getopts(&args[1..], &all_groups) {
+    let mut options = getopts::Options::new();
+    for option in opts() {
+        (option.apply)(&mut options);
+    }
+    let matches = match options.parse(&args[1..]) {
         Ok(m) => m,
         Err(err) => {
             print_error(err);
diff --git a/src/libtest/Cargo.toml b/src/libtest/Cargo.toml
index ecbd5a9c0f5..ec77f953380 100644
--- a/src/libtest/Cargo.toml
+++ b/src/libtest/Cargo.toml
@@ -9,5 +9,5 @@ path = "lib.rs"
 crate-type = ["dylib", "rlib"]
 
 [dependencies]
-getopts = { path = "../libgetopts" }
+getopts = "0.2"
 term = { path = "../libterm" }
diff --git a/src/libtest/lib.rs b/src/libtest/lib.rs
index 74212625eea..2094fd8898d 100644
--- a/src/libtest/lib.rs
+++ b/src/libtest/lib.rs
@@ -372,30 +372,31 @@ impl TestOpts {
 /// Result of parsing the options.
 pub type OptRes = Result<TestOpts, String>;
 
-#[cfg_attr(rustfmt, rustfmt_skip)]
-fn optgroups() -> Vec<getopts::OptGroup> {
-    vec![getopts::optflag("", "ignored", "Run ignored tests"),
-      getopts::optflag("", "test", "Run tests and not benchmarks"),
-      getopts::optflag("", "bench", "Run benchmarks instead of tests"),
-      getopts::optflag("", "list", "List all tests and benchmarks"),
-      getopts::optflag("h", "help", "Display this message (longer with --help)"),
-      getopts::optopt("", "logfile", "Write logs to the specified file instead \
-                          of stdout", "PATH"),
-      getopts::optflag("", "nocapture", "don't capture stdout/stderr of each \
-                                         task, allow printing directly"),
-      getopts::optopt("", "test-threads", "Number of threads used for running tests \
-                                           in parallel", "n_threads"),
-      getopts::optmulti("", "skip", "Skip tests whose names contain FILTER (this flag can \
-                                     be used multiple times)","FILTER"),
-      getopts::optflag("q", "quiet", "Display one character per test instead of one line"),
-      getopts::optflag("", "exact", "Exactly match filters rather than by substring"),
-      getopts::optopt("", "color", "Configure coloring of output:
+fn optgroups() -> getopts::Options {
+    let mut opts = getopts::Options::new();
+    opts.optflag("", "ignored", "Run ignored tests")
+        .optflag("", "test", "Run tests and not benchmarks")
+        .optflag("", "bench", "Run benchmarks instead of tests")
+        .optflag("", "list", "List all tests and benchmarks")
+        .optflag("h", "help", "Display this message (longer with --help)")
+        .optopt("", "logfile", "Write logs to the specified file instead \
+                                of stdout", "PATH")
+        .optflag("", "nocapture", "don't capture stdout/stderr of each \
+                                   task, allow printing directly")
+        .optopt("", "test-threads", "Number of threads used for running tests \
+                                     in parallel", "n_threads")
+        .optmulti("", "skip", "Skip tests whose names contain FILTER (this flag can \
+                               be used multiple times)","FILTER")
+        .optflag("q", "quiet", "Display one character per test instead of one line")
+        .optflag("", "exact", "Exactly match filters rather than by substring")
+        .optopt("", "color", "Configure coloring of output:
             auto   = colorize if stdout is a tty and tests are run on serially (default);
             always = always colorize output;
-            never  = never colorize output;", "auto|always|never")]
+            never  = never colorize output;", "auto|always|never");
+    return opts
 }
 
-fn usage(binary: &str) {
+fn usage(binary: &str, options: &getopts::Options) {
     let message = format!("Usage: {} [OPTIONS] [FILTER]", binary);
     println!(r#"{usage}
 
@@ -424,19 +425,19 @@ Test Attributes:
                      test, then the test runner will ignore these tests during
                      normal test runs. Running with --ignored will run these
                      tests."#,
-             usage = getopts::usage(&message, &optgroups()));
+             usage = options.usage(&message));
 }
 
 // Parses command line arguments into test options
 pub fn parse_opts(args: &[String]) -> Option<OptRes> {
-    let args_ = &args[1..];
-    let matches = match getopts::getopts(args_, &optgroups()) {
+    let opts = optgroups();
+    let matches = match opts.parse(&args[1..]) {
         Ok(m) => m,
         Err(f) => return Some(Err(f.to_string())),
     };
 
     if matches.opt_present("h") {
-        usage(&args[0]);
+        usage(&args[0], &opts);
         return None;
     }
 
diff --git a/src/test/run-pass/auxiliary/allocator-dummy.rs b/src/test/run-pass/auxiliary/allocator-dummy.rs
index 1133ace275b..a54233535a4 100644
--- a/src/test/run-pass/auxiliary/allocator-dummy.rs
+++ b/src/test/run-pass/auxiliary/allocator-dummy.rs
@@ -10,33 +10,40 @@
 
 // no-prefer-dynamic
 
-#![feature(allocator, core_intrinsics, libc)]
+#![feature(allocator, core_intrinsics)]
 #![allocator]
 #![crate_type = "rlib"]
 #![no_std]
 
-extern crate libc;
-
 pub static mut HITS: usize = 0;
 
+type size_t = usize;
+
+extern {
+    fn malloc(size: usize) -> *mut u8;
+    fn free(ptr: *mut u8);
+    fn calloc(size: usize, amt: usize) -> *mut u8;
+    fn realloc(ptr: *mut u8, size: usize) -> *mut u8;
+}
+
 #[no_mangle]
 pub extern fn __rust_allocate(size: usize, align: usize) -> *mut u8 {
     unsafe {
         HITS += 1;
-        libc::malloc(size as libc::size_t) as *mut u8
+        malloc(size as size_t) as *mut u8
     }
 }
 
 #[no_mangle]
 pub extern fn __rust_allocate_zeroed(size: usize, _align: usize) -> *mut u8 {
-    unsafe { libc::calloc(size as libc::size_t, 1) as *mut u8 }
+    unsafe { calloc(size as size_t, 1) as *mut u8 }
 }
 
 #[no_mangle]
 pub extern fn __rust_deallocate(ptr: *mut u8, old_size: usize, align: usize) {
     unsafe {
         HITS += 1;
-        libc::free(ptr as *mut _)
+        free(ptr as *mut _)
     }
 }
 
@@ -44,7 +51,7 @@ pub extern fn __rust_deallocate(ptr: *mut u8, old_size: usize, align: usize) {
 pub extern fn __rust_reallocate(ptr: *mut u8, old_size: usize, size: usize,
                                 align: usize) -> *mut u8 {
     unsafe {
-        libc::realloc(ptr as *mut _, size as libc::size_t) as *mut u8
+        realloc(ptr as *mut _, size as size_t) as *mut u8
     }
 }
 
diff --git a/src/test/run-pass/getopts_ref.rs b/src/test/run-pass/getopts_ref.rs
deleted file mode 100644
index 90726c21fac..00000000000
--- a/src/test/run-pass/getopts_ref.rs
+++ /dev/null
@@ -1,28 +0,0 @@
-// Copyright 2012-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.
-
-
-#![feature(rustc_private)]
-
-extern crate getopts;
-
-use getopts::{optopt, getopts};
-
-pub fn main() {
-    let args = Vec::new();
-    let opts = vec![optopt("b", "", "something", "SMTHNG")];
-
-    match getopts(&args, &opts) {
-        Ok(ref m)  =>
-            assert!(!m.opt_present("b")),
-        Err(ref f) => panic!("{}", *f)
-    };
-
-}
diff --git a/src/test/run-pass/smallest-hello-world.rs b/src/test/run-pass/smallest-hello-world.rs
index a27d45ea17d..053ee8ee42e 100644
--- a/src/test/run-pass/smallest-hello-world.rs
+++ b/src/test/run-pass/smallest-hello-world.rs
@@ -11,6 +11,7 @@
 // Smallest "hello world" with a libc runtime
 
 // pretty-expanded FIXME #23616
+// ignore-windows
 
 #![feature(intrinsics, lang_items, start, no_core, alloc_system)]
 #![no_core]
diff --git a/src/tools/compiletest/Cargo.toml b/src/tools/compiletest/Cargo.toml
index 59d83de5787..543e6784a72 100644
--- a/src/tools/compiletest/Cargo.toml
+++ b/src/tools/compiletest/Cargo.toml
@@ -4,8 +4,9 @@ name = "compiletest"
 version = "0.0.0"
 
 [dependencies]
-log = "0.3"
+diff = "0.1.10"
 env_logger = { version = "0.4", default-features = false }
-rustc-serialize = "0.3"
 filetime = "0.1"
-diff = "0.1.10"
+getopts = "0.2"
+log = "0.3"
+rustc-serialize = "0.3"
diff --git a/src/tools/compiletest/src/main.rs b/src/tools/compiletest/src/main.rs
index 3dac580a5f4..c88ffba357a 100644
--- a/src/tools/compiletest/src/main.rs
+++ b/src/tools/compiletest/src/main.rs
@@ -11,7 +11,6 @@
 #![crate_name = "compiletest"]
 
 #![feature(box_syntax)]
-#![feature(rustc_private)]
 #![feature(test)]
 #![feature(libc)]
 
@@ -34,7 +33,7 @@ use std::io;
 use std::path::{Path, PathBuf};
 use std::process::Command;
 use filetime::FileTime;
-use getopts::{optopt, optflag, reqopt};
+use getopts::Options;
 use common::Config;
 use common::{Pretty, DebugInfoGdb, DebugInfoLldb, Mode};
 use test::{TestPaths, ColorConfig};
@@ -66,68 +65,68 @@ fn main() {
 
 pub fn parse_config(args: Vec<String> ) -> Config {
 
-    let groups : Vec<getopts::OptGroup> =
-        vec![reqopt("", "compile-lib-path", "path to host shared libraries", "PATH"),
-          reqopt("", "run-lib-path", "path to target shared libraries", "PATH"),
-          reqopt("", "rustc-path", "path to rustc to use for compiling", "PATH"),
-          reqopt("", "rustdoc-path", "path to rustdoc to use for compiling", "PATH"),
-          reqopt("", "lldb-python", "path to python to use for doc tests", "PATH"),
-          reqopt("", "docck-python", "path to python to use for doc tests", "PATH"),
-          optopt("", "valgrind-path", "path to Valgrind executable for Valgrind tests", "PROGRAM"),
-          optflag("", "force-valgrind", "fail if Valgrind tests cannot be run under Valgrind"),
-          optopt("", "llvm-filecheck", "path to LLVM's FileCheck binary", "DIR"),
-          reqopt("", "src-base", "directory to scan for test files", "PATH"),
-          reqopt("", "build-base", "directory to deposit test outputs", "PATH"),
-          reqopt("", "stage-id", "the target-stage identifier", "stageN-TARGET"),
-          reqopt("", "mode", "which sort of compile tests to run",
-                 "(compile-fail|parse-fail|run-fail|run-pass|\
-                  run-pass-valgrind|pretty|debug-info|incremental|mir-opt)"),
-          optflag("", "ignored", "run tests marked as ignored"),
-          optflag("", "exact", "filters match exactly"),
-          optopt("", "runtool", "supervisor program to run tests under \
-                                 (eg. emulator, valgrind)", "PROGRAM"),
-          optopt("", "host-rustcflags", "flags to pass to rustc for host", "FLAGS"),
-          optopt("", "target-rustcflags", "flags to pass to rustc for target", "FLAGS"),
-          optflag("", "verbose", "run tests verbosely, showing all output"),
-          optflag("", "quiet", "print one character per test instead of one line"),
-          optopt("", "color", "coloring: auto, always, never", "WHEN"),
-          optopt("", "logfile", "file to log test execution to", "FILE"),
-          optopt("", "target", "the target to build for", "TARGET"),
-          optopt("", "host", "the host to build for", "HOST"),
-          optopt("", "gdb", "path to GDB to use for GDB debuginfo tests", "PATH"),
-          optopt("", "lldb-version", "the version of LLDB used", "VERSION STRING"),
-          optopt("", "llvm-version", "the version of LLVM used", "VERSION STRING"),
-          optflag("", "system-llvm", "is LLVM the system LLVM"),
-          optopt("", "android-cross-path", "Android NDK standalone path", "PATH"),
-          optopt("", "adb-path", "path to the android debugger", "PATH"),
-          optopt("", "adb-test-dir", "path to tests for the android debugger", "PATH"),
-          optopt("", "lldb-python-dir", "directory containing LLDB's python module", "PATH"),
-          reqopt("", "cc", "path to a C compiler", "PATH"),
-          reqopt("", "cxx", "path to a C++ compiler", "PATH"),
-          reqopt("", "cflags", "flags for the C compiler", "FLAGS"),
-          reqopt("", "llvm-components", "list of LLVM components built in", "LIST"),
-          reqopt("", "llvm-cxxflags", "C++ flags for LLVM", "FLAGS"),
-          optopt("", "nodejs", "the name of nodejs", "PATH"),
-          optopt("", "remote-test-client", "path to the remote test client", "PATH"),
-          optflag("h", "help", "show this message")];
+    let mut opts = Options::new();
+    opts.reqopt("", "compile-lib-path", "path to host shared libraries", "PATH")
+        .reqopt("", "run-lib-path", "path to target shared libraries", "PATH")
+        .reqopt("", "rustc-path", "path to rustc to use for compiling", "PATH")
+        .reqopt("", "rustdoc-path", "path to rustdoc to use for compiling", "PATH")
+        .reqopt("", "lldb-python", "path to python to use for doc tests", "PATH")
+        .reqopt("", "docck-python", "path to python to use for doc tests", "PATH")
+        .optopt("", "valgrind-path", "path to Valgrind executable for Valgrind tests", "PROGRAM")
+        .optflag("", "force-valgrind", "fail if Valgrind tests cannot be run under Valgrind")
+        .optopt("", "llvm-filecheck", "path to LLVM's FileCheck binary", "DIR")
+        .reqopt("", "src-base", "directory to scan for test files", "PATH")
+        .reqopt("", "build-base", "directory to deposit test outputs", "PATH")
+        .reqopt("", "stage-id", "the target-stage identifier", "stageN-TARGET")
+        .reqopt("", "mode", "which sort of compile tests to run",
+                "(compile-fail|parse-fail|run-fail|run-pass|\
+                 run-pass-valgrind|pretty|debug-info|incremental|mir-opt)")
+        .optflag("", "ignored", "run tests marked as ignored")
+        .optflag("", "exact", "filters match exactly")
+        .optopt("", "runtool", "supervisor program to run tests under \
+                                (eg. emulator, valgrind)", "PROGRAM")
+        .optopt("", "host-rustcflags", "flags to pass to rustc for host", "FLAGS")
+        .optopt("", "target-rustcflags", "flags to pass to rustc for target", "FLAGS")
+        .optflag("", "verbose", "run tests verbosely, showing all output")
+        .optflag("", "quiet", "print one character per test instead of one line")
+        .optopt("", "color", "coloring: auto, always, never", "WHEN")
+        .optopt("", "logfile", "file to log test execution to", "FILE")
+        .optopt("", "target", "the target to build for", "TARGET")
+        .optopt("", "host", "the host to build for", "HOST")
+        .optopt("", "gdb", "path to GDB to use for GDB debuginfo tests", "PATH")
+        .optopt("", "lldb-version", "the version of LLDB used", "VERSION STRING")
+        .optopt("", "llvm-version", "the version of LLVM used", "VERSION STRING")
+        .optflag("", "system-llvm", "is LLVM the system LLVM")
+        .optopt("", "android-cross-path", "Android NDK standalone path", "PATH")
+        .optopt("", "adb-path", "path to the android debugger", "PATH")
+        .optopt("", "adb-test-dir", "path to tests for the android debugger", "PATH")
+        .optopt("", "lldb-python-dir", "directory containing LLDB's python module", "PATH")
+        .reqopt("", "cc", "path to a C compiler", "PATH")
+        .reqopt("", "cxx", "path to a C++ compiler", "PATH")
+        .reqopt("", "cflags", "flags for the C compiler", "FLAGS")
+        .reqopt("", "llvm-components", "list of LLVM components built in", "LIST")
+        .reqopt("", "llvm-cxxflags", "C++ flags for LLVM", "FLAGS")
+        .optopt("", "nodejs", "the name of nodejs", "PATH")
+        .optopt("", "remote-test-client", "path to the remote test client", "PATH")
+        .optflag("h", "help", "show this message");
 
     let (argv0, args_) = args.split_first().unwrap();
     if args.len() == 1 || args[1] == "-h" || args[1] == "--help" {
         let message = format!("Usage: {} [OPTIONS] [TESTNAME...]", argv0);
-        println!("{}", getopts::usage(&message, &groups));
+        println!("{}", opts.usage(&message));
         println!("");
         panic!()
     }
 
     let matches =
-        &match getopts::getopts(args_, &groups) {
+        &match opts.parse(args_) {
           Ok(m) => m,
           Err(f) => panic!("{:?}", f)
         };
 
     if matches.opt_present("h") || matches.opt_present("help") {
         let message = format!("Usage: {} [OPTIONS]  [TESTNAME...]", argv0);
-        println!("{}", getopts::usage(&message, &groups));
+        println!("{}", opts.usage(&message));
         println!("");
         panic!()
     }