Skip to content

Make functions passed to BoundVarReplacer be optional #83090

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 1 commit into from
Mar 17, 2021

Conversation

jackh726
Copy link
Member

This means we can reuse the bound vars when we don't care to change them

@rust-highfive
Copy link
Contributor

r? @varkor

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Mar 13, 2021
@jackh726
Copy link
Member Author

@bors try @rust-timer queue

@rust-timer
Copy link
Collaborator

Awaiting bors try build completion.

@rustbot label: +S-waiting-on-perf

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Mar 13, 2021
@bors
Copy link
Collaborator

bors commented Mar 13, 2021

⌛ Trying commit d22289d3ce6cbdb1ba66053d03ef23e96985fc50 with merge 4f15e3f1454acbf63f87a260b0b68a36cb27206a...

@bors
Copy link
Collaborator

bors commented Mar 13, 2021

☀️ Try build successful - checks-actions
Build commit: 4f15e3f1454acbf63f87a260b0b68a36cb27206a (4f15e3f1454acbf63f87a260b0b68a36cb27206a)

@rust-timer
Copy link
Collaborator

Queued 4f15e3f1454acbf63f87a260b0b68a36cb27206a with parent 56f74c5, future comparison URL.

@rust-timer
Copy link
Collaborator

Finished benchmarking try commit (4f15e3f1454acbf63f87a260b0b68a36cb27206a): comparison url.

Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. Please note that if the perf results are neutral, you should likely undo the rollup=never given below by specifying rollup- to bors.

Importantly, though, if the results of this run are non-neutral do not roll this PR up -- it will mask other regressions or improvements in the roll up.

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

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Mar 13, 2021
@jackh726
Copy link
Member Author

Perf is mixed. Maybe slightly clean on instruction counts, but heavily mixed for max-rss and wall-time. I'll leave it up to a reviewer to decide if benefits of "None means no change" outweighs the slight overhead in cognitive complexity.

@@ -471,9 +471,12 @@ impl<'a, 'tcx> TypeFolder<'tcx> for BoundVarReplacer<'a, 'tcx> {
match *t.kind() {
Copy link
Member

Choose a reason for hiding this comment

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

I wonder whether something like this would be more readable:

fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx> {
    match *t.kind() {
        ty::Bound(debruijn, bound_ty) if debruijn == self.current_index => {
            if let Some(fld_t) = self.fld_t.as_mut() {
                let ty = fld_t(bound_ty);
                return ty::fold::shift_vars(self.tcx, &ty, self.current_index.as_u32());
            }
        }
        _ if t.has_vars_bound_at_or_above(self.current_index) => return t.super_fold_with(self),
    }
    t
}

(and similarly for the other methods).

Copy link
Member Author

Choose a reason for hiding this comment

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

Ooh, I like that

@varkor
Copy link
Member

varkor commented Mar 15, 2021

I don't have a strong opinion on whether this is more or less readable. If you personally find it more readable, then I'm happy. It would be nice to simplify the methods as in my comment above, though.

@jackh726
Copy link
Member Author

I don't have a strong opinion on whether this is more or less readable. If you personally find it more readable, then I'm happy. It would be nice to simplify the methods as in my comment above, though.

I personally think the idea of "None means you don't want to change anything" is nice, even if there isn't really any additional perf benefit (I imagine we probably just don't end up with enough bound tys or consts for it to matter.)

@jackh726 jackh726 force-pushed the bound_var_replacer_option branch from d22289d to ba27cae Compare March 15, 2021 23:00
@varkor
Copy link
Member

varkor commented Mar 15, 2021

r=me when CI passes.

@jackh726
Copy link
Member Author

@bors r=varkor

@bors
Copy link
Collaborator

bors commented Mar 16, 2021

📌 Commit ba27cae has been approved by varkor

@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 Mar 16, 2021
@bors
Copy link
Collaborator

bors commented Mar 16, 2021

⌛ Testing commit ba27cae with merge 3b8e3d885585effc745b57c774aabf56bff6c4a9...

@bors
Copy link
Collaborator

bors commented Mar 16, 2021

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Mar 16, 2021
@rust-log-analyzer
Copy link
Collaborator

A job failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)

@jackh726
Copy link
Member Author

Looks spurious @bors retry

@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 Mar 16, 2021
@bors
Copy link
Collaborator

bors commented Mar 17, 2021

⌛ Testing commit ba27cae with merge 04ae501...

@bors
Copy link
Collaborator

bors commented Mar 17, 2021

☀️ Test successful - checks-actions
Approved by: varkor
Pushing 04ae501 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Mar 17, 2021
@bors bors merged commit 04ae501 into rust-lang:master Mar 17, 2021
@rustbot rustbot added this to the 1.52.0 milestone Mar 17, 2021
@jackh726 jackh726 deleted the bound_var_replacer_option branch March 17, 2021 18:34
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants