rust/compiler/rustc_mir_dataflow
Nicholas Nethercote be7c6a3b43 Make it possible for ResultsCursor to borrow a Results.
`ResultsCursor` currently owns its `Results`. But sometimes the
`Results` is needed again afterwards. So there is
`ResultsCursor::into_results` for extracting the `Results`, which leads
to some awkwardness.

This commit adds `ResultsHandle`, a `Cow`-like type that can either
borrow or own a a `Results`. `ResultsCursor` now uses it. This is good
because some `ResultsCursor`s really want to own their `Results`, while
others just want to borrow it.

We end with with a few more lines of code, but get some nice cleanups.
- `ResultsCursor::into_results` and `Formatter::into_results` are
  removed.
- `write_graphviz_results` now just borrows a `Results`, instead of the
  awkward "take ownership of a `Results` and then return it unchanged"
  pattern.

This reinstates the cursor flexibility that was lost in #118230 -- which
removed the old `ResultsRefCursor` and `ResultsCloneCursor` types -- but
in a much simpler way. Hooray!
2024-11-26 11:23:40 +11:00
..
src Make it possible for ResultsCursor to borrow a Results. 2024-11-26 11:23:40 +11:00
Cargo.toml compiler: Remove unused rustc_target from Cargo.tomls 2024-11-03 13:38:47 -08:00
messages.ftl Ensure Fluent messages are in alphabetical order 2023-05-25 23:49:35 +00:00