Skip to content

Commit 3950442

Browse files
glandiumluser
authored andcommitted
Fix some rust argument definitions
I don't know how I ended up with the definitions that landed in cae21a2, but many had the wrong attribute, and the wrong target type. Also, short options allow the forms: -Cfoo -C foo while long options allow the forms: --codegen=foo --codegen foo But for some reason short options had been made to support: -C=foo -C foo
1 parent eb31d8e commit 3950442

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

src/compiler/rust.rs

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ pub struct RustHasher {
6464
parsed_args: ParsedArguments,
6565
}
6666

67-
#[derive(Debug, Clone)]
67+
#[derive(Debug, Clone, PartialEq)]
6868
pub struct ParsedArguments {
6969
/// The full commandline, with arguments and their values as pairs.
7070
arguments: Vec<(OsString, Option<OsString>)>,
@@ -323,7 +323,7 @@ static ARGS: [(ArgInfo, RustArgAttribute); 33] = [
323323
take_arg!("--cap-lints", Path, CanBeSeparated('='), PassThrough),
324324
take_arg!("--cfg", Path, CanBeSeparated('='), PassThrough),
325325
take_arg!("--codegen", Path, CanBeSeparated('='), CodeGen),
326-
take_arg!("--color", Path, CanBeSeparated('='), CodeGen),
326+
take_arg!("--color", Path, CanBeSeparated('='), PassThrough),
327327
take_arg!("--crate-name", String, CanBeSeparated('='), CrateName),
328328
take_arg!("--crate-type", String, CanBeSeparated('='), CrateType),
329329
take_arg!("--deny", Path, CanBeSeparated('='), PassThrough),
@@ -341,16 +341,16 @@ static ARGS: [(ArgInfo, RustArgAttribute); 33] = [
341341
take_arg!("--unpretty", String, CanBeSeparated('='), NotCompilation),
342342
flag!("--version", NotCompilation),
343343
take_arg!("--warn", Path, CanBeSeparated('='), PassThrough),
344-
take_arg!("-A", Path, CanBeSeparated('='), LinkPath),
345-
take_arg!("-C", Path, CanBeSeparated('='), CodeGen),
346-
take_arg!("-D", Path, CanBeSeparated('='), CodeGen),
347-
take_arg!("-F", Path, CanBeSeparated('='), CodeGen),
348-
take_arg!("-L", Path, CanBeSeparated('='), LinkPath),
344+
take_arg!("-A", String, CanBeSeparated, PassThrough),
345+
take_arg!("-C", String, CanBeSeparated, CodeGen),
346+
take_arg!("-D", String, CanBeSeparated, PassThrough),
347+
take_arg!("-F", String, CanBeSeparated, PassThrough),
348+
take_arg!("-L", Path, CanBeSeparated, LinkPath),
349349
flag!("-V", NotCompilation),
350-
take_arg!("-W", Path, CanBeSeparated('='), LinkPath),
351-
take_arg!("-Z", Path, CanBeSeparated('='), LinkPath),
352-
take_arg!("-l", Path, CanBeSeparated('='), LinkLibrary),
353-
take_arg!("-o", Path, CanBeSeparated('='), TooHard),
350+
take_arg!("-W", String, CanBeSeparated, PassThrough),
351+
take_arg!("-Z", String, CanBeSeparated, PassThrough),
352+
take_arg!("-l", Path, CanBeSeparated, LinkLibrary),
353+
take_arg!("-o", Path, CanBeSeparated, TooHard),
354354
];
355355

356356
fn parse_arguments(arguments: &[OsString], cwd: &Path) -> CompilerArguments<ParsedArguments>
@@ -759,6 +759,10 @@ mod test {
759759
assert!(h.dep_info.is_none());
760760
let h = parses!("--emit", "link", "foo.rs", "--out-dir=out", "--crate-name=foo");
761761
assert_eq!(h.output_dir.to_str(), Some("out"));
762+
assert_eq!(parses!("--emit", "link", "-C", "opt-level=1", "foo.rs",
763+
"--out-dir", "out", "--crate-name", "foo"),
764+
parses!("--emit=link", "-Copt-level=1", "foo.rs",
765+
"--out-dir=out", "--crate-name=foo"));
762766
let h = parses!("--emit", "link,dep-info", "foo.rs", "--out-dir", "out",
763767
"--crate-name", "my_crate",
764768
"-C", "extra-filename=-abcxyz");

0 commit comments

Comments
 (0)