rust/compiler/rustc_mir_dataflow/src
Nicholas Nethercote 5ce3797073 Introduce MirDumper and MirWriter.
MIR dumping is a mess. There are lots of functions and entry points,
e.g. `dump_mir`, `dump_mir_with_options`, `dump_polonius_mir`,
`dump_mir_to_writer`. Also, it's crucial that `create_dump_file` is
never called without `dump_enabled` first being checked, but there is no
mechanism for ensuring this and it's hard to tell if it is satisfied on
all paths. (`dump_enabled` is checked twice on some paths, however!)

This commit introduces `MirWriter`, which controls the MIR writing, and
encapsulates the `extra_data` closure and `options`. Two existing
functions are now methods of this type. It sets reasonable defaults,
allowing the removal of many `|_, _| Ok(())` closures.

The commit also introduces `MirDumper`, which is layered on top of
`MirWriter`, and which manages the creation of the dump files,
encapsulating pass names, disambiguators, etc. Four existing functions
are now methods of this type.
- `MirDumper::new` will only succeed if dumps are enabled, and will
  return `None` otherwise, which makes it impossible to dump when you
  shouldn't.
- It also sets reasonable defaults for various things like
  disambiguators, which means you no longer need to specify them in many
  cases. When they do need to be specified, it's now done via setter
  methods.
- It avoids some repetition. E.g. `dump_nll_mir` previously specifed the
  pass name `"nll"` four times and the disambiguator `&0` three times;
  now it specifies them just once, to put them in the `MirDumper`.
- For Polonius, the `extra_data` closure can now be specified earlier,
  which avoids having to pass some arguments through some functions.
2025-09-01 09:19:03 +10:00
..
framework Introduce MirDumper and MirWriter. 2025-09-01 09:19:03 +10:00
impls Rollup merge of #144478 - joshtriplett:doc-code-formatting-prep, r=Amanieu 2025-08-02 11:24:24 +02:00
move_paths Correct comments. 2025-08-21 23:59:20 +00:00
debuginfo.rs rename BitSet to DenseBitSet 2025-01-11 11:34:01 +00:00
drop_flag_effects.rs use let chains in hir, lint, mir 2025-07-28 06:10:14 +05:00
errors.rs Migrate all diagnostics 2022-10-23 10:09:44 +02:00
lib.rs update cfg(bootstrap) 2025-05-12 15:33:37 +02:00
points.rs Separate Analysis and Results. 2025-04-24 11:36:07 +10:00
rustc_peek.rs Eliminate unnecessary dependency from rustc_mir_dataflow to rustc_hir 2025-08-20 15:04:00 -07:00
un_derefer.rs Greatly simplify lifetime captures in edition 2024 2025-02-22 22:24:52 +00:00
value_analysis.rs use let chains in hir, lint, mir 2025-07-28 06:10:14 +05:00