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 TAITs and ATPITs capture late-bound lifetimes in scope #122103

Merged
merged 3 commits into from Mar 8, 2024

Conversation

compiler-errors
Copy link
Member

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
@@ -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
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 error message sucks but is improved by #122100. Separated that from this PR for reviewability.

@compiler-errors
Copy link
Member Author

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
Copy link
Contributor

oli-obk commented Mar 7, 2024

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
Copy link
Contributor

bors commented Mar 7, 2024

📌 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
Copy link
Contributor

bors commented Mar 7, 2024

☔ The latest upstream changes (presumably #121154) made this pull request unmergeable. Please resolve the merge conflicts.

@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
Copy link
Member Author

@bors r=oli-obk

@bors
Copy link
Contributor

bors commented Mar 7, 2024

📌 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
Copy link
Contributor

bors commented Mar 8, 2024

☔ The latest upstream changes (presumably #122151) made this pull request unmergeable. Please resolve the merge conflicts.

@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
Copy link
Contributor

oli-obk commented Mar 8, 2024

@bors r+

@bors
Copy link
Contributor

bors commented Mar 8, 2024

📌 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
…iaskrgr

Rollup of 8 pull requests

Successful merges:

 - rust-lang#118623 (Improve std::fs::read_to_string example)
 - rust-lang#119365 (Add asm goto support to `asm!`)
 - rust-lang#120608 (Docs for std::ptr::slice_from_raw_parts)
 - rust-lang#121832 (Add new Tier-3 target: `loongarch64-unknown-linux-musl`)
 - rust-lang#121938 (Fix quadratic behavior of repeated vectored writes)
 - rust-lang#122099 (Add  `#[inline]` to `BTreeMap::new` constructor)
 - rust-lang#122103 (Make TAITs and ATPITs capture late-bound lifetimes in scope)
 - rust-lang#122143 (PassWrapper: update for llvm/llvm-project@a3319371970b)

Failed merges:

 - rust-lang#122076 (Tweak the way we protect in-place function arguments in interpreters)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit d4d18d2 into rust-lang:master Mar 8, 2024
11 checks passed
@rustbot rustbot added this to the 1.78.0 milestone Mar 8, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Mar 8, 2024
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)
@compiler-errors compiler-errors deleted the taits-capture-everything branch March 8, 2024 15:02

// 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() {
Copy link
Member

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.

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.

nested TAITs/ATPITs should reject higher-ranked regions
5 participants