-
Notifications
You must be signed in to change notification settings - Fork 13.7k
change HIR typeck region uniquification handling approach #145706
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
Conversation
Some changes occurred to the core trait solver cc @rust-lang/initiative-trait-system-refactor |
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
change HIR typeck unification handling approach
@@ -94,6 +97,8 @@ where | |||
let errors = ocx.select_all_or_error(); | |||
if errors.is_empty() { | |||
Ok(value) | |||
} else if let Err(guar) = infcx.tcx.check_potentially_region_dependent_goals(root_def_id) { | |||
Err(guar) |
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.
this is the relevant change.
We store potentially region dependent goals in the TypeckResults
and then reprove them in case MIR type check failed to prove something
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (792614a): comparison URL. Overall result: ✅ improvements - no action neededBenchmarking 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 Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)Results (primary 3.2%, secondary 3.1%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (secondary 2.1%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 469.9s -> 472.215s (0.49%) |
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.
the code generally seems reasonable to me. I want to think more about whether this is what we actually want to do big picture wise though
@@ -23,6 +24,7 @@ use crate::universal_regions::UniversalRegions; | |||
#[instrument(skip(infcx, constraints, op), level = "trace")] | |||
pub(crate) fn fully_perform_op_raw<'tcx, R: fmt::Debug, Op>( | |||
infcx: &BorrowckInferCtxt<'tcx>, | |||
root_def_id: LocalDefId, |
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.
Do we need to thread root_def_id
everywhere? Could we use tcx.typeck_root_def_id(body.source.def_id())
where we use it?
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.
yes, that feels like it would slightly worsen perf though/just feels weird given that we've already got that value anyways 🤔 we use fully_perform_op_raw
frequently. I personally don't mind passing this additional arg everywhere, so I would keep it as is for now
This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
@bors r+ rollup=never I don't feel too strongly about the root_def_id thing, we can always change it after the fact |
@bors p=1 putting ahead of |
☀️ Test successful - checks-actions |
What is this?This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.Comparing c5a6a7b (parent) -> 69b76df (this PR) Test differencesShow 94 test diffs94 doctest diffs were found. These are ignored, as they are noisy. Test dashboardRun cargo run --manifest-path src/ci/citool/Cargo.toml -- \
test-dashboard 69b76df90c7ea63b5350d1865f92902a0b27c9a2 --output-dir test-dashboard And then open Job duration changes
How to interpret the job duration changes?Job durations can vary a lot, based on the actual runner instance |
Finished benchmarking commit (69b76df): comparison URL. Overall result: ✅ improvements - no action needed@rustbot label: -perf-regression Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)Results (secondary 2.2%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (secondary 3.9%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 467.196s -> 466.542s (-0.14%) |
#144405 causes structural lookup of opaque types to not work during HIR typeck, so instead avoid uniquifying goals and instead only reprove them if MIR borrowck actually encounters an error.
This doesn't perfectly maintain the property that HIR typeck succeeding implies that MIR typeck succeeds, instead weakening this check to only guarantee that HIR typeck implies that MIR typeck succeeds modulo region uniquification. This means we still get the actually desirable ICEs if we MIR building is broken or we forget to check some property in HIR typeck, without having to deal with the fallout of uniquification in HIR typeck itself.
We report errors using the original obligation sources of HIR typeck so diagnostics aren't that negatively impacted either.
Here's the history of region uniquification while working on the new trait solver:
r? @BoxyUwU