Skip to content

Commit

Permalink
Pass through --remap-path-prefix argument. (#2270)
Browse files Browse the repository at this point in the history
* Pass through `--remap-path-prefix` argument.

* Nothing is TooHard anymore in the Rust world!

* Add a test for `--remap-path-prefix`
  • Loading branch information
ColinFinck authored Jan 8, 2025
1 parent 9ca8beb commit e8b9af4
Showing 1 changed file with 30 additions and 3 deletions.
33 changes: 30 additions & 3 deletions src/compiler/rust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1000,7 +1000,6 @@ impl IntoArg for ArgTarget {

ArgData! {
TooHardFlag,
TooHard(OsString),
TooHardPath(PathBuf),
NotCompilationFlag,
NotCompilation(OsString),
Expand Down Expand Up @@ -1045,7 +1044,7 @@ counted_array!(static ARGS: [ArgInfo<ArgData>; _] = [
take_arg!("--out-dir", PathBuf, CanBeSeparated('='), OutDir),
take_arg!("--pretty", OsString, CanBeSeparated('='), NotCompilation),
take_arg!("--print", OsString, CanBeSeparated('='), NotCompilation),
take_arg!("--remap-path-prefix", OsString, CanBeSeparated('='), TooHard),
take_arg!("--remap-path-prefix", OsString, CanBeSeparated('='), PassThrough),
take_arg!("--sysroot", PathBuf, CanBeSeparated('='), TooHardPath),
take_arg!("--target", ArgTarget, CanBeSeparated('='), Target),
take_arg!("--unpretty", OsString, CanBeSeparated('='), NotCompilation),
Expand Down Expand Up @@ -1088,7 +1087,7 @@ fn parse_arguments(arguments: &[OsString], cwd: &Path) -> CompilerArguments<Pars
for arg in ArgsIter::new(arguments.iter().cloned(), &ARGS[..]) {
let arg = try_or_cannot_cache!(arg, "argument parse");
match arg.get_data() {
Some(TooHardFlag) | Some(TooHard(_)) | Some(TooHardPath(_)) => {
Some(TooHardFlag) | Some(TooHardPath(_)) => {
cannot_cache!(arg.flag_str().expect("Can't be Argument::Raw/UnknownFlag",))
}
Some(NotCompilationFlag) | Some(NotCompilation(_)) => {
Expand Down Expand Up @@ -3799,6 +3798,34 @@ proc_macro false
assert_eq!(h.gcno, Some("foo-a1b6419f8321841f.gcno".into()));
}

#[test]
fn test_parse_remap_path_prefix() {
let h = parses!(
"--crate-name",
"foo",
"--crate-type",
"lib",
"./src/lib.rs",
"--emit=dep-info,link",
"--out-dir",
"/out",
"--remap-path-prefix",
"/home/test=~",
"--remap-path-prefix",
"/root=~"
);
assert!(h.arguments.contains(&Argument::WithValue(
"--remap-path-prefix",
ArgData::PassThrough(OsString::from("/home/test=~")),
ArgDisposition::Separated
)));
assert!(h.arguments.contains(&Argument::WithValue(
"--remap-path-prefix",
ArgData::PassThrough(OsString::from("/root=~")),
ArgDisposition::Separated
)));
}

#[test]
fn test_parse_target() {
// Parse a --target argument that is a string (not a path to a .json file).
Expand Down

0 comments on commit e8b9af4

Please sign in to comment.