Skip to content

ICE: rustdoc: attempted to remap an already remapped filename #138520

Closed
@ojeda

Description

@ojeda

Code

echo 'macro_rules! f(() => {});' > x.rs
RUSTC_BOOTSTRAP=1 rustdoc -Zunstable-options --remap-path-prefix=./= ./x.rs

It reproduces with rustdoc, but not rustc.

We hit this building the documentation for the Linux kernel (for our custom compiler_builtins crate).

Meta

rustc 1.82.0 (f6e511eec 2024-10-15)
rustc 1.85.0 (4d91de4e4 2025-02-17)
rustc 1.86.0-beta.5 (b2af9a598 2025-03-08)
rustc 1.87.0-nightly (cbfdf0b01 2025-03-13)

It does not reproduce in 1.81.0, when the flag was introduced to rustdoc, but I imagine it is simply due to commit fd89197 ("Fix rustdoc missing handling of remap-path-prefix option").

Error output

internal error: entered unreachable code: attempted to remap an already remapped filename
Backtrace

thread 'rustc' panicked at compiler/rustc_span/src/source_map.rs:1170:34:
internal error: entered unreachable code: attempted to remap an already remapped filename
stack backtrace:
   0:     0x7d3d472dc07a - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::he089f96442833f67
   1:     0x7d3d47a14d26 - core::fmt::write::h2f210ed4c94745cb
   2:     0x7d3d4890f7d1 - std::io::Write::write_fmt::h7de08171ab770fb2
   3:     0x7d3d472dbed2 - std::sys::backtrace::BacktraceLock::print::h810fbd31421329e6
   4:     0x7d3d472de477 - std::panicking::default_hook::{{closure}}::hbaad47ed9dc6356d
   5:     0x7d3d472de260 - std::panicking::default_hook::h24e207139139d40a
   6:     0x7d3d4644e258 - std[cba35227022cdb8c]::panicking::update_hook::<alloc[304106e3416ed1f2]::boxed::Box<rustc_driver_impl[16f35eaf1f029c02]::install_ice_hook::{closure#1}>>::{closure#0}
   7:     0x7d3d472decc3 - std::panicking::rust_panic_with_hook::ha9131beeb2ddc506
   8:     0x7d3d472de986 - std::panicking::begin_panic_handler::{{closure}}::h1bba0eaeb6da506f
   9:     0x7d3d472dc549 - std::sys::backtrace::__rust_end_short_backtrace::h1d1ca3eade483f4c
  10:     0x7d3d472de67d - rust_begin_unwind
  11:     0x7d3d43fa1480 - core::panicking::panic_fmt::h896a0727a1a943f9
  12:     0x7d3d48963cfb - <rustc_span[7c0f9ff7c6ad315d]::source_map::FilePathMapping>::map_filename_prefix
  13:     0x7d3d48963e37 - <rustc_span[7c0f9ff7c6ad315d]::source_map::SourceMap>::new_source_file
  14:     0x7d3d48963421 - rustc_parse[192da714918a5014]::new_parser_from_source_str
  15:     0x611ca64e52e6 - rustdoc[bc9829b44a9905a9]::clean::render_macro_matchers::render_macro_matcher
  16:     0x611ca64f6e7f - rustdoc[bc9829b44a9905a9]::clean::utils::render_macro_arms::<core[3b140760090fa97d]::iter::adapters::map::Map<core[3b140760090fa97d]::slice::iter::Chunks<rustc_ast[59cd571f1bf64f97]::tokenstream::TokenTree>, rustdoc[bc9829b44a9905a9]::clean::utils::display_macro_source::{closure#0}>>
  17:     0x611ca64f7069 - rustdoc[bc9829b44a9905a9]::clean::utils::display_macro_source
  18:     0x611ca650e915 - rustdoc[bc9829b44a9905a9]::clean::clean_maybe_renamed_item::{closure#1}
  19:     0x611ca64f81a5 - rustdoc[bc9829b44a9905a9]::clean::clean_doc_module
  20:     0x611ca6522159 - rustdoc[bc9829b44a9905a9]::core::run_global_ctxt
  21:     0x611ca63d5dde - rustc_interface[d49f06094f81b30c]::passes::create_and_enter_global_ctxt::<(), rustdoc[bc9829b44a9905a9]::main_args::{closure#2}::{closure#0}>::{closure#2}::{closure#0}
  22:     0x611ca63e3739 - <rustc_interface[d49f06094f81b30c]::passes::create_and_enter_global_ctxt<(), rustdoc[bc9829b44a9905a9]::main_args::{closure#2}::{closure#0}>::{closure#2} as core[3b140760090fa97d]::ops::function::FnOnce<(&rustc_session[8ddc36379c4b7790]::session::Session, rustc_middle[c26a501345a63c03]::ty::context::CurrentGcx, &std[cba35227022cdb8c]::sync::once_lock::OnceLock<rustc_middle[c26a501345a63c03]::ty::context::GlobalCtxt>, &rustc_data_structures[3109d5d84592bd45]::sync::worker_local::WorkerLocal<rustc_middle[c26a501345a63c03]::arena::Arena>, &rustc_data_structures[3109d5d84592bd45]::sync::worker_local::WorkerLocal<rustc_hir[22be481a0a9f7622]::Arena>, rustdoc[bc9829b44a9905a9]::main_args::{closure#2}::{closure#0})>>::call_once::{shim:vtable#0}
  23:     0x611ca63cf618 - rustc_interface[d49f06094f81b30c]::interface::run_compiler::<(), rustdoc[bc9829b44a9905a9]::main_args::{closure#2}>::{closure#1}
  24:     0x611ca6357f79 - std[cba35227022cdb8c]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[d49f06094f81b30c]::util::run_in_thread_with_globals<rustc_interface[d49f06094f81b30c]::util::run_in_thread_pool_with_globals<rustc_interface[d49f06094f81b30c]::interface::run_compiler<(), rustdoc[bc9829b44a9905a9]::main_args::{closure#2}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  25:     0x611ca63df67e - <<std[cba35227022cdb8c]::thread::Builder>::spawn_unchecked_<rustc_interface[d49f06094f81b30c]::util::run_in_thread_with_globals<rustc_interface[d49f06094f81b30c]::util::run_in_thread_pool_with_globals<rustc_interface[d49f06094f81b30c]::interface::run_compiler<(), rustdoc[bc9829b44a9905a9]::main_args::{closure#2}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[3b140760090fa97d]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  26:     0x7d3d48835caf - std::sys::pal::unix::thread::Thread::new::thread_start::ha07e360225fa3528
  27:     0x7d3d42a9caa4 - <unknown>
  28:     0x7d3d42b29c3c - <unknown>
  29:                0x0 - <unknown>

error: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-rustdoc&template=ice.md

note: please make sure that you have updated to the latest nightly

note: please attach the file at `/t/rustc-ice-2025-03-14T20_33_42-48564.txt` to your bug report

note: compiler flags: -Z unstable-options

query stack during panic:
end of query stack

Cc: @GuillaumeGomez
@rustbot label A-rust-for-linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-path-remappingArea: path remapping, --remap-path-prefix, --remap-cwd-prefix, --remap-diagnostics-scope etc.A-rust-for-linuxRelevant for the Rust-for-Linux projectC-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions