@@ -128,6 +128,8 @@ pub(crate) struct Options {
128
128
pub ( crate ) enable_per_target_ignores : bool ,
129
129
/// Do not run doctests, compile them if should_test is active.
130
130
pub ( crate ) no_run : bool ,
131
+ /// What sources are being mapped.
132
+ pub ( crate ) remap_path_prefix : Vec < ( PathBuf , PathBuf ) > ,
131
133
132
134
/// The path to a rustc-like binary to build tests with. If not set, we
133
135
/// default to loading from `$sysroot/bin/rustc`.
@@ -211,6 +213,7 @@ impl fmt::Debug for Options {
211
213
. field ( "run_check" , & self . run_check )
212
214
. field ( "no_run" , & self . no_run )
213
215
. field ( "test_builder_wrappers" , & self . test_builder_wrappers )
216
+ . field ( "remap-file-prefix" , & self . remap_path_prefix )
214
217
. field ( "nocapture" , & self . nocapture )
215
218
. field ( "scrape_examples_options" , & self . scrape_examples_options )
216
219
. field ( "unstable_features" , & self . unstable_features )
@@ -372,6 +375,13 @@ impl Options {
372
375
let codegen_options = CodegenOptions :: build ( early_dcx, matches) ;
373
376
let unstable_opts = UnstableOptions :: build ( early_dcx, matches) ;
374
377
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
+
375
385
let dcx = new_dcx ( error_format, None , diagnostic_width, & unstable_opts) ;
376
386
377
387
// check for deprecated options
@@ -772,6 +782,7 @@ impl Options {
772
782
run_check,
773
783
no_run,
774
784
test_builder_wrappers,
785
+ remap_path_prefix,
775
786
nocapture,
776
787
crate_name,
777
788
output_format,
@@ -820,6 +831,21 @@ impl Options {
820
831
}
821
832
}
822
833
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
+
823
849
/// Prints deprecation warnings for deprecated options
824
850
fn check_deprecated_options ( matches : & getopts:: Matches , dcx : & rustc_errors:: DiagCtxt ) {
825
851
let deprecated_flags = [ ] ;
0 commit comments