Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upall but the last field of a tuple must be Sized #1592
Conversation
This comment has been minimized.
This comment has been minimized.
brendanzab
reviewed
Apr 27, 2016
| @@ -719,7 +719,8 @@ declare one), but we'll take those basic conditions for granted. | |||
|
|
|||
| WfTuple: | |||
| ∀i. R ⊢ Ti WF | |||
| -------------------------------------------------- | |||
| ∀i<n. R ⊢ Ti: Sized // the *last* field may be unsized | |||
| -------------------------------------------------- | |||
This comment has been minimized.
This comment has been minimized.
arielb1
force-pushed the
arielb1:tuple-wf
branch
from
8b00af6
to
b2c8577
Apr 27, 2016
This comment has been minimized.
This comment has been minimized.
|
This is already the requirement for structs. This RFC PR is fixing that oversight. |
This comment has been minimized.
This comment has been minimized.
|
Yeah, I realized that, which is why I deleted the comment. |
nrc
added
the
T-lang
label
Apr 27, 2016
nikomatsakis
self-assigned this
Apr 28, 2016
nikomatsakis
added
the
final-comment-period
label
May 2, 2016
This comment has been minimized.
This comment has been minimized.
|
Hear ye, hear ye! This RFC is now entering final comment period. |
This comment has been minimized.
This comment has been minimized.
bluss
commented
May 7, 2016
|
I'm repeating myself, but this RFC seems to conflict with the representation ideas in /pull/1582, what do you think about that? |
This comment has been minimized.
This comment has been minimized.
|
The problem is that the ill-formed tuples cause ICEs. |
This comment has been minimized.
This comment has been minimized.
|
If we ever wanted to go with the tuple representation proposed in #1582 then this would need to be "all but the first field of a tuple must be
|
canndrew
referenced this pull request
May 9, 2016
Closed
Tracking issue for `..=` inclusive ranges (RFC #1192) -- originally `...` #28237
This comment has been minimized.
This comment has been minimized.
bluss
commented
May 9, 2016
|
@arielb1 I mean that there are Rfcs that propose alternate tuple representations that directly conflict with allowing the last field be unsized, at least it is a conflict as I understand it. That needs to be addressed explicitly. For example, you could say it is best to have tuple fields be laid out in order with a possible flexible size field last. |
This comment has been minimized.
This comment has been minimized.
|
@bluss sorry, for the record can you summarize or give some pointers to the conflict? One problem I am aware of is that, if you try to use tuple types as the basis for "variadic generics", that would require tuple types that can permit multiple unsized values to be stored within them (but I don't think this is really tied to the representation per se. That is, the same problem arises regardless of how tuples are laid out in memory.) I've not been able to follow the other RFC thread in great detail, so I may not be caught up on the latest complications there. @arielb1 the fact that ICEs are caused doesn't seem, in and of itself, to mean much. =) It's more interesting to dig into the causes of those ICEs. Perhaps you can say more about that? There is definitely an inherent inconsistent in allowing tuples to have multiple unsized values but not structs, but perhaps a reconcilable one. I could also imagine some rules that say that a tuple type may contain multiple unsized values, but that such a type could not be used in most contexts, but it seems kind of complicated. In any case, I don't necessarily think that THIS RFC amendment is the right place to resolve this conflict. That is, I think that this RFC is (as @arielb1 suggested) adding something that ought to have been in the initial RFC to begin with. Rather, the onus is on later RFCs to make the WF rules for tuples more liberal and work out the conflicts that arise as a result (I believe such a change would be backwards compatible). |
This comment has been minimized.
This comment has been minimized.
|
@nikomatsakis Why would using tuple types as the basis for variadic generics require permitting multiple unsized values? As far as @eddyb and I could tell, they just required some compiler trait implementation support and they were fine. You can't actually pass unsized types. Note: incorrect assumptions. It's to do with being able to map over types, as someone explained to me. |
This comment has been minimized.
This comment has been minimized.
|
Causes ICEs = the tuple can't be represented, so unless we want to introduce a new |
This comment has been minimized.
This comment has been minimized.
|
@nikomatsakis RFC #1582 proposes being able to write tuples as a head-element, tail-tuple pair like so: If we take a few steps back we can fix this problem by changing the cons-cell syntax so that the Also I think it's an abuse of tuples to use them as lists of types. |
This comment has been minimized.
This comment has been minimized.
|
The current situation: none of the fields of a tuple are required to be What this RFC proposes: require the first N-1 fields of a tuple to be What's up for debate w.r.t. #1582: should we also require the last field of a tuple to be So I don't think this RFC and #1582 are in conflict. |
This comment has been minimized.
This comment has been minimized.
bluss
commented
May 11, 2016
•
|
@glaebhoerl this RFC also further reinforces that the last field of the tuple is allowed to be ?Sized and that is a technical conflict with a reversed tuple representation. I was thinking of the simple case where the representation's last field is unsized. This RFC would in that sense mandate that tuples are explicitly ordered so that the logically last field is also last in the actual representation. That's a technical conflict with the proposal for "tuple slicing" in the other RFC which canndrew describes in this thread. I don't think that's a big deal, but it just needs some coordination or acknowledgement if you rule out an idea that is being developed in parallel. I think the current order of fields in the tuple representation is better, and that "tuple slicing" should instead destructure them into |
This comment has been minimized.
This comment has been minimized.
|
That is definitely something which should be debated and decided, but I don't see why it needs to hold up fixing the obvious bug that currently the first N-1 fields are allowed to be Maybe tweak the wording of the RFC text with respect to the last field if it's currently too definitive. But I don't think this should stop us from moving forward on the part that everyone agrees about. The debate about the last field can continue on #1582 which I think is a better place for it anyways. |
This comment has been minimized.
This comment has been minimized.
|
You're right, sorry, I was just worried that this RFC would solidify allowing the last field to be |
This comment has been minimized.
This comment has been minimized.
|
Yes, good point -- the reason is because of my desire to allow passing On Tue, May 10, 2016 at 07:01:17AM -0700, Nicole Mazzuca wrote:
|
This comment has been minimized.
This comment has been minimized.
|
I am, I admit, a bit torn. On the one hand, I think that this RFC On the other, if we did wind up wanting some change here that required But of course in practice it's all quite moot since the compiler So this is leading me to wonder if we should (for now) say that tuples On Wed, May 11, 2016 at 06:46:37AM -0700, Gábor Lehel wrote:
|
This comment has been minimized.
This comment has been minimized.
|
@nikomatsakis I don't think that passing an unsized type by value is a useful enough extension to the language to change tuples from being tuple struct like (over owned stack pointers); in fact, I haven't seen any change that makes me think that tuples should be any different from tuple structs. |
This comment has been minimized.
This comment has been minimized.
|
(that is useful enough to complicate the language into making tuples more than just an anonymous struct type) |
This comment has been minimized.
This comment has been minimized.
Well, I think this is quite unclear, in two respects. First, with respect to general utility, I consider passing unsized types by value a very useful extension to the language (and closing an unnecessary lack of symmetry). But in any case it's not a question that must be settled at this time. The second question is whether that would require making tuples be different from structs. One could imagine variadic generic systems that are not based on tuples. |
This comment has been minimized.
This comment has been minimized.
|
@nikomatsakis Allowing passing DSTs as function parameters is pretty much the only place where we could allow it; elsewhere, unsized types are not allowed (for example, in returns). It would open an unnecessary lack of symmetry in the language, IMO. |
This comment has been minimized.
This comment has been minimized.
golddranks
commented
May 13, 2016
|
@ubsan Couldn't DST returns, in principle, be allowed with the placement syntax? |
This comment has been minimized.
This comment has been minimized.
|
Huzzah! The @rust-lang/lang team has decided to accept this RFC. We debated going further (e.g., requiring that tuples consist purely of sized values) in the interest of maximum compatibility, but decided in the end that it was better to take the RFC as is, since it represents the most natural extension of the existing RFC. (It's still the case though that tuples with unsized values are not well supported by the existing compiler.) |
arielb1 commentedApr 27, 2016
•
edited
This oversight was found while working on rust-lang/rust#33138.
Tuples with an unsized field in the middle can't possibly work. Tuples with an unsized field at the end should work after we refactor
trans::adt.