about summary refs log tree commit diff
path: root/tests/rustdoc-ui/remap-path-prefix-macro.rs
diff options
context:
space:
mode:
authorCharalampos Mitrodimas <charmitro@posteo.net>2025-03-16 11:28:21 +0100
committerCharalampos Mitrodimas <charmitro@posteo.net>2025-03-16 23:37:09 +0100
commitb14810669a805003cf6392447c08eed79441936f (patch)
treef51980f8b34190575ed36191ea1d203c04b2b96b /tests/rustdoc-ui/remap-path-prefix-macro.rs
parent5f3b84a42199278114b6e3d95f406de05e0446f4 (diff)
downloadrust-b14810669a805003cf6392447c08eed79441936f.tar.gz
rust-b14810669a805003cf6392447c08eed79441936f.zip
Fix ICE: attempted to remap an already remapped filename
This commit fixes an internal compiler error (ICE) that occurs when
rustdoc attempts to process macros with a remapped filename. The issue
arose during macro expansion when the `--remap-path-prefix` option was
used.

Instead of passing remapped filenames through, which would trigger the
"attempted to remap an already remapped filename" panic, we now
extract the original local path from remapped filenames before
processing them.

A test case has been added to verify this behavior.

Fixes #138520

Signed-off-by: Charalampos Mitrodimas <charmitro@posteo.net>
Diffstat (limited to 'tests/rustdoc-ui/remap-path-prefix-macro.rs')
-rw-r--r--tests/rustdoc-ui/remap-path-prefix-macro.rs9
1 files changed, 9 insertions, 0 deletions
diff --git a/tests/rustdoc-ui/remap-path-prefix-macro.rs b/tests/rustdoc-ui/remap-path-prefix-macro.rs
new file mode 100644
index 00000000000..1be22694b8c
--- /dev/null
+++ b/tests/rustdoc-ui/remap-path-prefix-macro.rs
@@ -0,0 +1,9 @@
+// Regression test for "attempted to remap an already remapped filename" ICE in rustdoc
+// when using --remap-path-prefix with macro rendering.
+// <https://github.com/rust-lang/rust/issues/138520>
+
+//@ compile-flags:-Z unstable-options --remap-path-prefix={{src-base}}=remapped_path
+//@ rustc-env:RUST_BACKTRACE=0
+//@ build-pass
+
+macro_rules! f(() => {});