Make TAITs and ATPITs capture late-bound lifetimes in scope by compiler-errors · Pull Request #122103 · rust-lang/rust (original) (raw)

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 andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation11 Commits3 Checks0 Files changed

Conversation

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

[ Show hidden characters]({{ revealButtonHref }})

compiler-errors

This generalizes the behavior that RPITs have, where they duplicate their in-scope lifetimes so that they will always reify late-bound lifetimes that they capture. This allows TAITs and ATPITs to properly error when they capture in-scope late-bound lifetimes.

r? @oli-obk cc @aliemjay

Fixes #122093 and therefore #120700 (comment)

@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

Mar 6, 2024

compiler-errors

@@ -1,8 +1,14 @@
error: cannot capture late-bound lifetime in type alias impl trait
--> $DIR/escaping-bound-var.rs:9:57
error: higher kinded lifetime bounds on nested opaque types are not supported yet

Choose a reason for hiding this comment

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

This error message sucks but is improved by #122100. Separated that from this PR for reviewability.

@compiler-errors

Alternatively, we could implement this restriction in a far simpler manner by just checking if any late-bound vars are in scope of an opaque via a HIR walker. But given that we may want to support this eventually, and the rest of the compiler is already set up to support this because of RPIT, I'd rather do this the right way.

@oli-obk

yea, I prefer mirroring RPITs, even if that means we duplicate all the lifetimes from parents only to then immediately always ignore the parent lifetimes

@bors r+

@bors

📌 Commit 0241618 has been approved by oli-obk

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

Mar 7, 2024

@bors

@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-bors

Status: Waiting on bors to run and complete tests. Bors will change the label on completion.

labels

Mar 7, 2024

@compiler-errors

@bors

📌 Commit e88c048 has been approved by oli-obk

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

Mar 7, 2024

@bors

@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-bors

Status: Waiting on bors to run and complete tests. Bors will change the label on completion.

labels

Mar 8, 2024

@oli-obk

@bors

📌 Commit 74d5bbb has been approved by oli-obk

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

Mar 8, 2024

bors added a commit to rust-lang-ci/rust that referenced this pull request

Mar 8, 2024

@bors

rust-timer added a commit to rust-lang-ci/rust that referenced this pull request

Mar 8, 2024

@rust-timer

Rollup merge of rust-lang#122103 - compiler-errors:taits-capture-everything, r=oli-obk

Make TAITs and ATPITs capture late-bound lifetimes in scope

This generalizes the behavior that RPITs have, where they duplicate their in-scope lifetimes so that they will always reify late-bound lifetimes that they capture. This allows TAITs and ATPITs to properly error when they capture in-scope late-bound lifetimes.

r? @oli-obk cc @aliemjay

Fixes rust-lang#122093 and therefore rust-lang#120700 (comment)

aliemjay

// Only check the parent generics, which will ignore any of the
// duplicated lifetime args that come from reifying late-bounds.
for (i, arg) in opaque_type_key.args.iter().take(parent_generics.count()).enumerate() {

Choose a reason for hiding this comment

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

The parent generics are bivariant and can easily be unconstrained lifetime variables. This caused #122307.

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.