-
Notifications
You must be signed in to change notification settings - Fork 13k
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 capturing duplicated lifetimes via parent in precise_captures
(impl use<'...>
)
#124104
Conversation
This comment has been minimized.
This comment has been minimized.
344151a
to
05bac93
Compare
} | ||
|
||
impl<'a> W<'a> { | ||
fn good2() -> impl use<'a> Into<<Self as Tr>::Assoc> {} |
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.
Document that this test is ensuring that Self
captures work, even though they refer to the parent's 'a
instead of the opaque type's copy
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.
r=me with test having a comment explaining what it tests
05bac93
to
5daf58f
Compare
@bors r=oli-obk rollup |
…iaskrgr Rollup of 3 pull requests Successful merges: - rust-lang#123409 (Implement Modified Condition/Decision Coverage) - rust-lang#124104 (Fix capturing duplicated lifetimes via parent in `precise_captures` (`impl use<'...>`)) - rust-lang#124137 (Match hyphen in multi-revision comment matchers) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#124104 - compiler-errors:parent-generic-use, r=oli-obk Fix capturing duplicated lifetimes via parent in `precise_captures` (`impl use<'...>`) For technical reasons related to the way that `Self` and `T::Assoc` are lowered from HIR -> `rustc_middle::ty`, an opaque may mention in its bounds both the original early-bound lifetime from the parent `impl`/`fn`, *and* the *duplicated* early-bound lifetime on the opaque. This is fine -- and has been fine since `@cjgillot` rewrote the way we handled opaque lifetime captures, and we went further to allow this behavior explicitly in rust-lang#115659. It's worthwhile to read this PR's technical section to recall how this duplication works and when it acts surprisingly. The problem here is that the check that make sure that `impl use<'a, 'b>` lists all of the opaque's captured lifetimes wasn't smart enough to consider both these captured lifetimes and the original lifetimes they're duplicated from to be equal. This PR fixes that. r? oli-obk
For technical reasons related to the way that
Self
andT::Assoc
are lowered from HIR ->rustc_middle::ty
, an opaque may mention in its bounds both the original early-bound lifetime from the parentimpl
/fn
, and the duplicated early-bound lifetime on the opaque.This is fine -- and has been fine since @cjgillot rewrote the way we handled opaque lifetime captures, and we went further to allow this behavior explicitly in #115659. It's worthwhile to read this PR's technical section to recall how this duplication works and when it acts surprisingly.
The problem here is that the check that make sure that
impl use<'a, 'b>
lists all of the opaque's captured lifetimes wasn't smart enough to consider both these captured lifetimes and the original lifetimes they're duplicated from to be equal. This PR fixes that.r? oli-obk