{"record":{"id":"fc5b4871d3da5807","repo":"rust-lang/rust","slug":"missing-source-file","errorCode":null,"errorMessage":"missing source file","messagePattern":"missing source file","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"compiler/rustc_metadata/src/rmeta/decoder.rs","lineNumber":1811,"sourceCode":"                        *name =\n                            rustc_span::FileName::Real(rustc_span::RealFileName::from_virtual_path(\n                                &virtual_dir.join(subdir).join(rest),\n                            ))\n                    }\n                }\n            };\n\n        let mut import_info = self.source_map_import_info.lock();\n        for _ in import_info.len()..=(source_file_index as usize) {\n            import_info.push(None);\n        }\n        import_info[source_file_index as usize]\n            .get_or_insert_with(|| {\n                let source_file_to_import = self\n                    .root\n                    .source_map\n                    .get(self, source_file_index)\n                    .expect(\"missing source file\")\n                    .decode((self, tcx));\n\n                // We can't reuse an existing SourceFile, so allocate a new one\n                // containing the information we need.\n                let original_end_pos = source_file_to_import.end_position();\n                let rustc_span::SourceFile {\n                    mut name,\n                    src_hash,\n                    checksum_hash,\n                    start_pos: original_start_pos,\n                    normalized_source_len,\n                    unnormalized_source_len,\n                    lines,\n                    multibyte_chars,\n                    normalized_pos,\n                    stable_id,\n                    ..\n                } = source_file_to_import;","sourceCodeStart":1793,"sourceCodeEnd":1829,"githubUrl":"https://github.com/rust-lang/rust/blob/7088e4b63a9516ebfbfe2ab2d999cf01a528ac14/compiler/rustc_metadata/src/rmeta/decoder.rs#L1793-L1829","documentation":"Fires during source-map import in the decoder (decoder.rs:1811). When a `Span` references a source file by index, the decoder lazily imports it from `root.source_map`; `.expect(\"missing source file\")` panics when the index is absent from the serialized source-map table. The span's `metadata_index` points past the end of the encoded file list.","triggerScenarios":"A span carrying a `metadata_index` that exceeds the encoded `source_map` array (index/count mismatch between span encoding and source-map encoding); reading proc-macro metadata where source files were not serialized but a span still references them.","commonSituations":"Remapping/debuginfo options changed between builds while reusing `target/`; proc-macro crate decoded with mismatched `-Z simulate-remapped-rust-src-base` settings; rmeta from a different rustc whose source-map layout differs.","solutions":["`cargo clean` to rebuild the source-map table consistently with the current spans.","Ensure debuginfo/remap flags (`--remap-path-prefix`, `-Z simulate-remapped-rust-src-base`) are identical across the build graph.","For proc-macro crates, rebuild them with the active compiler so their source-map indices line up.","Clean-build ICE -> report a span/source-map index mismatch."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"# Keep debuginfo/remap flags identical across the graph so span<->source-map\n# indices stay consistent.\nexport RUSTFLAGS=\"--remap-path-prefix=$PWD/=\"   # identical for every crate\nexport RUSTDOCFLAGS=\"$RUSTFLAGS\"\ncargo clean && cargo build","typeGuard":null,"tryCatchPattern":"cargo build || { cargo clean && cargo build; }","preventionTips":["Use identical `--remap-path-prefix` and debuginfo flags for every crate in the graph.","Rebuild proc-macro crates with the active compiler so their source-map indices line up.","`cargo clean` after changing remap/debuginfo settings."],"tags":["metadata","rmeta","decoder","source-map","debuginfo","ice"],"backgroundTag":null,"analyzedSha":"7088e4b63a9516ebfbfe2ab2d999cf01a528ac14","analyzedAt":"2026-08-10T14:17:03.603Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}