Commit d8dcb63
committed
Auto merge of #67476 - mark-i-m:simplify-borrow_check-5, r=matthewjasper
Region naming refactoring [6/N]
Followup to #67474
EDIT: this PR is probably best read commit-by-commit...
The major changes in this PR include:
- moving many functions around to modules that better suit them. In particular, a lot of methods were moved from `borrow_check::diagnostics::region_errors` to `borrow_check::region_infer`, and `report_region_errors` was moved from `borrow_check` to `borrow_check::diagnostics::region_errors`.
- `borrow_check::diagnostics::{region_errors, region_name}` are now most comprised of methods on `MirBorrowckCtxt` instead of `RegionInferenceContext`, allowing us to get rid of the annoying `pub(in crate::borrow_check)` on most of the fields of the latter, along with a number of method arguments on many methods.
- I renamed `MirBorrowckCtxt.nonlexical_regioncx` to just `regioncx` because their is no lexical lifetimes any more, and the old name was annoyingly verbose, causing many lines to wrap unnecessarily.
- I got rid of `ErrorRegionNamingContext`. Region naming is implemented as inherent methods on `MirBorrowckCtxt`, so we just move the naming stuff into that struct.
The PR is rather large, but the commits are fairly self-contained (though they don't all compile). There was one minor output change to one test with `compare-mode=nll`, which I think is acceptable.
Between this PR and the last one, a net of 200 lines are removed, most of which was function parameters and context structs :tada:
Some samples:
```diff
- self.nonlexical_regioncx.free_region_constraint_info(
- &self.body,
- &self.local_names,
- &self.upvars,
- self.mir_def_id,
- self.infcx,
- borrow_region_vid,
- region,
- );
+ self.free_region_constraint_info(borrow_region_vid, region);
```
```diff
- .or_else(|| {
- self.give_name_if_anonymous_region_appears_in_yield_ty(
- infcx,
- body,
- *mir_def_id,
- fr,
- renctx,
- )
- });
+ .or_else(|| self.give_name_if_anonymous_region_appears_in_arguments(fr))
```
r? @matthewjasper
cc @eddybFile tree
10 files changed
+789
-881
lines changed- src
- librustc_mir/borrow_check
- diagnostics
- region_infer
- test/ui/c-variadic
10 files changed
+789
-881
lines changedLines changed: 26 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
10 | | - | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| |||
254 | 255 | | |
255 | 256 | | |
256 | 257 | | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
257 | 275 | | |
258 | 276 | | |
259 | 277 | | |
| |||
278 | 296 | | |
279 | 297 | | |
280 | 298 | | |
281 | | - | |
| 299 | + | |
282 | 300 | | |
283 | 301 | | |
284 | 302 | | |
285 | 303 | | |
286 | 304 | | |
287 | 305 | | |
288 | | - | |
| 306 | + | |
289 | 307 | | |
290 | 308 | | |
291 | 309 | | |
| |||
329 | 347 | | |
330 | 348 | | |
331 | 349 | | |
332 | | - | |
333 | | - | |
334 | | - | |
335 | | - | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
336 | 353 | | |
337 | 354 | | |
338 | 355 | | |
| |||
345 | 362 | | |
346 | 363 | | |
347 | 364 | | |
348 | | - | |
| 365 | + | |
349 | 366 | | |
350 | 367 | | |
351 | 368 | | |
352 | 369 | | |
353 | 370 | | |
354 | 371 | | |
355 | | - | |
| 372 | + | |
356 | 373 | | |
357 | 374 | | |
358 | 375 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
35 | | - | |
| 35 | + | |
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| |||
Lines changed: 8 additions & 19 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| |||
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
80 | | - | |
81 | 80 | | |
82 | 81 | | |
83 | | - | |
84 | | - | |
85 | | - | |
| 82 | + | |
86 | 83 | | |
87 | 84 | | |
88 | 85 | | |
89 | 86 | | |
90 | 87 | | |
91 | 88 | | |
92 | | - | |
93 | 89 | | |
94 | 90 | | |
95 | 91 | | |
| |||
98 | 94 | | |
99 | 95 | | |
100 | 96 | | |
101 | | - | |
| 97 | + | |
102 | 98 | | |
103 | 99 | | |
104 | 100 | | |
| |||
107 | 103 | | |
108 | 104 | | |
109 | 105 | | |
110 | | - | |
111 | | - | |
112 | | - | |
| 106 | + | |
113 | 107 | | |
114 | 108 | | |
115 | 109 | | |
| |||
173 | 167 | | |
174 | 168 | | |
175 | 169 | | |
176 | | - | |
177 | 170 | | |
178 | 171 | | |
179 | 172 | | |
180 | | - | |
181 | | - | |
| 173 | + | |
| 174 | + | |
182 | 175 | | |
183 | 176 | | |
184 | 177 | | |
| |||
194 | 187 | | |
195 | 188 | | |
196 | 189 | | |
197 | | - | |
198 | | - | |
199 | | - | |
200 | | - | |
201 | | - | |
| 190 | + | |
202 | 191 | | |
203 | 192 | | |
204 | 193 | | |
| |||
215 | 204 | | |
216 | 205 | | |
217 | 206 | | |
218 | | - | |
| 207 | + | |
219 | 208 | | |
220 | 209 | | |
221 | 210 | | |
| |||
0 commit comments