Skip to content

Commit b2c8577

Browse files
committed
all but the last field of a tuple must be Sized
1 parent bf9fca6 commit b2c8577

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

text/1214-projections-lifetimes-and-wf.md

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ For example, in practice, many iterator implementation break due to
366366
region relationships:
367367

368368
```rust
369-
impl<'a, T> IntoIterator for &'a LinkedList<T> {
369+
impl<'a, T> IntoIterator for &'a LinkedList<T> {
370370
type Item = &'a T;
371371
...
372372
}
@@ -402,14 +402,14 @@ types:
402402
| T // Type
403403
O = for<r..> TraitId<P1..Pn> // Object type fragment
404404
r = 'x // Region name
405-
405+
406406
We'll use this to describe the rules in detail.
407407

408408
A quick note on terminology: an "object type fragment" is part of an
409409
object type: so if you have `Box<FnMut()+Send>`, `FnMut()` and `Send`
410410
are object type fragments. Object type fragments are identical to full
411411
trait references, except that they do not have a self type (no `P0`).
412-
412+
413413
### Syntactic definition of the outlives relation
414414

415415
The outlives relation is defined in purely syntactic terms as follows.
@@ -454,8 +454,8 @@ or projections are involved:
454454
OutlivesFragment:
455455
∀i. R,r.. ⊢ Pi: 'a
456456
--------------------------------------------------
457-
R ⊢ for<r..> TraitId<P0..Pn>: 'a
458-
457+
R ⊢ for<r..> TraitId<P0..Pn>: 'a
458+
459459
#### Outlives for lifetimes
460460

461461
The outlives relation for lifetimes depends on whether the lifetime in
@@ -487,7 +487,7 @@ lifetime is not yet known. This means for example that `for<'a> fn(&'a
487487
i32): 'x` holds, even though we do not yet know what region `'a` is
488488
(and in fact it may be instantiated many times with different values
489489
on each call to the fn).
490-
490+
491491
OutlivesRegionBound:
492492
'x ∈ R // bound region
493493
--------------------------------------------------
@@ -525,7 +525,7 @@ but reflects the behavior of my prototype implementation.)
525525
<> ⊢ <P0 as Trait<P1..Pn>>::Id: 'a
526526

527527
OutlivesProjectionTraitDef:
528-
WC = [Xi => Pi] WhereClauses(Trait)
528+
WC = [Xi => Pi] WhereClauses(Trait)
529529
<P0 as Trait<P1..Pn>>::Id: 'b in WC
530530
<> ⊢ 'b: 'a
531531
--------------------------------------------------
@@ -643,7 +643,7 @@ form:
643643
```
644644
C = r0: r1
645645
| C AND C
646-
```
646+
```
647647

648648
This is convenient because a simple fixed-point iteration suffices to
649649
find the minimal regions which satisfy the constraints.
@@ -719,6 +719,7 @@ declare one), but we'll take those basic conditions for granted.
719719

720720
WfTuple:
721721
∀i. R ⊢ Ti WF
722+
∀i<n. R ⊢ Ti: Sized // the *last* field may be unsized
722723
--------------------------------------------------
723724
R ⊢ (T0..Tn) WF
724725

@@ -812,7 +813,7 @@ object type fragment is WF if its components are WF:
812813
TraitId is object safe
813814
--------------------------------------------------
814815
R ⊢ for<r..> TraitId<P1..Pn>
815-
816+
816817
Note that we don't check the where clauses declared on the trait
817818
itself. These are checked when the object is created. The reason not
818819
to check them here is because the `Self` type is not known (this is an
@@ -1024,15 +1025,15 @@ that a projection outlives `'a` if its inputs outlive `'a`. To start,
10241025
let's specify the projection `<PROJ>` as:
10251026

10261027
<P0 as Trait<P1...Pn>>::Id
1027-
1028+
10281029
where `P` can be a lifetime or type parameter as appropriate.
1029-
1030+
10301031
Then we know that there exists some impl of the form:
10311032

10321033
```rust
10331034
impl<X0..Xn> Trait<Q1..Qn> for Q0 {
10341035
type Id = T;
1035-
}
1036+
}
10361037
```
10371038

10381039
Here again, `X` can be a lifetime or type parameter name, and `Q` can
@@ -1105,6 +1106,11 @@ then `R ⊢ P': 'a`. Proceed by induction and by cases over the form of `P`:
11051106
in a type outlive `'a`, then the type outlives `'a`. Follows by
11061107
inspection of the outlives rules.
11071108

1109+
# Edit History
1110+
1111+
[RFC1592] - amend to require that tuple fields be sized
1112+
11081113
[crater-errors]: https://gist.github.com/nikomatsakis/2f851e2accfa7ba2830d#root-regressions-sorted-by-rank
11091114
[crater-all]: https://gist.github.com/nikomatsakis/364fae49de18268680f2#root-regressions-sorted-by-rank
11101115
[#21953]: https://github.com/rust-lang/rust/issues/21953
1116+
[RFC1592]: https://github.com/rust-lang/rfcs/pull/1592

0 commit comments

Comments
 (0)