Skip to content

Commit e8b9af4

Browse files
authored
Pass through --remap-path-prefix argument. (#2270)
* Pass through `--remap-path-prefix` argument. * Nothing is TooHard anymore in the Rust world! * Add a test for `--remap-path-prefix`
1 parent 9ca8beb commit e8b9af4

File tree

1 file changed

+30
-3
lines changed

1 file changed

+30
-3
lines changed

src/compiler/rust.rs

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,7 +1000,6 @@ impl IntoArg for ArgTarget {
10001000

10011001
ArgData! {
10021002
TooHardFlag,
1003-
TooHard(OsString),
10041003
TooHardPath(PathBuf),
10051004
NotCompilationFlag,
10061005
NotCompilation(OsString),
@@ -1045,7 +1044,7 @@ counted_array!(static ARGS: [ArgInfo<ArgData>; _] = [
10451044
take_arg!("--out-dir", PathBuf, CanBeSeparated('='), OutDir),
10461045
take_arg!("--pretty", OsString, CanBeSeparated('='), NotCompilation),
10471046
take_arg!("--print", OsString, CanBeSeparated('='), NotCompilation),
1048-
take_arg!("--remap-path-prefix", OsString, CanBeSeparated('='), TooHard),
1047+
take_arg!("--remap-path-prefix", OsString, CanBeSeparated('='), PassThrough),
10491048
take_arg!("--sysroot", PathBuf, CanBeSeparated('='), TooHardPath),
10501049
take_arg!("--target", ArgTarget, CanBeSeparated('='), Target),
10511050
take_arg!("--unpretty", OsString, CanBeSeparated('='), NotCompilation),
@@ -1088,7 +1087,7 @@ fn parse_arguments(arguments: &[OsString], cwd: &Path) -> CompilerArguments<Pars
10881087
for arg in ArgsIter::new(arguments.iter().cloned(), &ARGS[..]) {
10891088
let arg = try_or_cannot_cache!(arg, "argument parse");
10901089
match arg.get_data() {
1091-
Some(TooHardFlag) | Some(TooHard(_)) | Some(TooHardPath(_)) => {
1090+
Some(TooHardFlag) | Some(TooHardPath(_)) => {
10921091
cannot_cache!(arg.flag_str().expect("Can't be Argument::Raw/UnknownFlag",))
10931092
}
10941093
Some(NotCompilationFlag) | Some(NotCompilation(_)) => {
@@ -3799,6 +3798,34 @@ proc_macro false
37993798
assert_eq!(h.gcno, Some("foo-a1b6419f8321841f.gcno".into()));
38003799
}
38013800

3801+
#[test]
3802+
fn test_parse_remap_path_prefix() {
3803+
let h = parses!(
3804+
"--crate-name",
3805+
"foo",
3806+
"--crate-type",
3807+
"lib",
3808+
"./src/lib.rs",
3809+
"--emit=dep-info,link",
3810+
"--out-dir",
3811+
"/out",
3812+
"--remap-path-prefix",
3813+
"/home/test=~",
3814+
"--remap-path-prefix",
3815+
"/root=~"
3816+
);
3817+
assert!(h.arguments.contains(&Argument::WithValue(
3818+
"--remap-path-prefix",
3819+
ArgData::PassThrough(OsString::from("/home/test=~")),
3820+
ArgDisposition::Separated
3821+
)));
3822+
assert!(h.arguments.contains(&Argument::WithValue(
3823+
"--remap-path-prefix",
3824+
ArgData::PassThrough(OsString::from("/root=~")),
3825+
ArgDisposition::Separated
3826+
)));
3827+
}
3828+
38023829
#[test]
38033830
fn test_parse_target() {
38043831
// Parse a --target argument that is a string (not a path to a .json file).

0 commit comments

Comments
 (0)