This is the doc for open discussion within wg-async about various design questions and other topics.
open-discussion
This is the prepared document for today.
tmandry: Is the dyn coercion doing some kind of "magic" to pave over the issue, or does the behavior fall out of rules we would expect?
TC: Type erasure. The problem is that the type can't be named outside of the function (due to the lifetime that's valid only within the function). The value can escape but the name of the type/lifetime cannot. So type erasure "fixes" it.
tmandry: What does the doc mean "this works"? There is still a "Dummy" placeholder in the code.
..oh, you're saying if you make a Dummy struct and put it there the code compiles. Got it. That seems similar to the idea of using a placeholder type like _
to signify that the type doesn't matter.
TC: Right.
tmandry: What's the desired outcome?
TC: This issue was nominated for wg-async, do we want to fix it?
TC: TAIT is the obvious solution here. Can also have the compiler notice that the hidden type doesn't capture the type parameter.
tmandry: Agreed that TAIT is the way to go. The other way sounds like auto trait leakage, I'm more hesitant about that.
TC: The capture is not part of the opaque type itself.
eholk: Still externally visible in terms of whether code outside the function itself compiles or not.
TC: This is not correct; the capture only affects what lifetimes the hidden type (the concrete return type of the function in this case) is allowed to name. Nothing not named in the opaque type can affect code outside of the function.
eholk: There's something the compiler is considering that isn't written down anywhere. Maybe the capture rules are too generous.
tmandry: In the lang team meeting we decided to make it more consistent, i.e. by having it capture everything. A syntax would be nice but haven't seen a good one yet.
TC: Also, what we decided about making the capture rules more consistent is a separable issue from maybe later adding a syntax to more precisely control the capturing of lifetime and type parameters.
eholk: I like having simpler rules. Explicit syntax might be good. for<'a>
, impl<'a>
TC: The problem is that our return type satisfies the outlives
predicate but we can't return it. That's just weird.
tmandry: Yeah maybe we can come up with some way around it, the compiler is trying to satisfy syntactic rules about lifetime names for which there is no syntax (see Dummy
in example Example 2.1).
TC: It's also possible to use existential lifetimes here.
Yosh: 'static
?
TC: I don't think it works in this case.
or
or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up
Syntax | Example | Reference | |
---|---|---|---|
# Header | Header | 基本排版 | |
- Unordered List |
|
||
1. Ordered List |
|
||
- [ ] Todo List |
|
||
> Blockquote | Blockquote |
||
**Bold font** | Bold font | ||
*Italics font* | Italics font | ||
~~Strikethrough~~ | |||
19^th^ | 19th | ||
H~2~O | H2O | ||
++Inserted text++ | Inserted text | ||
==Marked text== | Marked text | ||
[link text](https:// "title") | Link | ||
 | Image | ||
`Code` | Code |
在筆記中貼入程式碼 | |
```javascript var i = 0; ``` |
|
||
:smile: | ![]() |
Emoji list | |
{%youtube youtube_id %} | Externals | ||
$L^aT_eX$ | LaTeX | ||
:::info This is a alert area. ::: |
This is a alert area. |
On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?
Please give us some advice and help us improve HackMD.
Syncing