@@ -128,6 +128,8 @@ pub(crate) struct Options {
128128 pub ( crate ) enable_per_target_ignores : bool ,
129129 /// Do not run doctests, compile them if should_test is active.
130130 pub ( crate ) no_run : bool ,
131+ /// What sources are being mapped.
132+ pub ( crate ) remap_path_prefix : Vec < ( PathBuf , PathBuf ) > ,
131133
132134 /// The path to a rustc-like binary to build tests with. If not set, we
133135 /// default to loading from `$sysroot/bin/rustc`.
@@ -211,6 +213,7 @@ impl fmt::Debug for Options {
211213 . field ( "run_check" , & self . run_check )
212214 . field ( "no_run" , & self . no_run )
213215 . field ( "test_builder_wrappers" , & self . test_builder_wrappers )
216+ . field ( "remap-file-prefix" , & self . remap_path_prefix )
214217 . field ( "nocapture" , & self . nocapture )
215218 . field ( "scrape_examples_options" , & self . scrape_examples_options )
216219 . field ( "unstable_features" , & self . unstable_features )
@@ -372,6 +375,13 @@ impl Options {
372375 let codegen_options = CodegenOptions :: build ( early_dcx, matches) ;
373376 let unstable_opts = UnstableOptions :: build ( early_dcx, matches) ;
374377
378+ let remap_path_prefix = match parse_remap_path_prefix ( & matches) {
379+ Ok ( prefix_mappings) => prefix_mappings,
380+ Err ( err) => {
381+ early_dcx. early_fatal ( err) ;
382+ }
383+ } ;
384+
375385 let dcx = new_dcx ( error_format, None , diagnostic_width, & unstable_opts) ;
376386
377387 // check for deprecated options
@@ -772,6 +782,7 @@ impl Options {
772782 run_check,
773783 no_run,
774784 test_builder_wrappers,
785+ remap_path_prefix,
775786 nocapture,
776787 crate_name,
777788 output_format,
@@ -820,6 +831,21 @@ impl Options {
820831 }
821832}
822833
834+ fn parse_remap_path_prefix (
835+ matches : & getopts:: Matches ,
836+ ) -> Result < Vec < ( PathBuf , PathBuf ) > , & ' static str > {
837+ matches
838+ . opt_strs ( "remap-path-prefix" )
839+ . into_iter ( )
840+ . map ( |remap| {
841+ remap
842+ . rsplit_once ( '=' )
843+ . ok_or ( "--remap-path-prefix must contain '=' between FROM and TO" )
844+ . map ( |( from, to) | ( PathBuf :: from ( from) , PathBuf :: from ( to) ) )
845+ } )
846+ . collect ( )
847+ }
848+
823849/// Prints deprecation warnings for deprecated options
824850fn check_deprecated_options ( matches : & getopts:: Matches , dcx : & rustc_errors:: DiagCtxt ) {
825851 let deprecated_flags = [ ] ;
0 commit comments