library NAME. The optional KIND can be one of,
static, dylib, or framework. If omitted, dylib is
assumed.", "NAME[:KIND]"),
- optmulti("", "crate-type", "Comma separated list of types of crates
+ opt::multi("", "crate-type", "Comma separated list of types of crates
for the compiler to emit",
- "[bin|lib|rlib|dylib|staticlib|dep-info]"),
+ "[bin|lib|rlib|dylib|staticlib]"),
- optopt("", "crate-name", "Specify the name of the crate being built",
+ opt::opt("", "crate-name", "Specify the name of the crate being built",
"NAME"),
- optmulti("", "emit", "Comma separated list of types of output for \
+ opt::multi("", "emit", "Comma separated list of types of output for \
the compiler to emit",
- optmulti("", "print", "Comma separated list of compiler information to \
+ "[asm|llvm-bc|llvm-ir|obj|link|dep-info]"),
+ "[asm|llvm-bc|llvm-ir|obj|link]"),
+ opt::multi("", "print", "Comma separated list of compiler information to \
print on stdout",
"[crate-name|output-file-names|sysroot]"),
- optflag("g", "", "Equivalent to -C debuginfo=2"),
- optflag("O", "", "Equivalent to -C opt-level=2"),
- optopt("o", "", "Write output to <filename>", "FILENAME"),
- optopt("", "out-dir", "Write output to compiler-chosen filename \
- opt::flag("g", "", "Equivalent to --debuginfo=2"),
- opt::flag("O", "", "Equivalent to --opt-level=2"),
++ opt::flag("g", "", "Equivalent to -C debuginfo=2"),
++ opt::flag("O", "", "Equivalent to -C opt-level=2"),
+ opt::opt("o", "", "Write output to <filename>", "FILENAME"),
+ opt::opt("", "out-dir", "Write output to compiler-chosen filename \
in <dir>", "DIR"),
- optopt("", "explain", "Provide a detailed explanation of an error \
+ opt::opt("", "explain", "Provide a detailed explanation of an error \
message", "OPT"),
- optflag("", "test", "Build a test harness"),
- optopt("", "target", "Target triple cpu-manufacturer-kernel[-os] \
+ opt::flag("", "test", "Build a test harness"),
+ opt::opt("", "target", "Target triple cpu-manufacturer-kernel[-os] \
to compile for (see chapter 3.4 of \
http://www.sourceware.org/autobook/
for details)",
}
let matches =
- match getopts::getopts(args.as_slice(), config::optgroups().as_slice()) {
+ match getopts::getopts(args[], config::optgroups()[]) {
Ok(m) => m,
- Err(f) => {
- early_error(f.to_string()[]);
+ Err(f_stable_attempt) => {
+ // redo option parsing, including unstable options this time,
+ // in anticipation that the mishandled option was one of the
+ // unstable ones.
+ let all_groups : Vec<getopts::OptGroup>
+ = config::rustc_optgroups().into_iter().map(|x|x.opt_group).collect();
+ match getopts::getopts(args.as_slice(), all_groups.as_slice()) {
+ Ok(m_unstable) => {
+ let r = m_unstable.opt_strs("Z");
+ let include_unstable_options = r.iter().any(|x| *x == "unstable-options");
+ if include_unstable_options {
+ m_unstable
+ } else {
+ early_error(f_stable_attempt.to_string().as_slice());
+ }
+ }
+ Err(_) => {
+ // ignore the error from the unstable attempt; just
+ // pass the error we got from the first try.
+ early_error(f_stable_attempt.to_string().as_slice());
+ }
+ }
}
};
let mut split = name.splitn(1, '=');
let first = split.next().unwrap();
let opt_second = split.next();
- let first = match first {
- "normal" => PpmSource(PpmNormal),
- "expanded" => PpmSource(PpmExpanded),
- "typed" => PpmSource(PpmTyped),
- "expanded,identified" => PpmSource(PpmExpandedIdentified),
- "expanded,hygiene" => PpmSource(PpmExpandedHygiene),
- "identified" => PpmSource(PpmIdentified),
- "flowgraph" => PpmFlowGraph,
+ let first = match (first, extended) {
+ ("normal", _) => PpmSource(PpmNormal),
+ ("everybody_loops", true) => PpmSource(PpmEveryBodyLoops),
+ ("expanded", _) => PpmSource(PpmExpanded),
+ ("typed", _) => PpmSource(PpmTyped),
+ ("expanded,identified", _) => PpmSource(PpmExpandedIdentified),
+ ("expanded,hygiene", _) => PpmSource(PpmExpandedHygiene),
+ ("identified", _) => PpmSource(PpmIdentified),
+ ("flowgraph", true) => PpmFlowGraph,
_ => {
- sess.fatal(format!(
- "argument to `pretty` must be one of `normal`, \
- `expanded`, `flowgraph=<nodeid>`, `typed`, `identified`, \
- or `expanded,identified`; got {}", name)[]);
+ if extended {
+ sess.fatal(format!(
+ "argument to `xpretty` must be one of `normal`, \
+ `expanded`, `flowgraph=<nodeid>`, `typed`, `identified`, \
+ `expanded,identified`, or `everybody_loops`; got {}", name).as_slice());
+ } else {
+ sess.fatal(format!(
+ "argument to `pretty` must be one of `normal`, \
+ `expanded`, `typed`, `identified`, \
+ or `expanded,identified`; got {}", name).as_slice());
+ }
}
};
- let opt_second = opt_second.and_then::<UserIdentifiedItem, _>(from_str);
+ let opt_second = opt_second.and_then(|s| s.parse::<UserIdentifiedItem>());
(first, opt_second)
}