rust/compiler/rustc_errors/src
bors 8188f6c808 Auto merge of #149709 - Urgau:overhaul-filenames, r=davidtwco
Overhaul filename handling for cross-compiler consistency

This PR overhauls the way we handle filenames in the compiler and `rmeta` in order to achieve achieve cross-compiler consistency (ie. having the same path no matter if the filename was created in the current compiler session or is coming from `rmeta`).

This is required as some parts of the compiler rely on consistent paths for the soundness of generated code (see rust-lang/rust#148328).

In order to achieved consistency multiple steps are being taken by this PR:
 - by making `RealFileName` immutable
 - by only having `SourceMap::to_real_filename` create `RealFileName`
   - currently `RealFileName` can be created from any `Path` and are remapped afterwards, which creates consistency issue
 - by also making `RealFileName` holds it's working directory, embeddable name and the remapped scopes
   - this removes the need for a `Session`, to know the current(!) scopes and cwd, which is invalid as they may not be equal to the scopes used when creating the filename

In order for `SourceMap::to_real_filename` to know which scopes to apply `FilePathMapping` now takes the current remapping scopes to apply, which makes `FileNameDisplayPreference` and company useless and are removed.

This PR is split-up in multiple commits (unfortunately not atomic), but should help review the changes.

Unblocks https://github.com/rust-lang/rust/pull/147611
Fixes https://github.com/rust-lang/rust/issues/148328
2025-12-13 14:32:09 +00:00
..
json Overhaul filename handling for cross-compiler consistency 2025-12-12 07:33:09 +01:00
markdown chore: Remove unneeded ansi escape resets from output 2025-10-20 12:13:26 -06:00
annotate_snippet_emitter_writer.rs fix: Only show one origin for multiline annotations with no source 2025-11-18 19:26:02 -07:00
codes.rs remove duplicated columns from rustc_error_code::error_codes! 2025-09-27 12:29:54 +02:00
decorate_diag.rs Refactor lint buffering to avoid requiring a giant enum 2025-08-22 01:59:56 -07:00
diagnostic.rs Revert "Auto merge of #146121 - Muscraft:filter-suggestion-parts, r=petrochenkov" 2025-10-23 18:18:35 +00:00
diagnostic_impls.rs Move IntoDiagArg earlier in the dependency chains 2025-08-20 15:01:13 -07:00
emitter.rs Point at span within local macros even when error happens in nested external macro 2025-12-10 19:27:40 +00:00
error.rs Reformat use declarations. 2024-07-29 08:26:52 +10:00
json.rs Overhaul filename handling for cross-compiler consistency 2025-12-12 07:33:09 +01:00
lib.rs Rollup merge of #146584 - cyrgani:error-codes-macro, r=GuillaumeGomez 2025-12-11 22:09:52 +01:00
lock.rs Reformat using the new identifier sorting from rustfmt 2024-09-22 19:11:29 -04:00
registry.rs Reformat use declarations. 2024-07-29 08:26:52 +10:00
snippet.rs Use abs_diff where applicable 2025-03-27 18:29:06 +00:00
styled_buffer.rs use let chains in ast, borrowck, codegen, const_eval 2025-07-28 06:08:48 +05:00
tests.rs Extract Translator struct 2025-06-19 13:02:04 -05:00
timings.rs Add codegen timing section 2025-06-23 08:50:17 +02:00
translation.rs Extract Translator struct 2025-06-19 13:02:04 -05:00