-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Better debug logs for borrowck constraint graph #104239
Conversation
r? @jackh726 (rustbot has picked a reviewer for you, use r? to override) |
This comment has been minimized.
This comment has been minimized.
This adds a huge amount of fn with_reg_var_to_origin(&self, f: impl FnOnce(RefCell<FxHashMap<ty::RegionVid, RegionCtxt>>)) that calls the closure when |
Something like this would have the downside of passing in unused arguments (the |
☔ The latest upstream changes (presumably #104293) made this pull request unmergeable. Please resolve the merge conflicts. |
Can we try to add this without all the |
@jackh726 Sorry, didn't immediately have time when I saw your reply and then forgot that you posted. |
☔ The latest upstream changes (presumably #105036) made this pull request unmergeable. Please resolve the merge conflicts. |
Agh sorry for the delay. Can you rebase and remove the cargo.lock changes? |
8dc0366
to
570ad62
Compare
This comment was marked as off-topic.
This comment was marked as off-topic.
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
Agh |
@bors try |
Okay good. Can we do one more with the cfgs removed? |
0e917b4
to
c9843d6
Compare
Forgot that I also should be able to request a perf run, let's see: @bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
⌛ Trying commit c9843d6 with merge e02ff57926ffbe7e5ed3694d530b665c6917be1d... |
☀️ Try build successful - checks-actions |
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (e02ff57926ffbe7e5ed3694d530b665c6917be1d): comparison URL. Overall result: ❌ regressions - no action neededBenchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR may lead to changes in compiler perf. @bors rollup=never Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
Max RSS (memory usage)This benchmark run did not return any relevant results for this metric. CyclesResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
|
Okay, unless there's anything else you think you want to try, I think we land this as-is. How's that sound @b-naber? |
@jackh726 Don't have anything else to try. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a couple nits. r=me with or without them
scc_indices: IndexVec<N, S>, | ||
pub scc_indices: IndexVec<N, S>, | ||
|
||
/// Data about each SCC. | ||
scc_data: SccData<S>, | ||
pub scc_data: SccData<S>, | ||
} | ||
|
||
struct SccData<S: Idx> { | ||
pub struct SccData<S: Idx> { | ||
/// For each SCC, the range of `all_successors` where its | ||
/// successors can be found. | ||
ranges: IndexVec<S, Range<usize>>, | ||
pub ranges: IndexVec<S, Range<usize>>, | ||
|
||
/// Contains the successors for all the Sccs, concatenated. The | ||
/// range of indices corresponding to a given SCC is found in its | ||
/// SccData. | ||
all_successors: Vec<S>, | ||
pub all_successors: Vec<S>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I kind of think these should stay private, with public functions that return immutable access?
compiler/rustc_middle/src/ty/sty.rs
Outdated
pub fn is_var(self) -> bool { | ||
matches!(self.kind(), ty::ReVar(_)) | ||
} | ||
|
||
pub fn try_get_var(self) -> Option<RegionVid> { | ||
match self.kind() { | ||
ty::ReVar(vid) => Some(vid), | ||
_ => None, | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just a nit, but I kind of like as_var
or just var
more.
Also, in theory, is_var
is redundant now, because you can just do l.as_var().is_some()
{ | ||
infcx.tcx.fold_regions(value, |_region, _depth| { | ||
let origin = NllRegionVariableOrigin::Existential { from_forall: false }; | ||
infcx.next_nll_region_var(origin) | ||
infcx.next_nll_region_var(origin, || get_ctxt_fn()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can just pass get_ctxt_fn
right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, get_ctxt_fn
is captured in fold_regions
which is FnMut
, so we can't move there.
@bors r=jackh726 rollup |
…iaskrgr Rollup of 7 pull requests Successful merges: - rust-lang#104239 (Better debug logs for borrowck constraint graph) - rust-lang#108202 (Make sure `test_type_match` doesn't ICE with late-bound types) - rust-lang#108295 (Use DefKind to give more item kind information during BindingObligation note ) - rust-lang#108306 (compiletest: up deps) - rust-lang#108313 (Fix compiletest possible crash in option only-modified) - rust-lang#108322 (Clean ConstProp) - rust-lang#108323 (hir-analysis: make one diagnostic translatable) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
There's a bad pattern matching confusion present in this function. `_anon` gets assigned to, and then `_anon` is used as an unbound variable in the pattern, which is unrelated to the first `_anon`. If the `_anon` didn't start with `_` the compiler would give warnings. This was introduced in rust-lang#104239. I have rewritten the function to remove the confusion and preserve the existing behaviour. This seems safest, because the original intent is not clear.
It's really cumbersome to work with
RegionVar
s when trying to debug borrowck code or when trying to understand how the borrowchecker works. This PR collects some region information (behindcfg(debug_assertions)
) for createdRegionVar
s (NLL region vars, this PR doesn't touch canonicalization) and prints the nodes and edges of the strongly connected constraints graph using representatives that use that region information (either lifetime names, locations in MIR or spans).