Skip to content

Commit b1d1bfd

Browse files
committed
Revert "Permit multiple lifetime bounds on parameter types",
which was pushed accidentally. This reverts commit 5e8d273.
1 parent 5e8d273 commit b1d1bfd

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

active/0049-bounds-on-object-and-generic-types.md

+21-3
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,24 @@ declared:
6969
Here, the constraint `T:'a` indicates that the data being iterated
7070
over must live at least as long as the collection (logically enough).
7171

72+
### At most one explicit lifetime bound is permitted
73+
74+
For simplicity, we permit at most one *explicit* lifetime bound on any
75+
given parameter type. That means that the following function is illegal:
76+
77+
fn foo<'a,'b,A:'a+'b>() { ... }
78+
79+
Remember that if there are multiple lifetime bounds, it implies that
80+
all of them must hold. That means that if, in fact, `A` outlives both
81+
`'a` and `'b` then either one of them is shorter than the other, the
82+
two are the same, or there is a third lifetime that outlives them
83+
both. Therefore, the function above can be rewritten as follows (using
84+
explicit lifetime bounds, specified below):
85+
86+
fn foo<'a,'b,'c:'a+'b,A:'c>() { ... }
87+
88+
As far as I know, this situation has not arisen once in the codebase.
89+
7290
## Lifetime bounds on object types
7391

7492
Like parameters, all object types have a lifetime bound. Unlike
@@ -95,9 +113,9 @@ Here are some examples:
95113
// IsStatic+'a 'static+'a
96114
// IsStatic+Is<'a>+'b 'static,'a,'b
97115

98-
Object types must have exactly one bound -- zero bounds is not
99-
acceptable. Therefore, if an object type with no derivable bounds
100-
appears, we will supply a default lifetime using the normal rules:
116+
In general no object type is permitted to have zero bounds. Therefore,
117+
if an object type with no derivable bounds appears, we will supply a
118+
default lifetime using the normal rules:
101119

102120
trait Writer { /* no derivable bounds */ }
103121
struct Foo<'a> {

0 commit comments

Comments
 (0)