Skip to content

rustpkg: Recover -h/--help option #11467

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions src/librustc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ use middle::lint;

use d = driver::driver;

use std::cast;
use std::comm;
use std::io;
use std::io::Reader;
Expand Down Expand Up @@ -365,8 +364,7 @@ impl diagnostic::Emitter for RustcEmitter {
msg: &str,
lvl: diagnostic::Level) {
if lvl == diagnostic::Fatal {
let this = unsafe { cast::transmute_mut(self) };
this.ch_capture.send(fatal)
self.ch_capture.send(fatal)
}

diagnostic::DefaultEmitter.emit(cmsp, msg, lvl)
Expand Down
1 change: 0 additions & 1 deletion src/librustpkg/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -752,7 +752,6 @@ pub fn main() {
}

pub fn main_args(args: &[~str]) -> int {

let (command, args, context, supplied_sysroot) = match parse_args(args) {
Ok(ParseResult {
command: cmd,
Expand Down
18 changes: 11 additions & 7 deletions src/librustpkg/parse_args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ pub struct ParseResult {
/// Parses command line arguments of rustpkg.
/// Returns a triplet (command, remaining_args, context)
pub fn parse_args(args: &[~str]) -> Result<ParseResult, int> {
let opts = ~[ getopts::optflag("no-link"),
let opts = ~[getopts::optflag("h"), getopts::optflag("help"),
getopts::optflag("no-link"),
getopts::optflag("no-trans"),
// n.b. Ignores different --pretty options for now
getopts::optflag("pretty"),
Expand All @@ -62,11 +63,11 @@ pub fn parse_args(args: &[~str]) -> Result<ParseResult, int> {
return Err(1);
}
};
let help = matches.opt_present("h") || matches.opt_present("help");
let no_link = matches.opt_present("no-link");
let no_trans = matches.opt_present("no-trans");
let supplied_sysroot = matches.opt_str("sysroot");
let generate_asm = matches.opt_present("S") ||
matches.opt_present("assembly");
let generate_asm = matches.opt_present("S") || matches.opt_present("assembly");
let parse_only = matches.opt_present("parse-only");
let pretty = matches.opt_present("pretty");
let emit_llvm = matches.opt_present("emit-llvm");
Expand Down Expand Up @@ -155,10 +156,13 @@ pub fn parse_args(args: &[~str]) -> Result<ParseResult, int> {
}
Some(cmd) => {
let bad_option = flags_forbidden_for_cmd(&rustc_flags,
cfgs,
cmd,
user_supplied_opt_level);
if bad_option {
cfgs,
cmd,
user_supplied_opt_level);
if help {
usage::usage_for_command(cmd);
return Err(0);
} else if bad_option {
usage::usage_for_command(cmd);
debug!("Bad option, returning BAD_FLAG_CODE");
return Err(BAD_FLAG_CODE);
Expand Down