Fix capturing duplicated lifetimes via parent in precise_captures (impl use<'...>)#124104
Merged
bors merged 1 commit intorust-lang:masterfrom Apr 20, 2024
Merged
Conversation
This comment has been minimized.
This comment has been minimized.
344151a to
05bac93
Compare
oli-obk
reviewed
Apr 19, 2024
| } | ||
|
|
||
| impl<'a> W<'a> { | ||
| fn good2() -> impl use<'a> Into<<Self as Tr>::Assoc> {} |
Contributor
There was a problem hiding this comment.
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
oli-obk
approved these changes
Apr 19, 2024
Contributor
oli-obk
left a comment
There was a problem hiding this comment.
r=me with test having a comment explaining what it tests
05bac93 to
5daf58f
Compare
Contributor
Author
|
@bors r=oli-obk rollup |
Collaborator
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Apr 20, 2024
…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
rust-timer
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Apr 20, 2024
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
For technical reasons related to the way that
SelfandT::Assocare 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