Rollup merge of #147611 - stablize-remap-path-scope, r=davidtwco

Stabilize `-Zremap-path-scope`

# Stabilization report of `--remap-path-scope`

## Summary

RFC 3127 trim-paths aims to improve the current status of sanitizing paths emitted by the compiler via the `--remap-path-prefix=FROM=TO` command line flag, by offering a profile setting named `trim-paths` in Cargo to sanitize absolute paths introduced during compilation that may be embedded in the compiled binary executable or library.

As part of that RFC the compiler was asked to add the `--remap-path-scope` command-line flag to control the scoping of how paths get remapped in the resulting binary.

Tracking:

- https://github.com/rust-lang/rust/issues/111540

### What is stabilized

The rustc `--remap-path-scope` flag is being stabilized by this PR. It defines which scopes of paths should be remapped by `--remap-path-prefix`.

This flag accepts a comma-separated list of values and may be specified multiple times, in which case the scopes are aggregated together.

The valid scopes are:

- `macro` - apply remappings to the expansion of `std::file!()` macro. This is where paths in embedded panic messages come from
- `diagnostics` - apply remappings to printed compiler diagnostics
- `debuginfo` - apply remappings to debug informations
- `coverage` - apply remappings to coverage informations
- `object` - apply remappings to all paths in compiled executables or libraries, but not elsewhere. Currently an alias for `macro,coverage,debuginfo`.
- `all` (default) - an alias for all of the above, also equivalent to supplying only `--remap-path-prefix` without `--remap-path-scope`.

#### Example

```sh
# With `object` scope only the build outputs will be remapped, the diagnostics won't be remapped.
rustc --remap-path-prefix=$(PWD)=/remapped --remap-path-scope=object main.rs
```

### What isn't stabilized

None of the Cargo facility is being stabilized in this stabilization PR, only the `--remap-path-scope` flag in `rustc` is being stabilized.

## Design

### RFC history

- [RFC3127 - trim-paths](https://rust-lang.github.io/rfcs/3127-trim-paths.html)

### Answers to unresolved questions

> What questions were left unresolved by the RFC? How have they been answered? Link to any relevant lang decisions.

There are no unresolved questions regarding `--remap-path-scope`.

(The tracking issue list a bunch of unresolved questions but they are for `--remap-path-prefix` or the bigger picture `trim-paths` in Cargo and are not related the functionality provided by `--remap-path-scope`.)

### Post-RFC changes

The RFC described more scopes, in particularly regarding split debuginfo. Those scopes where removed after analysis by `michaelwoerister` of all the possible combinations in https://github.com/rust-lang/rust/issues/111540#issuecomment-1994010274.

### Nightly extensions

There are no nightly extensions.

### Doors closed

We are committing to having to having a flag that control which paths are being remapped based on a "scope".

## Feedback

### Call for testing

> Has a "call for testing" been done? If so, what feedback was received?

No call for testing has been done per se but feedback has been received on both the rust-lang/rust and rust-lang/cargo tracking issue.

The feedback was mainly related to deficiencies in *our best-effort* `--remap-path-prefix` implementation, in particular regarding linkers added paths, which does not change anything for `--remap-path-scope`.

### Nightly use

> Do any known nightly users use this feature? Counting instances of `#![feature(FEATURE_NAME)]` on GitHub with grep might be informative.

Except for Cargo unstable `trim-paths` there doesn't appear any committed use [on GitHub](https://github.com/search?q=%22--remap-path-scope%22+NOT+path%3A%2F%5Esrc%5C%2Fcargo%5C%2Fcore%5C%2Fcompiler%5C%2F%2F+NOT+path%3A%2F%5Etext%5C%2F%2F+NOT+path%3A%2F%5Erust%5C%2Fsrc%5C%2Fdoc%5C%2Funstable-book%5C%2Fsrc%5C%2Fcompiler-flags%5C%2F%2F+NOT+path%3A%2F%5Esrc%5C%2Fdoc%5C%2Funstable-book%5C%2Fsrc%5C%2Fcompiler-flags%5C%2F%2F+NOT+path%3A%2F%5Ecollector%5C%2Fcompile-benchmarks%5C%2Fcargo-0%5C.87%5C.1%5C%2Fsrc%5C%2Fcargo%5C%2Fcore%5C%2Fcompiler%5C%2F%2F&type=code).

## Implementation

### Major parts

- b3f8586fb1/compiler/rustc_session/src/config.rs (L1373-L1384)
- b3f8586fb1/compiler/rustc_session/src/session.rs (L1526)
- b3f8586fb1/compiler/rustc_span/src/lib.rs (L352-L372)

### Coverage

- [`tests/run-make/split-debuginfo/rmake.rs`](9725c4baac/tests/run-make/split-debuginfo/rmake.rs (L7))
- [`tests/ui/errors/remap-path-prefix.rs`](9725c4baac/tests/ui/errors/remap-path-prefix.rs (L4))
- [`tests/ui/errors/remap-path-prefix-macro.rs`](9725c4baac/tests/ui/errors/remap-path-prefix-macro.rs (L1-L4))
- [`tests/run-make/remap-path-prefix-dwarf/rmake.rs
`](9725c4baac/tests/run-make/remap-path-prefix-dwarf/rmake.rs)
- [`tests/run-make/remap-path-prefix/rmake.rs`](9725c4baac/tests/run-make/remap-path-prefix/rmake.rs)
- [`tests/ui/errors/remap-path-prefix-diagnostics.rs`](9725c4baac/tests/ui/errors/remap-path-prefix-diagnostics.rs)

### Outstanding bugs

> What outstanding bugs involve this feature? List them. Should any block the stabilization? Discuss why or why not.

There are no outstanding bugs regarding `--remap-path-scope`.

### Outstanding FIXMEs

> What FIXMEs are still in the code for that feature and why is it OK to leave them there?

There are no FIXME regarding `--remap-path-scope` in it-self.

### Tool changes

> What changes must be made to our other tools to support this feature. Has this work been done? Link to any relevant PRs and issues.

- rustdoc (both JSON, HTML and doctest)
  - `rustdoc` has support for `--remap-path-prefix`, it should probably also get support for `--remap-path-scope`, although rustdoc maybe want to adapt the scopes for it's use (replace `debuginfo` with `documentation` for example).

## History

> List issues and PRs that are important for understanding how we got here.

- https://github.com/rust-lang/rust/pull/115214
- https://github.com/rust-lang/rust/pull/122450
- https://github.com/rust-lang/rust/pull/139550
- https://github.com/rust-lang/rust/pull/140716

## Acknowledgments

> Summarize contributors to the feature by name for recognition and so that those people are notified about the stabilization. Does anyone who worked on this *not* think it should be stabilized right now? We'd like to hear about that if so.

- @cbeuw
- @michaelwoerister
- @weihanglo
- @Urgau

@rustbot labels +T-compiler +needs-fcp +F-trim-paths
r? @davidtwco
This commit is contained in:
Guillaume Gomez 2026-01-20 14:36:30 +01:00 committed by GitHub
commit 1832bdfe64
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
22 changed files with 124 additions and 97 deletions

View file

@ -22,7 +22,9 @@ use rustc_hashes::Hash64;
use rustc_macros::{BlobDecodable, Decodable, Encodable, HashStable_Generic};
use rustc_span::edition::{DEFAULT_EDITION, EDITION_NAME_LIST, Edition, LATEST_STABLE_EDITION};
use rustc_span::source_map::FilePathMapping;
use rustc_span::{FileName, RealFileName, SourceFileHashAlgorithm, Symbol, sym};
use rustc_span::{
FileName, RealFileName, RemapPathScopeComponents, SourceFileHashAlgorithm, Symbol, sym,
};
use rustc_target::spec::{
FramePointer, LinkSelfContainedComponents, LinkerFeatures, PanicStrategy, SplitDebuginfo,
Target, TargetTuple,
@ -1317,6 +1319,29 @@ impl OutputFilenames {
}
}
pub(crate) fn parse_remap_path_scope(
early_dcx: &EarlyDiagCtxt,
matches: &getopts::Matches,
) -> RemapPathScopeComponents {
if let Some(v) = matches.opt_str("remap-path-scope") {
let mut slot = RemapPathScopeComponents::empty();
for s in v.split(',') {
slot |= match s {
"macro" => RemapPathScopeComponents::MACRO,
"diagnostics" => RemapPathScopeComponents::DIAGNOSTICS,
"debuginfo" => RemapPathScopeComponents::DEBUGINFO,
"coverage" => RemapPathScopeComponents::COVERAGE,
"object" => RemapPathScopeComponents::OBJECT,
"all" => RemapPathScopeComponents::all(),
_ => early_dcx.early_fatal("argument for `--remap-path-scope` must be a comma separated list of scopes: `macro`, `diagnostics`, `debuginfo`, `coverage`, `object`, `all`"),
}
}
slot
} else {
RemapPathScopeComponents::all()
}
}
#[derive(Clone, Debug)]
pub struct Sysroot {
pub explicit: Option<PathBuf>,
@ -1353,9 +1378,9 @@ pub fn host_tuple() -> &'static str {
fn file_path_mapping(
remap_path_prefix: Vec<(PathBuf, PathBuf)>,
unstable_opts: &UnstableOptions,
remap_path_scope: RemapPathScopeComponents,
) -> FilePathMapping {
FilePathMapping::new(remap_path_prefix.clone(), unstable_opts.remap_path_scope)
FilePathMapping::new(remap_path_prefix.clone(), remap_path_scope)
}
impl Default for Options {
@ -1367,7 +1392,7 @@ impl Default for Options {
// to create a default working directory.
let working_dir = {
let working_dir = std::env::current_dir().unwrap();
let file_mapping = file_path_mapping(Vec::new(), &unstable_opts);
let file_mapping = file_path_mapping(Vec::new(), RemapPathScopeComponents::empty());
file_mapping.to_real_filename(&RealFileName::empty(), &working_dir)
};
@ -1402,6 +1427,7 @@ impl Default for Options {
cli_forced_codegen_units: None,
cli_forced_local_thinlto_off: false,
remap_path_prefix: Vec::new(),
remap_path_scope: RemapPathScopeComponents::all(),
real_rust_source_base_dir: None,
real_rustc_dev_source_base_dir: None,
edition: DEFAULT_EDITION,
@ -1428,7 +1454,7 @@ impl Options {
}
pub fn file_path_mapping(&self) -> FilePathMapping {
file_path_mapping(self.remap_path_prefix.clone(), &self.unstable_opts)
file_path_mapping(self.remap_path_prefix.clone(), self.remap_path_scope)
}
/// Returns `true` if there will be an output file generated.
@ -1866,6 +1892,14 @@ pub fn rustc_optgroups() -> Vec<RustcOptGroup> {
"Remap source names in all output (compiler messages and output files)",
"<FROM>=<TO>",
),
opt(
Stable,
Opt,
"",
"remap-path-scope",
"Defines which scopes of paths should be remapped by `--remap-path-prefix`",
"<macro,diagnostics,debuginfo,coverage,object,all>",
),
opt(Unstable, Multi, "", "env-set", "Inject an environment variable", "<VAR>=<VALUE>"),
];
options.extend(verbose_only.into_iter().map(|mut opt| {
@ -2669,6 +2703,7 @@ pub fn build_session_options(early_dcx: &mut EarlyDiagCtxt, matches: &getopts::M
let externs = parse_externs(early_dcx, matches, &unstable_opts);
let remap_path_prefix = parse_remap_path_prefix(early_dcx, matches, &unstable_opts);
let remap_path_scope = parse_remap_path_scope(early_dcx, matches);
let pretty = parse_pretty(early_dcx, &unstable_opts);
@ -2735,7 +2770,7 @@ pub fn build_session_options(early_dcx: &mut EarlyDiagCtxt, matches: &getopts::M
early_dcx.early_fatal(format!("Current directory is invalid: {e}"));
});
let file_mapping = file_path_mapping(remap_path_prefix.clone(), &unstable_opts);
let file_mapping = file_path_mapping(remap_path_prefix.clone(), remap_path_scope);
file_mapping.to_real_filename(&RealFileName::empty(), &working_dir)
};
@ -2772,6 +2807,7 @@ pub fn build_session_options(early_dcx: &mut EarlyDiagCtxt, matches: &getopts::M
cli_forced_codegen_units: codegen_units,
cli_forced_local_thinlto_off: disable_local_thinlto,
remap_path_prefix,
remap_path_scope,
real_rust_source_base_dir,
real_rustc_dev_source_base_dir,
edition,

View file

@ -454,6 +454,8 @@ top_level_options!(
/// Remap source path prefixes in all output (messages, object files, debug, etc.).
remap_path_prefix: Vec<(PathBuf, PathBuf)> [TRACKED_NO_CRATE_HASH],
/// Defines which scopes of paths should be remapped by `--remap-path-prefix`.
remap_path_scope: RemapPathScopeComponents [TRACKED_NO_CRATE_HASH],
/// Base directory containing the `library/` directory for the Rust standard library.
/// Right now it's always `$sysroot/lib/rustlib/src/rust`
@ -872,7 +874,6 @@ mod desc {
pub(crate) const parse_branch_protection: &str = "a `,` separated combination of `bti`, `gcs`, `pac-ret`, (optionally with `pc`, `b-key`, `leaf` if `pac-ret` is set)";
pub(crate) const parse_proc_macro_execution_strategy: &str =
"one of supported execution strategies (`same-thread`, or `cross-thread`)";
pub(crate) const parse_remap_path_scope: &str = "comma separated list of scopes: `macro`, `diagnostics`, `debuginfo`, `coverage`, `object`, `all`";
pub(crate) const parse_inlining_threshold: &str =
"either a boolean (`yes`, `no`, `on`, `off`, etc), or a non-negative number";
pub(crate) const parse_llvm_module_flag: &str = "<key>:<type>:<value>:<behavior>. Type must currently be `u32`. Behavior should be one of (`error`, `warning`, `require`, `override`, `append`, `appendunique`, `max`, `min`)";
@ -1737,29 +1738,6 @@ pub mod parse {
true
}
pub(crate) fn parse_remap_path_scope(
slot: &mut RemapPathScopeComponents,
v: Option<&str>,
) -> bool {
if let Some(v) = v {
*slot = RemapPathScopeComponents::empty();
for s in v.split(',') {
*slot |= match s {
"macro" => RemapPathScopeComponents::MACRO,
"diagnostics" => RemapPathScopeComponents::DIAGNOSTICS,
"debuginfo" => RemapPathScopeComponents::DEBUGINFO,
"coverage" => RemapPathScopeComponents::COVERAGE,
"object" => RemapPathScopeComponents::OBJECT,
"all" => RemapPathScopeComponents::all(),
_ => return false,
}
}
true
} else {
false
}
}
pub(crate) fn parse_relocation_model(slot: &mut Option<RelocModel>, v: Option<&str>) -> bool {
match v.and_then(|s| RelocModel::from_str(s).ok()) {
Some(relocation_model) => *slot = Some(relocation_model),
@ -2614,8 +2592,6 @@ options! {
"whether ELF relocations can be relaxed"),
remap_cwd_prefix: Option<PathBuf> = (None, parse_opt_pathbuf, [TRACKED],
"remap paths under the current working directory to this path prefix"),
remap_path_scope: RemapPathScopeComponents = (RemapPathScopeComponents::all(), parse_remap_path_scope, [TRACKED],
"remap path scope (default: all)"),
remark_dir: Option<PathBuf> = (None, parse_opt_pathbuf, [UNTRACKED],
"directory into which to write optimization remarks (if not specified, they will be \
written to standard error output)"),

View file

@ -428,6 +428,14 @@ specified multiple times.
Refer to the [Remap source paths](remap-source-paths.md) section of this book for
further details and explanation.
<a id="option-remap-path-scope"></a>
## `--remap-path-scope`: remap source paths in output
Defines which scopes of paths should be remapped by `--remap-path-prefix`.
Refer to the [Remap source paths](remap-source-paths.md) section of this book for
further details and explanation.
<a id="option-json"></a>
## `--json`: configure json messages printed by the compiler

View file

@ -6,7 +6,7 @@ output, including compiler diagnostics, debugging information, macro expansions,
This is useful for normalizing build products, for example, by removing the current directory
out of the paths emitted into object files.
The remapping is done via the `--remap-path-prefix` option.
The remapping is done via the `--remap-path-prefix` flag and can be customized via the `--remap-path-scope` flag.
## `--remap-path-prefix`
@ -39,6 +39,31 @@ rustc --remap-path-prefix "/home/user/project=/redacted"
This example replaces all occurrences of `/home/user/project` in emitted paths with `/redacted`.
## `--remap-path-scope`
Defines which scopes of paths should be remapped by `--remap-path-prefix`.
This flag accepts a comma-separated list of values and may be specified multiple times, in which case the scopes are aggregated together.
The valid scopes are:
- `macro` - apply remappings to the expansion of `std::file!()` macro. This is where paths in embedded panic messages come from
- `diagnostics` - apply remappings to printed compiler diagnostics
- `debuginfo` - apply remappings to debug information
- `coverage` - apply remappings to coverage information
- `object` - apply remappings to all paths in compiled executables or libraries, but not elsewhere. Currently an alias for `macro,coverage,debuginfo`.
- `all` (default) - an alias for all of the above, also equivalent to supplying only `--remap-path-prefix` without `--remap-path-scope`.
The scopes accepted by `--remap-path-scope` are not exhaustive - new scopes may be added in future releases for eventual stabilisation.
This implies that the `all` scope can correspond to different scopes between releases.
### Example
```sh
# With `object` scope only the build outputs will be remapped, the diagnostics won't be remapped.
rustc --remap-path-prefix=$(PWD)=/remapped --remap-path-scope=object main.rs
```
## Caveats and Limitations
### Paths generated by linkers

View file

@ -1,23 +0,0 @@
# `remap-path-scope`
The tracking issue for this feature is: [#111540](https://github.com/rust-lang/rust/issues/111540).
------------------------
When the `--remap-path-prefix` option is passed to rustc, source path prefixes in all output will be affected by default.
The `--remap-path-scope` argument can be used in conjunction with `--remap-path-prefix` to determine paths in which output context should be affected.
This flag accepts a comma-separated list of values and may be specified multiple times, in which case the scopes are aggregated together. The valid scopes are:
- `macro` - apply remappings to the expansion of `std::file!()` macro. This is where paths in embedded panic messages come from
- `diagnostics` - apply remappings to printed compiler diagnostics
- `debuginfo` - apply remappings to debug information
- `coverage` - apply remappings to coverage information
- `object` - apply remappings to all paths in compiled executables or libraries, but not elsewhere. Currently an alias for `macro,debuginfo`.
- `all` - an alias for all of the above, also equivalent to supplying only `--remap-path-prefix` without `--remap-path-scope`.
## Example
```sh
# This would produce an absolute path to main.rs in build outputs of
# "./main.rs".
rustc --remap-path-prefix=$(PWD)=/remapped -Zremap-path-scope=object main.rs
```

View file

@ -10,8 +10,8 @@
//@ revisions: with_remap with_coverage_scope with_object_scope with_macro_scope
//@ compile-flags: --remap-path-prefix={{src-base}}=remapped
//
//@[with_coverage_scope] compile-flags: -Zremap-path-scope=coverage
//@[with_object_scope] compile-flags: -Zremap-path-scope=object
//@[with_macro_scope] compile-flags: -Zremap-path-scope=macro
//@[with_coverage_scope] compile-flags: --remap-path-scope=coverage
//@[with_object_scope] compile-flags: --remap-path-scope=object
//@[with_macro_scope] compile-flags: --remap-path-scope=macro
fn main() {}

View file

@ -10,9 +10,9 @@
LL| |//@ revisions: with_remap with_coverage_scope with_object_scope with_macro_scope
LL| |//@ compile-flags: --remap-path-prefix={{src-base}}=remapped
LL| |//
LL| |//@[with_coverage_scope] compile-flags: -Zremap-path-scope=coverage
LL| |//@[with_object_scope] compile-flags: -Zremap-path-scope=object
LL| |//@[with_macro_scope] compile-flags: -Zremap-path-scope=macro
LL| |//@[with_coverage_scope] compile-flags: --remap-path-scope=coverage
LL| |//@[with_object_scope] compile-flags: --remap-path-scope=object
LL| |//@[with_macro_scope] compile-flags: --remap-path-scope=macro
LL| |
LL| 1|fn main() {}

View file

@ -97,7 +97,7 @@ fn main() {
location_caller
.crate_type("lib")
.remap_path_prefix(cwd(), "/remapped")
.arg("-Zremap-path-scope=object")
.arg("--remap-path-scope=object")
.input(cwd().join("location-caller.rs"));
location_caller.run();
@ -105,7 +105,7 @@ fn main() {
runner
.crate_type("bin")
.remap_path_prefix(cwd(), "/remapped")
.arg("-Zremap-path-scope=diagnostics")
.arg("--remap-path-scope=diagnostics")
.input(cwd().join("runner.rs"))
.output(&runner_bin);
runner.run();

View file

@ -105,7 +105,7 @@ fn check_dwarf_deps(scope: &str, dwarf_test: DwarfDump) {
let mut rustc_sm = rustc();
rustc_sm.input(cwd().join("src/some_value.rs"));
rustc_sm.arg("-Cdebuginfo=2");
rustc_sm.arg(format!("-Zremap-path-scope={}", scope));
rustc_sm.arg(format!("--remap-path-scope={}", scope));
rustc_sm.arg("--remap-path-prefix");
rustc_sm.arg(format!("{}=/REMAPPED", cwd().display()));
rustc_sm.arg("-Csplit-debuginfo=off");
@ -117,7 +117,7 @@ fn check_dwarf_deps(scope: &str, dwarf_test: DwarfDump) {
rustc_pv.input(cwd().join("src/print_value.rs"));
rustc_pv.output(&print_value_rlib);
rustc_pv.arg("-Cdebuginfo=2");
rustc_pv.arg(format!("-Zremap-path-scope={}", scope));
rustc_pv.arg(format!("--remap-path-scope={}", scope));
rustc_pv.arg("--remap-path-prefix");
rustc_pv.arg(format!("{}=/REMAPPED", cwd().display()));
rustc_pv.arg("-Csplit-debuginfo=off");
@ -158,8 +158,8 @@ fn check_dwarf(test: DwarfTest) {
rustc.arg("-Cdebuginfo=2");
if let Some(scope) = test.scope {
match scope {
ScopeType::Object => rustc.arg("-Zremap-path-scope=object"),
ScopeType::Diagnostics => rustc.arg("-Zremap-path-scope=diagnostics"),
ScopeType::Object => rustc.arg("--remap-path-scope=object"),
ScopeType::Diagnostics => rustc.arg("--remap-path-scope=diagnostics"),
};
if is_darwin() {
rustc.arg("-Csplit-debuginfo=off");

View file

@ -38,9 +38,9 @@ fn main() {
rmeta_contains("/the/aux/lib.rs");
rmeta_not_contains("auxiliary");
out_object.arg("-Zremap-path-scope=object");
out_macro.arg("-Zremap-path-scope=macro");
out_diagobj.arg("-Zremap-path-scope=diagnostics,object");
out_object.arg("--remap-path-scope=object");
out_macro.arg("--remap-path-scope=macro");
out_diagobj.arg("--remap-path-scope=diagnostics,object");
if is_darwin() {
out_object.arg("-Csplit-debuginfo=off");
out_macro.arg("-Csplit-debuginfo=off");

View file

@ -1,4 +1,4 @@
@@ -65,10 +65,28 @@
@@ -65,10 +65,31 @@
Set a codegen option
-V, --version Print version info and exit
-v, --verbose Use verbose output
@ -20,6 +20,9 @@
+ --remap-path-prefix <FROM>=<TO>
+ Remap source names in all output (compiler messages
+ and output files)
+ --remap-path-scope <macro,diagnostics,debuginfo,coverage,object,all>
+ Defines which scopes of paths should be remapped by
+ `--remap-path-prefix`
+ @path Read newline separated options from `path`
Additional help:

View file

@ -83,6 +83,9 @@ Options:
--remap-path-prefix <FROM>=<TO>
Remap source names in all output (compiler messages
and output files)
--remap-path-scope <macro,diagnostics,debuginfo,coverage,object,all>
Defines which scopes of paths should be remapped by
`--remap-path-prefix`
@path Read newline separated options from `path`
Additional help:

View file

@ -171,8 +171,7 @@ enum RemapPathPrefix {
Unspecified,
}
/// `-Zremap-path-scope`. See
/// <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/remap-path-scope.html#remap-path-scope>.
/// `--remap-path-scope`
#[derive(Debug, Clone)]
enum RemapPathScope {
/// Comma-separated list of remap scopes: `macro`, `diagnostics`, `debuginfo`, `object`, `all`.
@ -921,7 +920,7 @@ mod shared_linux_other_tests {
.debuginfo(level.cli_value())
.arg(format!("-Zsplit-dwarf-kind={}", split_dwarf_kind.cli_value()))
.remap_path_prefix(cwd(), remapped_prefix)
.arg(format!("-Zremap-path-scope={scope}"))
.arg(format!("--remap-path-scope={scope}"))
.run();
let found_files = cwd_filenames();
FileAssertions { expected_files: BTreeSet::from(["foo", "foo.dwp"]) }
@ -950,7 +949,7 @@ mod shared_linux_other_tests {
.debuginfo(level.cli_value())
.arg(format!("-Zsplit-dwarf-kind={}", split_dwarf_kind.cli_value()))
.remap_path_prefix(cwd(), remapped_prefix)
.arg(format!("-Zremap-path-scope={scope}"))
.arg(format!("--remap-path-scope={scope}"))
.run();
let found_files = cwd_filenames();
FileAssertions { expected_files: BTreeSet::from(["foo", "foo.dwp"]) }
@ -1202,7 +1201,7 @@ mod shared_linux_other_tests {
.debuginfo(level.cli_value())
.arg(format!("-Zsplit-dwarf-kind={}", split_dwarf_kind.cli_value()))
.remap_path_prefix(cwd(), remapped_prefix)
.arg(format!("-Zremap-path-scope={scope}"))
.arg(format!("--remap-path-scope={scope}"))
.run();
let found_files = cwd_filenames();
@ -1242,7 +1241,7 @@ mod shared_linux_other_tests {
.debuginfo(level.cli_value())
.arg(format!("-Zsplit-dwarf-kind={}", split_dwarf_kind.cli_value()))
.remap_path_prefix(cwd(), remapped_prefix)
.arg(format!("-Zremap-path-scope={scope}"))
.arg(format!("--remap-path-scope={scope}"))
.run();
let found_files = cwd_filenames();
@ -1356,7 +1355,7 @@ fn main() {
// NOTE: these combinations are not exhaustive, because while porting to rmake.rs initially I
// tried to preserve the existing test behavior closely. Notably, no attempt was made to
// exhaustively cover all cases in the 6-fold Cartesian product of `{,-Csplit=debuginfo=...}` x
// `{,-Cdebuginfo=...}` x `{,--remap-path-prefix}` x `{,-Zremap-path-scope=...}` x
// `{,-Cdebuginfo=...}` x `{,--remap-path-prefix}` x `{,--remap-path-scope=...}` x
// `{,-Zsplit-dwarf-kind=...}` x `{,-Clinker-plugin-lto}`. If you really want to, you can
// identify which combination isn't exercised with a 6-layers nested for loop iterating through
// each of the cli flag enum variants.

View file

@ -1,5 +1,5 @@
//@ compile-flags: --remap-path-prefix={{src-base}}=remapped
//@ compile-flags: -Zremap-path-scope=debuginfo
//@ compile-flags: --remap-path-scope=debuginfo
#[macro_export]
macro_rules! my_file {

View file

@ -1,5 +1,5 @@
//@ compile-flags: --remap-path-prefix={{src-base}}=remapped
//@ compile-flags: -Zremap-path-scope=diagnostics
//@ compile-flags: --remap-path-scope=diagnostics
#[macro_export]
macro_rules! my_file {

View file

@ -1,5 +1,5 @@
//@ compile-flags: --remap-path-prefix={{src-base}}=remapped
//@ compile-flags: -Zremap-path-scope=macro
//@ compile-flags: --remap-path-scope=macro
#[macro_export]
macro_rules! my_file {

View file

@ -1,4 +1,4 @@
//@ compile-flags: --remap-path-prefix={{src-base}}=remapped
//@ compile-flags: -Zremap-path-scope=debuginfo
//@ compile-flags: --remap-path-scope=debuginfo
pub trait Trait: std::fmt::Display {}

View file

@ -1,4 +1,4 @@
//@ compile-flags: --remap-path-prefix={{src-base}}=remapped
//@ compile-flags: -Zremap-path-scope=diagnostics
//@ compile-flags: --remap-path-scope=diagnostics
pub trait Trait: std::fmt::Display {}

View file

@ -1,4 +1,4 @@
//@ compile-flags: --remap-path-prefix={{src-base}}=remapped
//@ compile-flags: -Zremap-path-scope=macro
//@ compile-flags: --remap-path-scope=macro
pub trait Trait: std::fmt::Display {}

View file

@ -1,4 +1,4 @@
// This test exercises `-Zremap-path-scope`, diagnostics printing paths and dependency.
// This test exercises `--remap-path-scope`, diagnostics printing paths and dependency.
//
// We test different combinations with/without remap in deps, with/without remap in this
// crate but always in deps and always here but never in deps.
@ -12,10 +12,10 @@
//@[with-debuginfo-in-deps] compile-flags: --remap-path-prefix={{src-base}}=remapped
//@[not-diag-in-deps] compile-flags: --remap-path-prefix={{src-base}}=remapped
//@[with-diag-in-deps] compile-flags: -Zremap-path-scope=diagnostics
//@[with-macro-in-deps] compile-flags: -Zremap-path-scope=macro
//@[with-debuginfo-in-deps] compile-flags: -Zremap-path-scope=debuginfo
//@[not-diag-in-deps] compile-flags: -Zremap-path-scope=diagnostics
//@[with-diag-in-deps] compile-flags: --remap-path-scope=diagnostics
//@[with-macro-in-deps] compile-flags: --remap-path-scope=macro
//@[with-debuginfo-in-deps] compile-flags: --remap-path-scope=debuginfo
//@[not-diag-in-deps] compile-flags: --remap-path-scope=diagnostics
//@[with-diag-in-deps] aux-build:trait-diag.rs
//@[with-macro-in-deps] aux-build:trait-macro.rs

View file

@ -1,4 +1,4 @@
// This test exercises `-Zremap-path-scope`, macros (like file!()) and dependency.
// This test exercises `--remap-path-scope`, macros (like file!()) and dependency.
//
// We test different combinations with/without remap in deps, with/without remap in
// this crate but always in deps and always here but never in deps.
@ -15,10 +15,10 @@
//@[with-debuginfo-in-deps] compile-flags: --remap-path-prefix={{src-base}}=remapped
//@[not-macro-in-deps] compile-flags: --remap-path-prefix={{src-base}}=remapped
//@[with-diag-in-deps] compile-flags: -Zremap-path-scope=diagnostics
//@[with-macro-in-deps] compile-flags: -Zremap-path-scope=macro
//@[with-debuginfo-in-deps] compile-flags: -Zremap-path-scope=debuginfo
//@[not-macro-in-deps] compile-flags: -Zremap-path-scope=macro
//@[with-diag-in-deps] compile-flags: --remap-path-scope=diagnostics
//@[with-macro-in-deps] compile-flags: --remap-path-scope=macro
//@[with-debuginfo-in-deps] compile-flags: --remap-path-scope=debuginfo
//@[not-macro-in-deps] compile-flags: --remap-path-scope=macro
//@[with-diag-in-deps] aux-build:file-diag.rs
//@[with-macro-in-deps] aux-build:file-macro.rs

View file

@ -1,7 +1,7 @@
//@ revisions: normal with-diagnostic-scope without-diagnostic-scope
//@ compile-flags: --remap-path-prefix={{src-base}}=remapped
//@ [with-diagnostic-scope]compile-flags: -Zremap-path-scope=diagnostics
//@ [without-diagnostic-scope]compile-flags: -Zremap-path-scope=object
//@ [with-diagnostic-scope]compile-flags: --remap-path-scope=diagnostics
//@ [without-diagnostic-scope]compile-flags: --remap-path-scope=object
// Manually remap, so the remapped path remains in .stderr file.
// The remapped paths are not normalized by compiletest.