Commit d154728
committed
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 #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 #147611
Fixes #148328File tree
56 files changed
+1088
-885
lines changed- compiler
- rustc_borrowck/src/region_infer
- rustc_builtin_macros/src
- rustc_codegen_cranelift/src/debuginfo
- rustc_codegen_gcc/src
- rustc_codegen_llvm/src
- back
- coverageinfo
- debuginfo
- rustc_const_eval/src/const_eval
- rustc_driver_impl/src
- rustc_errors/src
- json
- rustc_expand/src
- rustc_interface/src
- rustc_metadata/src/rmeta
- rustc_middle/src
- mir
- ty/print
- rustc_monomorphize/src
- rustc_parse/src
- parser
- rustc_passes/src
- rustc_public_bridge/src/context
- rustc_resolve/src/rustdoc
- rustc_session
- src
- rustc_span
- src
- source_map
- src
- librustdoc
- clean
- doctest
- html
- render
- passes
- tools
- clippy
- clippy_lints/src
- clippy_utils/src
- miri/src
- rustfmt/src
- config
- parse
- tests
- run-make
- duplicate-dependency
- remap-path-prefix-consts
- ui/errors
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
56 files changed
+1088
-885
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4632 | 4632 | | |
4633 | 4633 | | |
4634 | 4634 | | |
4635 | | - | |
4636 | 4635 | | |
4637 | 4636 | | |
4638 | 4637 | | |
| |||
4659 | 4658 | | |
4660 | 4659 | | |
4661 | 4660 | | |
| 4661 | + | |
4662 | 4662 | | |
4663 | 4663 | | |
4664 | 4664 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
80 | 80 | | |
81 | 81 | | |
82 | 82 | | |
83 | | - | |
| 83 | + | |
84 | 84 | | |
85 | 85 | | |
86 | 86 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
71 | | - | |
72 | | - | |
| 71 | + | |
73 | 72 | | |
74 | 73 | | |
75 | | - | |
76 | | - | |
77 | | - | |
| 74 | + | |
78 | 75 | | |
79 | 76 | | |
80 | 77 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
| 14 | + | |
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| |||
445 | 445 | | |
446 | 446 | | |
447 | 447 | | |
448 | | - | |
| 448 | + | |
449 | 449 | | |
450 | 450 | | |
451 | 451 | | |
| |||
Lines changed: 5 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
10 | 13 | | |
11 | 14 | | |
12 | 15 | | |
| |||
95 | 98 | | |
96 | 99 | | |
97 | 100 | | |
98 | | - | |
| 101 | + | |
99 | 102 | | |
100 | 103 | | |
101 | 104 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
| 24 | + | |
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
47 | | - | |
48 | 47 | | |
49 | 48 | | |
50 | 49 | | |
| |||
102 | 101 | | |
103 | 102 | | |
104 | 103 | | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | 104 | | |
111 | | - | |
112 | | - | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
113 | 111 | | |
114 | 112 | | |
115 | 113 | | |
116 | | - | |
| 114 | + | |
| 115 | + | |
117 | 116 | | |
118 | 117 | | |
119 | 118 | | |
| |||
137 | 136 | | |
138 | 137 | | |
139 | 138 | | |
140 | | - | |
| 139 | + | |
141 | 140 | | |
142 | 141 | | |
143 | 142 | | |
| |||
180 | 179 | | |
181 | 180 | | |
182 | 181 | | |
183 | | - | |
184 | 182 | | |
185 | 183 | | |
186 | 184 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
297 | 297 | | |
298 | 298 | | |
299 | 299 | | |
300 | | - | |
301 | | - | |
302 | | - | |
303 | | - | |
304 | | - | |
305 | | - | |
306 | | - | |
307 | | - | |
308 | | - | |
309 | | - | |
310 | | - | |
311 | | - | |
312 | | - | |
313 | | - | |
314 | | - | |
315 | | - | |
316 | | - | |
317 | | - | |
318 | | - | |
319 | | - | |
320 | | - | |
321 | | - | |
322 | | - | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
323 | 305 | | |
324 | 306 | | |
325 | 307 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
| 24 | + | |
| 25 | + | |
28 | 26 | | |
29 | 27 | | |
30 | 28 | | |
| |||
248 | 246 | | |
249 | 247 | | |
250 | 248 | | |
| 249 | + | |
251 | 250 | | |
252 | 251 | | |
253 | 252 | | |
| |||
271 | 270 | | |
272 | 271 | | |
273 | 272 | | |
274 | | - | |
275 | | - | |
276 | | - | |
277 | 273 | | |
278 | 274 | | |
279 | 275 | | |
| |||
284 | 280 | | |
285 | 281 | | |
286 | 282 | | |
287 | | - | |
288 | | - | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
289 | 286 | | |
290 | 287 | | |
291 | 288 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
11 | | - | |
12 | | - | |
| 10 | + | |
13 | 11 | | |
14 | 12 | | |
15 | 13 | | |
| |||
127 | 125 | | |
128 | 126 | | |
129 | 127 | | |
130 | | - | |
131 | | - | |
132 | | - | |
133 | | - | |
| 128 | + | |
134 | 129 | | |
135 | 130 | | |
136 | 131 | | |
| |||
145 | 140 | | |
146 | 141 | | |
147 | 142 | | |
148 | | - | |
149 | | - | |
150 | | - | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
151 | 147 | | |
152 | 148 | | |
153 | 149 | | |
| |||
0 commit comments