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

Make regionck care about placeholders in outlives components #118000

Merged
merged 1 commit into from Nov 20, 2023

Conversation

compiler-errors
Copy link
Member

Currently, we don't consider a placeholder type !T to be a type component when it comes to processing type-outlives obligations. This means that they are essentially treated like unit values with no sub-components, and always outlive any region. This is problematic for non_lifetime_binders, and even more problematic for with_negative_coherence, since negative coherence uses placeholders as universals.

This PR adds Component::Placeholder which acts much like Component::Param. This currently causes a regression in some non-lifetime-binders tests because for<T> T: 'static doesn't imply itself when processing outlives obligations, so code like this will fail:

fn foo() where for<T> T: 'static {
  foo() //~ fails
}

Since the where clause doesn't imply itself. This requires making the MatchAgainstHigherRankedOutlives relation smarter when it comes to binders.

r? types

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Nov 17, 2023
@@ -7,5 +7,20 @@ LL | #![feature(non_lifetime_binders)]
= note: see issue #108185 <https://github.com/rust-lang/rust/issues/108185> for more information
= note: `#[warn(incomplete_features)]` on by default

warning: 1 warning emitted
error[E0309]: the placeholder type `!1_"F"` may not live long enough
Copy link
Member Author

Choose a reason for hiding this comment

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

I don't really care about fixing this diagnostic regression for now, since it's behind a super unstable feature gate.

@@ -0,0 +1,14 @@
#![feature(negative_impls)]
Copy link
Member Author

Choose a reason for hiding this comment

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

This currently fails on nightly for the same root cause as #117994. Only after that PR is this behavior exploitable. I'm just committing this test here, though, since it should not regress.

Copy link
Member

@aliemjay aliemjay left a comment

Choose a reason for hiding this comment

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

Makes sense. You can r=me after the nits.
r? aliemjay

@rustbot rustbot assigned aliemjay and unassigned spastorino Nov 19, 2023
@compiler-errors
Copy link
Member Author

@bors r=aliemjay

@bors
Copy link
Contributor

bors commented Nov 19, 2023

📌 Commit 8f267e2 has been approved by aliemjay

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-review Status: Awaiting review from the assignee but also interested parties. labels Nov 19, 2023
bors added a commit to rust-lang-ci/rust that referenced this pull request Nov 20, 2023
…mpiler-errors

Rollup of 8 pull requests

Successful merges:

 - rust-lang#117828 (Avoid iterating over hashmaps in astconv)
 - rust-lang#117832 (interpret: simplify handling of shifts by no longer trying to handle signed and unsigned shift amounts in the same branch)
 - rust-lang#117891 (Recover `dyn` and `impl` after `for<...>`)
 - rust-lang#117957 (if available use a Child's pidfd for kill/wait)
 - rust-lang#117988 (Handle attempts to have multiple `cfg`d tail expressions)
 - rust-lang#117994 (Ignore but do not assume region obligations from unifying headers in negative coherence)
 - rust-lang#118000 (Make regionck care about placeholders in outlives components)
 - rust-lang#118068 (subtree update cg_gcc 2023/11/17)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit to rust-lang-ci/rust that referenced this pull request Nov 20, 2023
…tthiaskrgr

Rollup of 8 pull requests

Successful merges:

 - rust-lang#117828 (Avoid iterating over hashmaps in astconv)
 - rust-lang#117832 (interpret: simplify handling of shifts by no longer trying to handle signed and unsigned shift amounts in the same branch)
 - rust-lang#117891 (Recover `dyn` and `impl` after `for<...>`)
 - rust-lang#117957 (if available use a Child's pidfd for kill/wait)
 - rust-lang#117988 (Handle attempts to have multiple `cfg`d tail expressions)
 - rust-lang#117994 (Ignore but do not assume region obligations from unifying headers in negative coherence)
 - rust-lang#118000 (Make regionck care about placeholders in outlives components)
 - rust-lang#118068 (subtree update cg_gcc 2023/11/17)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 6388c0e into rust-lang:master Nov 20, 2023
11 checks passed
@rustbot rustbot added this to the 1.76.0 milestone Nov 20, 2023
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Nov 20, 2023
Rollup merge of rust-lang#118000 - compiler-errors:placeholder-ty-outlives, r=aliemjay

Make regionck care about placeholders in outlives components

Currently, we don't consider a placeholder type `!T` to be a type component when it comes to processing type-outlives obligations. This means that they are essentially treated like unit values with no sub-components, and always outlive any region. This is problematic for `non_lifetime_binders`, and even more problematic for `with_negative_coherence`, since negative coherence uses placeholders as universals.

This PR adds `Component::Placeholder` which acts much like `Component::Param`. This currently causes a regression in some non-lifetime-binders tests because `for<T> T: 'static` doesn't imply itself when processing outlives obligations, so code like this will fail:

```
fn foo() where for<T> T: 'static {
  foo() //~ fails
}
```

Since the where clause doesn't imply itself. This requires making the `MatchAgainstHigherRankedOutlives` relation smarter when it comes to binders.

r? types
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.

None yet

5 participants