-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Make TAITs and ATPITs capture late-bound lifetimes in scope #122103
Conversation
@@ -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 |
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 error message sucks but is improved by #122100. Separated that from this PR for reviewability.
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. |
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+ |
☔ The latest upstream changes (presumably #121154) made this pull request unmergeable. Please resolve the merge conflicts. |
0241618
to
e88c048
Compare
@bors r=oli-obk |
☔ The latest upstream changes (presumably #122151) made this pull request unmergeable. Please resolve the merge conflicts. |
e88c048
to
74d5bbb
Compare
@bors r+ |
…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
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)
|
||
// 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() { |
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.
The parent generics are bivariant and can easily be unconstrained lifetime variables. This caused #122307.
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)