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 implied outlives bounds logic for projections #101680

Merged
merged 2 commits into from
Feb 10, 2023

Conversation

jackh726
Copy link
Member

The logic here is subtly wrong. I put a bit of an explanation in a767d7b5165cea8ee5cbe494a4a636c50ef67c9c.

TL;DR: we register outlives predicates to be proved, because wf code normalizes projections (from the unnormalized types) to type variables. This causes us to register those as constraints instead of implied. This was "fine", because we later added that implied bound in the normalized type, and delayed registering constraints. When I went to cleanup free_region_relations to not delay adding constraints, this bug was uncovered.

cc. @aliemjay because this caused your test failure in #99832 (I only realized as I was writing this)

r? @nikomatsakis

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

@bors try

@bors
Copy link
Contributor

bors commented Sep 11, 2022

⌛ Trying commit 79367191d3c2148648e4167e4e366a538c2f7650 with merge 77b749d3ae4f115e3b8cef8a0e20da0998461320...

@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Contributor

bors commented Sep 11, 2022

💔 Test failed - checks-actions

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 11, 2022
@jackh726
Copy link
Member Author

Spurious?

@bors try

@bors
Copy link
Contributor

bors commented Sep 11, 2022

⌛ Trying commit 79367191d3c2148648e4167e4e366a538c2f7650 with merge d752302224558bd75a97bd19853f642147a9d13b...

@bors
Copy link
Contributor

bors commented Sep 11, 2022

💔 Test failed - checks-actions

@rust-log-analyzer

This comment has been minimized.

@jackh726
Copy link
Member Author

@bors try

@bors
Copy link
Contributor

bors commented Sep 11, 2022

⌛ Trying commit f8f8a50 with merge ee93ebe8ef8a3e16bffdd473f324fc515dec2948...

@bors
Copy link
Contributor

bors commented Sep 11, 2022

💔 Test failed - checks-actions

@rust-log-analyzer

This comment has been minimized.

@jackh726
Copy link
Member Author

@bors try

@bors
Copy link
Contributor

bors commented Sep 12, 2022

⌛ Trying commit 9e6234b294bc5aae0b6fcf8d7b0a73e55459d67d with merge e79c9799a5ffd821c63b799b91e8aa87fd7ebb1e...

@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Contributor

bors commented Sep 12, 2022

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

@jackh726
Copy link
Member Author

@craterbot check

@rustbot rustbot assigned lcnr and unassigned oli-obk Jan 10, 2023
Copy link
Contributor

@lcnr lcnr left a comment

Choose a reason for hiding this comment

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

nits, then r=me

let param_env = self.param_env;
self.add_outlives_bounds(outlives::explicit_outlives_bounds(param_env));

// Finally:
Copy link
Contributor

@lcnr lcnr Jan 13, 2023

Choose a reason for hiding this comment

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

"Finally:" seems wrong, considering that we add the implied bounds further down 😁

// We add implied bounds from both the unnormalized and normalized ty.
// See issue #87748
let constraints_unnorm = self.add_implied_bounds(ty);
constraints_unnorm.map(|c| constraints.push(c));
Copy link
Contributor

Choose a reason for hiding this comment

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

can you use if let here? map with side effects always looks a bit scary to me

@@ -918,6 +918,8 @@ pub(crate) struct MirTypeckRegionConstraints<'tcx> {
}

impl<'tcx> MirTypeckRegionConstraints<'tcx> {
/// Creates a `Region` that for a given `PlaceholderRegion`, or returns the
Copy link
Contributor

Choose a reason for hiding this comment

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

"Creates a Region that for a given PlaceholderRegion"?

@apiraino
Copy link
Contributor

apiraino commented Feb 2, 2023

Switching to waiting on author to incorporate last changes (see comment) then we should be set.

@rustbot author

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 2, 2023
@rustbot rustbot added the T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) label Feb 10, 2023
@rustbot
Copy link
Collaborator

rustbot commented Feb 10, 2023

Hey! It looks like you've submitted a new PR for the library teams!

If this PR contains changes to any rust-lang/rust public library APIs then please comment with @rustbot label +T-libs-api -T-libs to tag it appropriately. If this PR contains changes to any unstable APIs please edit the PR description to add a link to the relevant API Change Proposal or create one if you haven't already. If you're unsure where your change falls no worries, just leave it as is and the reviewer will take a look and make a decision to forward on if necessary.

Examples of T-libs-api changes:

  • Stabilizing library features
  • Introducing insta-stable changes such as new implementations of existing stable traits on existing stable types
  • Introducing new or changing existing unstable library APIs (excluding permanently unstable features / features without a tracking issue)
  • Changing public documentation in ways that create new stability guarantees
  • Changing observable runtime behavior of library APIs

Some changes occurred in src/tools/cargo

cc @ehuss

@jackh726 jackh726 force-pushed the implied-cleanup branch 4 times, most recently from 22a8dae to 40e519e Compare February 10, 2023 02:08
@jackh726
Copy link
Member Author

@bors r=lcnr rollup=never

@bors
Copy link
Contributor

bors commented Feb 10, 2023

📌 Commit 0637b6b has been approved by lcnr

It is now in the queue for this repository.

@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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Feb 10, 2023
@bors
Copy link
Contributor

bors commented Feb 10, 2023

⌛ Testing commit 0637b6b with merge a697573...

@bors
Copy link
Contributor

bors commented Feb 10, 2023

☀️ Test successful - checks-actions
Approved by: lcnr
Pushing a697573 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Feb 10, 2023
@bors bors merged commit a697573 into rust-lang:master Feb 10, 2023
@rustbot rustbot added this to the 1.69.0 milestone Feb 10, 2023
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (a697573): comparison URL.

Overall result: no relevant changes - no action needed

@rustbot label: -perf-regression

Instruction count

This benchmark run did not return any relevant results for this metric.

Max RSS (memory usage)

Results

This 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.

mean range count
Regressions ❌
(primary)
3.1% [3.1%, 3.1%] 1
Regressions ❌
(secondary)
2.6% [1.6%, 3.2%] 14
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 3.1% [3.1%, 3.1%] 1

Cycles

Results

This 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.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
2.3% [1.6%, 2.9%] 5
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

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. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-types Relevant to the types team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.