Skip to content

Elaborate on dataflow outputs for region constraints - #1969

Merged
tshepang merged 6 commits into
rust-lang:mainfrom
amandasystems:master
Aug 18, 2026
Merged

Elaborate on dataflow outputs for region constraints#1969
tshepang merged 6 commits into
rust-lang:mainfrom
amandasystems:master

Conversation

@amandasystems

Copy link
Copy Markdown
Contributor

No description provided.

@amandasystems

Copy link
Copy Markdown
Contributor Author

I see Zed snuck in some Markdown normalisation too while it was at it. Sorry about that, let me know if that's inexcusable and I will revert those changes.

@lqd

lqd commented May 1, 2024

Copy link
Copy Markdown
Member

I will revert those changes

Please do yes, if it's not too hard. It will make review easier.

I'll take a closer look when I have more time, but I noted a couple of things:

  • "With -Z dump-mir-graphviz=yes, you will also get Graphviz files for the outlives constraints" is that the case? Did you maybe mean -Zdump-mir=nll?
  • I don't think these visualizations are from MIR dataflow, so the new paragraph may need to be moved to somewhere more related to borrowck

@amandasystems

Copy link
Copy Markdown
Contributor Author

Please do yes, if it's not too hard. It will make review easier.

Done!

"With -Z dump-mir-graphviz=yes, you will also get Graphviz files for the outlives constraints" is that the case? Did you maybe mean -Zdump-mir=nll?

Huh! Apparently, -Z dump-mir=fn is enough to get those. I assumed it wouldn't drop graphviz files without the Graphviz option, but apparently it does! dump-mir=nll also works and now I'm worried it will dump different graphs.

I don't think these visualizations are from MIR dataflow, so the new paragraph may need to be moved to somewhere more related to borrowck

That's probably true; this should be in the borrowck chapter, maybe? Do you have a suggestion off the top of your head or should I go digging?

@lqd

lqd commented May 2, 2024

Copy link
Copy Markdown
Member

Not from the top of my head but I will look for one -- but yeah I agree this should be in the borrowck chapter most likely.

@lqd lqd left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Sorry for taking so long to get back to this.)

So since these are not dataflow outputs, I agree we should add it to the borrow_check chapter.

To do so, I think we should add a dedicated borrow_check/debugging.md page, and have the "Region constraint graphs and their SCCs" section there. We would mention that these come from -Zdump-mir=nll -- and that will give us the occasion to also describe the NLL dumps there in the future.

We can link to that page from the bottom of src/borrow_check.md instead of src/compiler-debugging.md (but we can leave the unflatten paragraph there, it's a good addition next to the graphviz section).

Comment thread src/mir/dataflow.md Outdated
Comment thread src/mir/dataflow.md Outdated
Comment thread src/mir/dataflow.md Outdated
Comment thread src/compiler-debugging.md Outdated
Comment thread src/borrow-check/debugging.md Outdated

## See also

The [general instructions on debugging dataflow]() also apply to graphs generated from

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The [general instructions on debugging dataflow]() also apply to graphs generated from
The [general instructions on debugging dataflow](../mir/dataflow.md) also apply to graphs generated from

Comment thread src/borrow-check/debugging.md Outdated
![A graph showing a small number of strongly connected components on the region-outlives-graph above](../img/scc-graphviz.png)

**Note:** There are implicit edges from `'static` to every region, but those are not rendered
in the region graph to avoid clutter. They _do_ however show up in the SCC graph. This is why there are outgoing edges from `SCC(5)` in the SCC graph that do not seem to have corresponding edges in the region outlives graph above.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line will need to be wrapped as well.

Comment thread src/compiler-debugging.md Outdated
Comment on lines +256 to +257
This is particularly useful for complicated region outlives graphs from
[MIR Dataflow](mir/dataflow.md).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
This is particularly useful for complicated region outlives graphs from
[MIR Dataflow](mir/dataflow.md).
This is particularly useful for complicated region outlives graphs from
[the borrow checker](borrow_check/debugging.md).

@jieyouxu jieyouxu added the S-waiting-on-author Status: this PR is waiting for additional action by the OP label Oct 8, 2024
@jieyouxu

jieyouxu commented Nov 2, 2024

Copy link
Copy Markdown
Member

@lqd btw, you can also edit @amandasystems's branch directly for trivial things like fixing links. We can also try to get this merged so it doesn't drown from merge conflicts. And it's perfectly fine if it still has inaccuracies/omissions, we can always follow-up, it's just docs after all!

@jieyouxu jieyouxu added T-compiler Relevant to the compiler team A-dataflow Area: dataflow analysis A-borrow-checker Area: borrow checker A-regions Area: regions labels Nov 4, 2024
@Kobzol

Kobzol commented Jan 5, 2025

Copy link
Copy Markdown
Member

Sorry, due to me messing up a git operation, we sadly had to force-push the whole commit history of rustc-dev-guide :( If you'd like to update this pull request, you will have to rebase it in a special way onto the new commit history (the new master):

git fetch origin --all
git checkout <pr-branch>
git rebase --onto origin/master origin/master-old
git push --force-with-lease

More context can be found here.

@rustbot

This comment has been minimized.

@jyn514

jyn514 commented Aug 17, 2026

Copy link
Copy Markdown
Member

@lqd @amandasystems what's the state of this PR? if I rebased it onto main for you, do you think it makes sense to merge it as-is? if not, would you have sometime to work on it in the next few weeks?

@amandasystems

Copy link
Copy Markdown
Contributor Author

@lqd @amandasystems what's the state of this PR? if I rebased it onto main for you, do you think it makes sense to merge it as-is? if not, would you have sometime to work on it in the next few weeks?

I looked at what the rebase process would look like and balked a bit. I don't remember what I wrote anymore, but given lqd's minor comments it sounds like it was more or less mergeable.

amandasystems and others added 5 commits August 17, 2026 16:12
Add a hint about unflatten and an internal link to MIR outlives graphs to advertise them better.
Co-authored-by: Rémy Rakic <remy.rakic+github@gmail.com>
Co-authored-by: Rémy Rakic <remy.rakic+github@gmail.com>
@amandasystems

Copy link
Copy Markdown
Contributor Author

Ok I tried the rebase and it seems mergeable. I'll fix @lqd's nits!

@amandasystems
amandasystems force-pushed the master branch 4 times, most recently from f486696 to d54d8e7 Compare August 17, 2026 14:27
@amandasystems

Copy link
Copy Markdown
Contributor Author

Ok I should have fixed the nits too now.

@tshepang
tshepang merged commit bfb40cc into rust-lang:main Aug 18, 2026
1 check passed
@jyn514

jyn514 commented Aug 18, 2026

Copy link
Copy Markdown
Member

thank you for your work on this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-borrow-checker Area: borrow checker A-dataflow Area: dataflow analysis A-regions Area: regions S-waiting-on-author Status: this PR is waiting for additional action by the OP T-compiler Relevant to the compiler team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants