Commit db7352d
committed
Adjust
`Analysis` has six methods of note:
- `apply_statement_effect`
- `apply_before_statement_effect`
- `apply_terminator_effect`
- `apply_before_terminator_effect`
- `apply_call_return_effect`
- `apply_switch_int_edge_effects`
`GenKillAnalysis` has six similar methods of note:
- `statement_effect`
- `before_statement_effect`
- `terminator_effect`
- `before_terminator_effect`
- `call_return_effect`
- `switch_int_edge_effects`
Every `GenKillAnalysis` also implicitly impls `Analysis`, thanks to
this blanket impl:
```
impl<'tcx, A> Analysis<'tcx> for A
where
A: GenKillAnalysis<'tcx>,
A::Domain: GenKill<A::Idx> + BitSetExt<A::Idx>,
```
which forwards `apply_statement_effect` to `statement_effect`, and so
on.
This is a nice symmetry, but it's misleading. The latter four
`GenKillAnalysis` methods (`terminator_effect`, ...) are only called
from the latter four `Analysis` methods (`apply_terminator_effect`,
...). In reality, to implement a `GenKillAnalysis` you want to implement
the first two `GenKillAnalysis` methods (which take `impl GenKill` args)
and the latter four `Analysis` methods (which can take `Self::Domain`
args).
This commit adjusts things accordingly.
- The latter four methods in `GenKillAnalysis` are removed.
- The blanket impl of `Analysis` for any type implementing
`GenKillAnalysis` is removed.
- Each gen-kill analysis now implements the two `GenKillAnalysis`
methods and the four latter `Analysis` methods.
- Each gen-kill analysis also implicitly implements the first two
`Analysis` methods by using new macros
`fn_apply_before_statement_effect_gen_kill!` and
`fn_apply_statement_effect_gen_kill!` that just define a method that
forwards on to the corresponding `GenKillAnalysis` method.
Overall this is a little less code and I find the whole structure easier
to understand.Analysis/GenKillAnalysis interaction.1 parent 1b35beb commit db7352d
File tree
6 files changed
+123
-154
lines changed- compiler
- rustc_borrowck/src
- rustc_mir_dataflow/src
- framework
- impls
6 files changed
+123
-154
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
14 | | - | |
| 13 | + | |
| 14 | + | |
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| |||
506 | 506 | | |
507 | 507 | | |
508 | 508 | | |
509 | | - | |
| 509 | + | |
510 | 510 | | |
511 | 511 | | |
512 | 512 | | |
| |||
529 | 529 | | |
530 | 530 | | |
531 | 531 | | |
532 | | - | |
| 532 | + | |
533 | 533 | | |
534 | 534 | | |
535 | 535 | | |
| |||
592 | 592 | | |
593 | 593 | | |
594 | 594 | | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
595 | 601 | | |
596 | | - | |
| 602 | + | |
597 | 603 | | |
598 | | - | |
| 604 | + | |
599 | 605 | | |
600 | 606 | | |
601 | 607 | | |
602 | 608 | | |
603 | 609 | | |
604 | 610 | | |
605 | | - | |
| 611 | + | |
606 | 612 | | |
607 | 613 | | |
608 | 614 | | |
| |||
620 | 626 | | |
621 | 627 | | |
622 | 628 | | |
623 | | - | |
| 629 | + | |
624 | 630 | | |
625 | | - | |
| 631 | + | |
626 | 632 | | |
627 | 633 | | |
628 | 634 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
253 | 253 | | |
254 | 254 | | |
255 | 255 | | |
256 | | - | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
257 | 259 | | |
258 | 260 | | |
259 | 261 | | |
| |||
275 | 277 | | |
276 | 278 | | |
277 | 279 | | |
278 | | - | |
279 | | - | |
280 | | - | |
281 | | - | |
282 | | - | |
283 | | - | |
284 | | - | |
285 | | - | |
286 | | - | |
287 | | - | |
288 | | - | |
289 | | - | |
290 | | - | |
291 | | - | |
292 | | - | |
293 | | - | |
294 | | - | |
295 | | - | |
296 | | - | |
297 | | - | |
298 | | - | |
299 | | - | |
300 | | - | |
301 | | - | |
302 | | - | |
303 | | - | |
304 | | - | |
305 | | - | |
306 | | - | |
307 | | - | |
308 | | - | |
309 | | - | |
310 | | - | |
311 | | - | |
312 | | - | |
313 | | - | |
314 | 280 | | |
315 | 281 | | |
316 | | - | |
317 | | - | |
318 | | - | |
319 | | - | |
320 | | - | |
321 | | - | |
322 | | - | |
323 | | - | |
324 | | - | |
325 | | - | |
326 | | - | |
327 | | - | |
328 | | - | |
329 | | - | |
330 | | - | |
331 | | - | |
332 | | - | |
333 | | - | |
334 | | - | |
335 | | - | |
336 | | - | |
337 | | - | |
338 | | - | |
339 | | - | |
340 | | - | |
341 | | - | |
342 | | - | |
343 | | - | |
344 | | - | |
345 | | - | |
346 | | - | |
347 | | - | |
348 | | - | |
349 | | - | |
350 | | - | |
351 | | - | |
352 | | - | |
353 | | - | |
354 | | - | |
355 | | - | |
356 | | - | |
357 | | - | |
358 | | - | |
359 | | - | |
360 | | - | |
361 | | - | |
362 | | - | |
363 | | - | |
364 | | - | |
365 | | - | |
366 | | - | |
367 | | - | |
368 | | - | |
369 | | - | |
370 | | - | |
371 | | - | |
372 | | - | |
373 | | - | |
374 | | - | |
375 | | - | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
376 | 298 | | |
377 | | - | |
378 | | - | |
379 | | - | |
380 | | - | |
381 | | - | |
382 | | - | |
383 | | - | |
384 | | - | |
385 | | - | |
386 | | - | |
387 | | - | |
388 | | - | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
389 | 314 | | |
390 | 315 | | |
391 | 316 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
52 | 56 | | |
53 | | - | |
| 57 | + | |
54 | 58 | | |
55 | 59 | | |
56 | 60 | | |
| |||
60 | 64 | | |
61 | 65 | | |
62 | 66 | | |
63 | | - | |
| 67 | + | |
64 | 68 | | |
65 | | - | |
| 69 | + | |
66 | 70 | | |
67 | 71 | | |
68 | 72 | | |
| |||
0 commit comments