-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Make regionck care about placeholders in outlives components #118000
Conversation
@@ -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 |
There was a problem hiding this comment.
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)] |
There was a problem hiding this comment.
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.
There was a problem hiding this 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
tests/ui/traits/non_lifetime_binders/placeholders-dont-outlive-static.rs
Outdated
Show resolved
Hide resolved
compiler/rustc_trait_selection/src/traits/query/type_op/implied_outlives_bounds.rs
Outdated
Show resolved
Hide resolved
b85f1e2
to
8f267e2
Compare
@bors r=aliemjay |
…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
…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
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
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 fornon_lifetime_binders
, and even more problematic forwith_negative_coherence
, since negative coherence uses placeholders as universals.This PR adds
Component::Placeholder
which acts much likeComponent::Param
. This currently causes a regression in some non-lifetime-binders tests becausefor<T> T: 'static
doesn't imply itself when processing outlives obligations, so code like this will fail:Since the where clause doesn't imply itself. This requires making the
MatchAgainstHigherRankedOutlives
relation smarter when it comes to binders.r? types