Skip to content

Add annotations to the graphviz region graph on region origins #144988

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 9, 2025

Conversation

amandasystems
Copy link
Contributor

@amandasystems amandasystems commented Aug 6, 2025

This adds

  • (ex<'e>) for regions whose origin is existential, with name if one exists,
  • (for<'p>) for regions whose origin is a placeholder, with name if one exists

For any region whose name we don't know, use '_.

This has helped my debugging and it doesn't create too bad clutter, I feel.

The change iswas ridiculously small, but I turned it into a separate PR so we can bikeshed the format.

The following snippet:

struct Co<'a>(&'a ());
struct Contra<'a>(fn(&'a ()));

// `exists<'e> forall<'p> 'p: 'e` -> ERROR
fn p_outlives_e(
    x: for<'e> fn(for<'p> fn(fn(fn(Contra<'e>, Co<'p>)))),
) -> fn(fn(fn(for<'unify> fn(Contra<'unify>, Co<'unify>)))) {
    x

Gives this graph:
new-naming

This adds
- (ex) for regions whose origin is existential,
- (p) for regoins whose origin is a placeholder, and
- (p for <name>) if the originating placeholder is named.

This has helped _my_ debugging and it doesn't create too bad clutter, I feel.

The change is ridiculously small, but I turned it into a separate PR so we can bikeshed the format.
@rustbot
Copy link
Collaborator

rustbot commented Aug 6, 2025

r? @matthewjasper

rustbot has assigned @matthewjasper.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Aug 6, 2025
@lcnr
Copy link
Contributor

lcnr commented Aug 6, 2025

👍 on adding this to the graph in some form

maybe even

(for<'p>) (and for<'_>) [and (ex<'e>)], feel like it's not that much clutter (and I don#t have to lookup what p means :3 it's also helpful to know the name of existential hr regions 🤔 I guess we currently don't track the bound region for existential hr regions... I feel like we should :3

@lcnr
Copy link
Contributor

lcnr commented Aug 6, 2025

I guess I don't know whether using for<T> for both universals in general and for instantiated universals (i.e. either assumed existential quantification or to prove universal quantification) is more confusing than not. It feels fairly natural for me, but I am a bad person to ask here :>

@amandasystems
Copy link
Contributor Author

Nice, just the discussion I wanted to have!

@amandasystems
Copy link
Contributor Author

👍 on adding this to the graph in some form

maybe even

(for<'p>) (and for<'_>) [and (ex<'e>)], feel like it's not that much clutter (and I don#t have to lookup what p means :3 it's also helpful to know the name of existential hr regions 🤔

Yeah, not having to look up what sigils means is... a good idea. I'll make that change!

@amandasystems
Copy link
Contributor Author

...and now the names for existentials are in there too, if we have them!

@lcnr
Copy link
Contributor

lcnr commented Aug 7, 2025

@bors2 try @rust-timer queue

@rust-timer

This comment has been minimized.

rust-bors bot added a commit that referenced this pull request Aug 7, 2025
…try>

Add annotations to the graphviz region graph on region origins
@rust-bors
Copy link

rust-bors bot commented Aug 7, 2025

⌛ Trying commit 648e3fc with merge ad601d7

To cancel the try build, run the command @bors try cancel.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Aug 7, 2025
@rust-bors
Copy link

rust-bors bot commented Aug 7, 2025

☀️ Try build successful (CI)
Build commit: ad601d7 (ad601d7b50bab72680f28b6b4d8830c0c0a5fece, parent: 61cb1e97fcf954c37d0a457a8084ed9ad8b3cb82)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (ad601d7): comparison URL.

Overall result: ❌ regressions - no action needed

Benchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf.

@bors rollup=never
@rustbot label: -S-waiting-on-perf -perf-regression

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
0.5% [0.5%, 0.5%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Max RSS (memory usage)

Results (primary 3.9%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
3.9% [3.9%, 3.9%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 3.9% [3.9%, 3.9%] 1

Cycles

This benchmark run did not return any relevant results for this metric.

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 464.27s -> 466.698s (0.52%)
Artifact size: 377.42 MiB -> 377.41 MiB (-0.00%)

@lcnr
Copy link
Contributor

lcnr commented Aug 8, 2025

fun fact, entirely ignoring from_forall does not change anything, see #145091

@bors r+

@bors
Copy link
Collaborator

bors commented Aug 8, 2025

📌 Commit 648e3fc has been approved by lcnr

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 8, 2025
@lcnr
Copy link
Contributor

lcnr commented Aug 8, 2025

@bors rollup

the only perf change looks spurious to me

bors added a commit that referenced this pull request Aug 9, 2025
Rollup of 23 pull requests

Successful merges:

 - #141658 (rustdoc search: prefer stable items in search results)
 - #141828 (Add diagnostic explaining STATUS_STACK_BUFFER_OVERRUN not only being used for stack buffer overruns if link.exe exits with that exit code)
 - #144823 (coverage: Extract HIR-related helper code out of the main module)
 - #144883 (Remove unneeded `drop_in_place` calls)
 - #144923 (Move several more float tests to floats/mod.rs)
 - #144988 (Add annotations to the graphviz region graph on region origins)
 - #145010 (Couple of minor abi handling cleanups)
 - #145017 (Explicitly disable vector feature on s390x baseline of bad-reg test)
 - #145027 (Optimize `char::is_alphanumeric`)
 - #145050 (add member constraints tests)
 - #145073 (update enzyme submodule to handle llvm 21)
 - #145080 (Escape diff strings in MIR dataflow graphviz)
 - #145082 (Fix some bad formatting in `-Zmacro-stats` output.)
 - #145083 (Fix cross-compilation of Cargo)
 - #145096 (Fix wasm target build with atomics feature)
 - #145097 (remove unnecessary `TypeFoldable` impls)
 - #145100 (Rank doc aliases lower than equivalently matched items)
 - #145103 (rustc_metadata: remove unused private trait impls)
 - #145115 (defer opaque type errors, generally greatly reduce tainting)
 - #145119 (rustc_public: fix missing parenthesis in pretty discriminant)
 - #145124 (Recover `for PAT = EXPR {}`)
 - #145132 (Refactor map_unit_fn lint)
 - #145134 (Reduce indirect assoc parent queries)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit that referenced this pull request Aug 9, 2025
Rollup of 23 pull requests

Successful merges:

 - #141658 (rustdoc search: prefer stable items in search results)
 - #141828 (Add diagnostic explaining STATUS_STACK_BUFFER_OVERRUN not only being used for stack buffer overruns if link.exe exits with that exit code)
 - #144823 (coverage: Extract HIR-related helper code out of the main module)
 - #144883 (Remove unneeded `drop_in_place` calls)
 - #144923 (Move several more float tests to floats/mod.rs)
 - #144988 (Add annotations to the graphviz region graph on region origins)
 - #145010 (Couple of minor abi handling cleanups)
 - #145017 (Explicitly disable vector feature on s390x baseline of bad-reg test)
 - #145027 (Optimize `char::is_alphanumeric`)
 - #145050 (add member constraints tests)
 - #145073 (update enzyme submodule to handle llvm 21)
 - #145080 (Escape diff strings in MIR dataflow graphviz)
 - #145082 (Fix some bad formatting in `-Zmacro-stats` output.)
 - #145083 (Fix cross-compilation of Cargo)
 - #145096 (Fix wasm target build with atomics feature)
 - #145097 (remove unnecessary `TypeFoldable` impls)
 - #145100 (Rank doc aliases lower than equivalently matched items)
 - #145103 (rustc_metadata: remove unused private trait impls)
 - #145115 (defer opaque type errors, generally greatly reduce tainting)
 - #145119 (rustc_public: fix missing parenthesis in pretty discriminant)
 - #145124 (Recover `for PAT = EXPR {}`)
 - #145132 (Refactor map_unit_fn lint)
 - #145134 (Reduce indirect assoc parent queries)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 35f2fb9 into rust-lang:master Aug 9, 2025
11 checks passed
@rustbot rustbot added this to the 1.91.0 milestone Aug 9, 2025
rust-timer added a commit that referenced this pull request Aug 9, 2025
Rollup merge of #144988 - amandasystems:more-detailed-region-graph, r=lcnr

Add annotations to the graphviz region graph on region origins

This adds
- `(ex<'e>)` for regions whose origin is existential, with name if one exists,
- `(for<'p>)` for regions whose origin is a placeholder, with name if one exists

For any region whose name we don't know, use `'_`.

This has helped _my_ debugging and it doesn't create too bad clutter, I feel.

The change  ~~is~~was ridiculously small, but I turned it into a separate PR so we can bikeshed the format.

The following snippet:
```rust
struct Co<'a>(&'a ());
struct Contra<'a>(fn(&'a ()));

// `exists<'e> forall<'p> 'p: 'e` -> ERROR
fn p_outlives_e(
    x: for<'e> fn(for<'p> fn(fn(fn(Contra<'e>, Co<'p>)))),
) -> fn(fn(fn(for<'unify> fn(Contra<'unify>, Co<'unify>)))) {
    x
```

Gives this graph:
![new-naming](https://github.com/user-attachments/assets/f2c8f17c-d29b-4d42-9da7-4b8e520e76a6)
@jieyouxu
Copy link
Member

jieyouxu commented Aug 9, 2025

Hi bors this already merged
@bors r-

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Aug 9, 2025
@jieyouxu
Copy link
Member

jieyouxu commented Aug 9, 2025

@rustbot label: -S-waiting-on-author +S-waiting-on-bors +merged-by-bors

@rustbot rustbot added merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Aug 9, 2025
@amandasystems amandasystems deleted the more-detailed-region-graph branch August 9, 2025 15:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants