rust-lang / rust-lang/rust

Support different paths remapping for different scopes

Open
#142,917 12 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-path-remapping F-trim-paths T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

I want to raise that I think it should be possible to apply different remapping to the same path for different scopes. It seems like remap-path-prefix was too generic in remapping across many different use cases, and now the scope argument is being introduced to limit the scope, but that doesn't deal with the situation where you want to remap the same path differently across scopes.

E.g. imagine I want to remap /home/cameron/code/project to "." for macro, but to "" for split-debuginfo. This would be necessary on macOS, where OSO stabs cannot use relative paths (see #132143).

You could imagine doing something like:

rustc ...
  --remap-path-scope=split-debuginfo \
  --remap-path-prefix=/home/cameron/code/project=. \
  --remap-path-scope=macro \
  --remap-path-prefix=/home/cameron/code/project=

But repeated usage of these flags are independently aggregated, rather than ordered, so that wouldn't work.

Not sure on the right design here, but I do think being able to express ^ is worthwhile.

Originally posted by @csmulhern in #111540

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing rustc's existing --remap-path-scope and --remap-path-prefix handling, including the behavior described in issue #132143. Define how repeated flags should associate a path remapping with each scope, then verify that the example distinguishes macro and split-debuginfo remappings without changing unrelated scopes.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.