Skip to content
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

Use a Field in ConstraintCategory::ClosureUpvar #94006

Merged
merged 1 commit into from
Feb 19, 2022

Conversation

pierwill
Copy link
Member

@pierwill pierwill commented Feb 14, 2022

As part of #90317, we do not want HirId to implement Ord, PartialOrd. This line of code has made that difficult

https://github.com/rust-lang/rust/blob/1b27144afc77031ba9c05d86c06c64485589775a/compiler/rustc_borrowck/src/region_infer/mod.rs#L2184

since it sorts a ConstraintCategory::ClosureUpvar(HirId).

This PR makes that variant take a Field instead.

r? @nikomatsakis

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Feb 14, 2022
@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Feb 14, 2022
@rust-log-analyzer

This comment has been minimized.

@pierwill

This comment was marked as off-topic.

@rust-log-analyzer

This comment has been minimized.

@pierwill

This comment was marked as outdated.

@pierwill
Copy link
Member Author

UI tests passing locally! 🎉

@@ -421,17 +421,26 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {

diag.span_label(*span, message);

// FIXME(project-rfc-2229#48): This should store a captured_place not a hir id
Copy link
Member Author

Choose a reason for hiding this comment

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

Should we keep this comment?

Copy link
Contributor

Choose a reason for hiding this comment

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

no, I think it is addressed by using the field actually

@@ -2530,9 +2530,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
body,
);
let category = if let Some(field) = field {
let var_hir_id = self.borrowck_context.upvars[field.index()].place.get_root_variable();
// FIXME(project-rfc-2229#8): Use Place for better diagnostics
Copy link
Member Author

Choose a reason for hiding this comment

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

Should we keep this comment?

Copy link
Contributor

Choose a reason for hiding this comment

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

no

@pierwill
Copy link
Member Author

pierwill commented Feb 17, 2022

Conversation regarding correctness of this PR on Zulip:

@pierwill: Another PR related to #90317 (ordering): #94006. I was so eager to clear away sorting of HirIds that I didn't fully think through whether the type introduced here would have the same problems. Is rustc_middle::mir::Field safe for incr. comp. in the sense of #90317?

@cgillot: Field represents the position of a data field inside an datatype. This type exists for documentation and type-safety purposes. It derives HashStable in a straightforward manner: the index is hashed, without any elaborate hashing scheme like DefId and ExpnId do. So Field is fine for incr comp.

👍 👍

diag.span_label(upvar_def_span, "variable defined here");
diag.span_label(upvar_span, "variable captured here");
let captured_place = &self.upvars[upvar_field.index()].place;
let defined_hir = match captured_place.place.base {
Copy link
Contributor

Choose a reason for hiding this comment

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

to some extent that comment here to this now, because the thing we've captured is really a full place, not just the base of the place

@@ -2530,9 +2530,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
body,
);
let category = if let Some(field) = field {
let var_hir_id = self.borrowck_context.upvars[field.index()].place.get_root_variable();
// FIXME(project-rfc-2229#8): Use Place for better diagnostics
Copy link
Contributor

Choose a reason for hiding this comment

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

no

@nikomatsakis
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented Feb 18, 2022

📌 Commit f41722a has been approved by nikomatsakis

@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 Feb 18, 2022
bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 19, 2022
…askrgr

Rollup of 7 pull requests

Successful merges:

 - rust-lang#92902 (Improve the documentation of drain members)
 - rust-lang#93658 (Stabilize `#[cfg(panic = "...")]`)
 - rust-lang#93954 (rustdoc-json: buffer output)
 - rust-lang#93979 (Add debug assertions to validate NUL terminator in c strings)
 - rust-lang#93990 (pre rust-lang#89862 cleanup)
 - rust-lang#94006 (Use a `Field` in `ConstraintCategory::ClosureUpvar`)
 - rust-lang#94086 (Fix ScalarInt to char conversion)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit c28940e into rust-lang:master Feb 19, 2022
@rustbot rustbot added this to the 1.60.0 milestone Feb 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

6 participants