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

fix universes in the NLL type tests #98109

Merged
merged 18 commits into from
Jun 24, 2022
Merged

Conversation

nikomatsakis
Copy link
Contributor

@nikomatsakis nikomatsakis commented Jun 14, 2022

In the NLL code, we were not accommodating universes in the
type_test logic.

Fixes #98095.

r? @compiler-errors

This breaks some tests, however, so the purpose of this branch is more explanatory and perhaps to do a crater run.

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

@bors try

@bors
Copy link
Contributor

bors commented Jun 14, 2022

⌛ Trying commit 54d4fee2b42bbaa0073f89a7b979ed1cbb34f34b with merge 363598f22faa9d0e3a12f5b6d2b118bc77f83bf7...

@compiler-errors compiler-errors added S-experimental Status: Ongoing experiment that does not require reviewing and won't be merged in its current state. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 14, 2022
@compiler-errors
Copy link
Member

marking this as experimental since it probably shouldn't be merged, since it breaks existing UI tests


return self.eval_outlives(sup_region, self.universal_regions.fr_static);
}

// Both the `sub_region` and `sup_region` consist of the union
// of some number of universal regions (along with the union
// of various points in the CFG; ignore those points for
Copy link
Member

Choose a reason for hiding this comment

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

I'm curious if the logic below (let universal_outlives = ...) is necessary due to the added logic above. I don't know enough about borrowck to make a judgement.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I believe it is still relevant. I think that the code below is meant to deal with "top-level" generics declared on the function, where we do have finer-grained outlives data.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In other words, it deals with relationships between universals and variables that are in the same universe.

@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Contributor

bors commented Jun 14, 2022

☀️ Try build successful - checks-actions
Build commit: 363598f22faa9d0e3a12f5b6d2b118bc77f83bf7 (363598f22faa9d0e3a12f5b6d2b118bc77f83bf7)

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@klensy

This comment was marked as outdated.

the excessive generality becomes annoying later because
it wouldn't implement type folding etc
we don't really take other things
The code now accepts `Binder<OutlivesPredicate>`
instead of just `OutlivesPredicate` and thus exercises
the new, generalized `IfEqBound` codepaths. Note though
that we never *produce* Binder<OutlivesPredicate>, so we
are only testing a subset of those codepaths that excludes
actual higher-ranked outlives bounds.
// Test that we consider `for<'a> &'a T: 'a` to be sufficient to prove
// that `for<'a> &'a T: 'a`.
//
// FIXME. Except we don't!
Copy link
Member

Choose a reason for hiding this comment

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

known-bug?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I believe so, certainly a pre-existing one. This feels like an implied bounds situation to me. We ought to be able to know that for<'a> &'a T: 'a is really for<'a> if (WF(&'a T)) { &'a T: 'a }, and -- in that case -- we would be succesful here.

Copy link
Member

Choose a reason for hiding this comment

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

I think @jackh726 means using the // known-bug attribute

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, cool. Citing which bug?

@rust-log-analyzer

This comment has been minimized.

In the NLL code, we were not accommodating universes in the
`type_test` logic. This led to issue 98095.
These were "fixed" as part of switching on NLL but seems
to be due to another problem. Preliminary investigation
suggests they are both PROBABLY "implied bounds" related.
Co-authored-by: Oli Scherer <github35764891676564198441@oli-obk.de>
@rust-log-analyzer

This comment has been minimized.

@jackh726
Copy link
Member

@bors r+ p=5 rollup=never

We want this in before beta cut, since this fixes a stable-to-nightly unsound regression, caused by NLL stabilization.

There are two known regressions here, but one requires GATs (unstable) and the other has an obvious fix (remove the 'a bound). Given this, it makes sense to land this. We might be able to fix and backport a fix for those; but if not, it's not the end of the world.

I think the code here and adjacent would be a good candidate for a types team deep dive; this feels a bit ad-hoc to me, even if correct (but I have little personal context to the overall design of this logic).

@bors
Copy link
Contributor

bors commented Jun 24, 2022

📌 Commit e7ed8fe has been approved by jackh726

@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 Jun 24, 2022
@bors
Copy link
Contributor

bors commented Jun 24, 2022

⌛ Testing commit e7ed8fe with merge d017d59...

@bors
Copy link
Contributor

bors commented Jun 24, 2022

☀️ Test successful - checks-actions
Approved by: jackh726
Pushing d017d59 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Jun 24, 2022
@bors bors merged commit d017d59 into rust-lang:master Jun 24, 2022
@rustbot rustbot added this to the 1.63.0 milestone Jun 24, 2022
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (d017d59): comparison url.

Instruction count

  • Primary benchmarks: 😿 relevant regressions found
  • Secondary benchmarks: 😿 relevant regressions found
mean1 max count2
Regressions 😿
(primary)
0.6% 1.9% 31
Regressions 😿
(secondary)
0.9% 2.0% 35
Improvements 🎉
(primary)
N/A N/A 0
Improvements 🎉
(secondary)
N/A N/A 0
All 😿🎉 (primary) 0.6% 1.9% 31

Max RSS (memory usage)

Results
  • Primary benchmarks: no relevant changes found
  • Secondary benchmarks: mixed results
mean1 max count2
Regressions 😿
(primary)
N/A N/A 0
Regressions 😿
(secondary)
4.0% 4.0% 1
Improvements 🎉
(primary)
N/A N/A 0
Improvements 🎉
(secondary)
-8.4% -8.4% 1
All 😿🎉 (primary) N/A N/A 0

Cycles

Results
  • Primary benchmarks: 😿 relevant regressions found
  • Secondary benchmarks: 🎉 relevant improvement found
mean1 max count2
Regressions 😿
(primary)
1.7% 1.8% 3
Regressions 😿
(secondary)
N/A N/A 0
Improvements 🎉
(primary)
N/A N/A 0
Improvements 🎉
(secondary)
-2.9% -2.9% 1
All 😿🎉 (primary) 1.7% 1.8% 3

If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf.

Next Steps: If you can justify the regressions found in this perf run, please indicate this with @rustbot label: +perf-regression-triaged along with sufficient written justification. If you cannot justify the regressions please open an issue or create a new PR that fixes the regressions, add a comment linking to the newly created issue or PR, and then add the perf-regression-triaged label to this PR.

@rustbot label: +perf-regression

Footnotes

  1. the arithmetic mean of the percent change 2 3

  2. number of relevant changes 2 3

@oli-obk
Copy link
Contributor

oli-obk commented Jun 24, 2022

In diesel-check-full, the main regression is

205,739,874  ???:<rustc_middle::ty::context::CtxtInterners>::intern_ty
190,507,805  ???:<alloc::vec::Vec<rustc_middle::ty::sty::Binder<rustc_middle::ty::OutlivesPredicate<rustc_middle::ty::Ty, rustc_middle::ty::sty::Region>>> as alloc::vec::spec_from_iter::SpecFromIter<rustc_middle::ty::sty::Binder<rustc_middle::ty::OutlivesPredicate<rustc_middle::ty::Ty, rustc_middle::ty::sty::Region>>, core::iter::adapters::inspect::Inspect<core::iter::adapters::chain::Chain<core::iter::adapters::filter::Filter<core::iter::adapters::filter_map::FilterMap<core::iter::adapters::copied::Copied<core::slice::iter::Iter<rustc_middle::ty::Predicate>>, <rustc_infer::infer::outlives::verify::VerifyBoundCx>::collect_outlives_from_predicate_list<core::iter::adapters::copied::Copied<core::slice::iter::Iter<rustc_middle::ty::Predicate>>>::{closure

the second one is entirely due to the logic in can_match_erased_ty. There may be some possible gains if we skip the binder first and then erase, but it generally won't help much. Ideally we'd just relate the types while ignoring lifetimes.

@rylev
Copy link
Member

rylev commented Jun 28, 2022

@oli-obk should we capture this in an issue? I think it's pretty likely that this regression will go unaddressed if we leave it in the comment here.

@oli-obk
Copy link
Contributor

oli-obk commented Jun 28, 2022

This is a soundness fix, the additional checking is necessary for soundness. I don't believe the regression is directly addressable, even if we can do some improvements here.

I'll open a PR for the binder skipping thing to see if it has any effect, but I don't think it'll be significant.

@rylev
Copy link
Member

rylev commented Jun 28, 2022

Ok I think we can mark this as triaged then.

@rustbot label: +perf-regression-triaged

@rustbot rustbot added the perf-regression-triaged The performance regression has been triaged. label Jun 28, 2022
aliemjay added a commit to aliemjay/snocat that referenced this pull request Jul 31, 2022
Dessix pushed a commit to microsoft/snocat that referenced this pull request Oct 10, 2022
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. perf-regression Performance regression. perf-regression-triaged The performance regression has been triaged. 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.

NLL: unsound verification of higher ranked outlives bounds